@@ -80,7 +80,7 @@ const char kInlinedScriptFormat[] =
80
80
" <script type=\" text/javascript\" "
81
81
" id=\" pagespeed_script_%d\" data-pagespeed-no-defer>"
82
82
" pagespeed.dedupInlinedImages.inlineImg("
83
- " 'pagespeed_img_0','pagespeed_img_0','pagespeed_script_%d'"
83
+ " 'pagespeed_img_0%d ','pagespeed_img_0%d ','pagespeed_script_%d'"
84
84
" );</script>" ;
85
85
86
86
const char kHtmlWrapperFormat [] =
@@ -162,7 +162,7 @@ TEST_F(DedupInlinedImagesTest, InlineSingleSmallImage) {
162
162
TestDedupImages (" inline_single_small_image" , " " , " " ,
163
163
StrCat (" <img src='" , kCuppaPngFilename , " '>" ),
164
164
StrCat (" <img src='" , kCuppaPngInlineData ,
165
- " ' id=\" pagespeed_img_0 \" >" ));
165
+ " ' id=\" pagespeed_img_01 \" >" ));
166
166
}
167
167
168
168
TEST_F (DedupInlinedImagesTest, DontInlineLargeImage) {
@@ -178,10 +178,10 @@ TEST_F(DedupInlinedImagesTest, DedupSecondSmallImage) {
178
178
StrCat (" <img src='" , kCuppaPngFilename , " '>\n " ,
179
179
" <img src='" , kCuppaPngFilename , " '>" ),
180
180
StrCat (" <img src='" , kCuppaPngInlineData ,
181
- " ' id=\" pagespeed_img_0 \" >\n " ,
181
+ " ' id=\" pagespeed_img_01 \" >\n " ,
182
182
InsertScriptBefore (
183
- StrCat (" <img id=\" pagespeed_img_0 \" >" ,
184
- StringPrintf (kInlinedScriptFormat , 1 , 1 )))));
183
+ StrCat (" <img id=\" pagespeed_img_02 \" >" ,
184
+ StringPrintf (kInlinedScriptFormat , 3 , 1 , 2 , 3 )))));
185
185
}
186
186
187
187
TEST_F (DedupInlinedImagesTest, DedupManySmallImages) {
@@ -190,12 +190,12 @@ TEST_F(DedupInlinedImagesTest, DedupManySmallImages) {
190
190
TestDedupImages (
191
191
" dedup_many_small_images" , " " , " " ,
192
192
StrCat (image, " \n " , image, " \n " , image),
193
- StrCat (" <img src='" , kCuppaPngInlineData , " ' id=\" pagespeed_img_0 \" >\n " ,
193
+ StrCat (" <img src='" , kCuppaPngInlineData , " ' id=\" pagespeed_img_01 \" >\n " ,
194
194
InsertScriptBefore (
195
- StrCat (" <img id=\" pagespeed_img_0 \" >" ,
196
- StringPrintf (kInlinedScriptFormat , 1 , 1 ), " \n " ,
197
- " <img id=\" pagespeed_img_0 \" >" ,
198
- StringPrintf (kInlinedScriptFormat , 2 , 2 )))));
195
+ StrCat (" <img id=\" pagespeed_img_02 \" >" ,
196
+ StringPrintf (kInlinedScriptFormat , 3 , 1 , 2 , 3 ), " \n " ,
197
+ " <img id=\" pagespeed_img_04 \" >" ,
198
+ StringPrintf (kInlinedScriptFormat , 5 , 1 , 4 , 5 )))));
199
199
}
200
200
201
201
TEST_F (DedupInlinedImagesTest, DedupSecondSmallImageWithId) {
@@ -205,14 +205,14 @@ TEST_F(DedupInlinedImagesTest, DedupSecondSmallImageWithId) {
205
205
" <img src='" , kCuppaPngFilename , " '>" ),
206
206
StrCat (" <img src='" , kCuppaPngInlineData , " ' id='xyzzy'>\n " ,
207
207
InsertScriptBefore (
208
- " <img id=\" pagespeed_img_0 \" >"
208
+ " <img id=\" pagespeed_img_01 \" >"
209
209
" <script type=\" text/javascript\" "
210
- " id=\" pagespeed_script_1 \" "
210
+ " id=\" pagespeed_script_2 \" "
211
211
" data-pagespeed-no-defer>"
212
212
" pagespeed.dedupInlinedImages.inlineImg("
213
213
" 'xyzzy',"
214
- " 'pagespeed_img_0 ',"
215
- " 'pagespeed_script_1 ');"
214
+ " 'pagespeed_img_01 ',"
215
+ " 'pagespeed_script_2 ');"
216
216
" </script>" )));
217
217
}
218
218
@@ -223,16 +223,16 @@ TEST_F(DedupInlinedImagesTest, DedupSecondSmallImageWithAttributes) {
223
223
" <img src='" , kCuppaPngFilename ,
224
224
" ' alt='xyzzy' id='plugh'>" ),
225
225
StrCat (" <img src='" , kCuppaPngInlineData ,
226
- " ' id=\" pagespeed_img_0 \" >\n " ,
226
+ " ' id=\" pagespeed_img_01 \" >\n " ,
227
227
InsertScriptBefore (
228
228
" <img alt='xyzzy' id='plugh'>"
229
229
" <script type=\" text/javascript\" "
230
- " id=\" pagespeed_script_1 \" "
230
+ " id=\" pagespeed_script_2 \" "
231
231
" data-pagespeed-no-defer>"
232
232
" pagespeed.dedupInlinedImages.inlineImg("
233
- " 'pagespeed_img_0 ',"
233
+ " 'pagespeed_img_01 ',"
234
234
" 'plugh',"
235
- " 'pagespeed_script_1 ');"
235
+ " 'pagespeed_script_2 ');"
236
236
" </script>" )));
237
237
}
238
238
@@ -293,15 +293,17 @@ TEST_F(DedupInlinePreviewImagesTest, DedupInlinePreviewImages) {
293
293
" \" onload=\" " , DelayImagesFilter::kImageOnloadCode ,
294
294
" \" onerror=\" this.onerror=null;" ,
295
295
DelayImagesFilter::kImageOnloadCode ,
296
- " \" id=\" pagespeed_img_0 \" />" );
297
- GoogleString scripted_img =
296
+ " \" id=\" pagespeed_img_01 \" />" );
297
+ GoogleString scripted_img_fmt =
298
298
StrCat (" <img data-pagespeed-high-res-src='" , image_filename,
299
299
" ' onload=\" " , DelayImagesFilter::kImageOnloadCode ,
300
300
" \" onerror=\" this.onerror=null;" ,
301
301
DelayImagesFilter::kImageOnloadCode ,
302
- " \" id=\" pagespeed_img_0\" />" );
303
- GoogleString script_1 = StringPrintf (kInlinedScriptFormat , 1 , 1 );
304
- GoogleString script_2 = StringPrintf (kInlinedScriptFormat , 2 , 2 );
302
+ " \" id=\" pagespeed_img_0%d\" />" );
303
+ GoogleString scripted_img_1 = StringPrintf (scripted_img_fmt.c_str (), 2 );
304
+ GoogleString scripted_img_2 = StringPrintf (scripted_img_fmt.c_str (), 4 );
305
+ GoogleString script_1 = StringPrintf (kInlinedScriptFormat , 3 , 1 , 2 , 3 );
306
+ GoogleString script_2 = StringPrintf (kInlinedScriptFormat , 5 , 1 , 4 , 5 );
305
307
GoogleString input_html = StrCat (" <head></head>"
306
308
" <body>" ,
307
309
input_img, input_img, input_img,
@@ -312,8 +314,8 @@ TEST_F(DedupInlinePreviewImagesTest, DedupInlinePreviewImages) {
312
314
GetImageOnloadScriptBlock (),
313
315
inlined_img,
314
316
InsertScriptBefore (
315
- StrCat (scripted_img , script_1,
316
- scripted_img , script_2)),
317
+ StrCat (scripted_img_1 , script_1,
318
+ scripted_img_2 , script_2)),
317
319
" </body>" );
318
320
319
321
// Since the preview image has been resized use a wildcard to match it.
0 commit comments