Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: headless/public/util/dom_tree_extractor_browsertest.cc

Issue 2534873002: Use the Ahem font to try and deflake DomTreeExtractorBrowserTest (Closed)
Patch Set: Try and use ahem on every element Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | headless/test/data/Ahem.ttf » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "headless/public/util/dom_tree_extractor.h" 5 #include "headless/public/util/dom_tree_extractor.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 devtools_client_->GetPage()->Navigate( 47 devtools_client_->GetPage()->Navigate(
48 embedded_test_server()->GetURL("/dom_tree_test.html").spec()); 48 embedded_test_server()->GetURL("/dom_tree_test.html").spec());
49 } 49 }
50 50
51 void OnLoadEventFired(const page::LoadEventFiredParams& params) override { 51 void OnLoadEventFired(const page::LoadEventFiredParams& params) override {
52 devtools_client_->GetPage()->RemoveObserver(this); 52 devtools_client_->GetPage()->RemoveObserver(this);
53 53
54 extractor_.reset(new DomTreeExtractor(devtools_client_.get())); 54 extractor_.reset(new DomTreeExtractor(devtools_client_.get()));
55 55
56 std::vector<std::string> css_whitelist = { 56 std::vector<std::string> css_whitelist = {
57 "color", "display", "font-style", "margin-left", 57 "color", "display", "font-style", "font-family",
58 "margin-right", "margin-top", "margin-bottom"}; 58 "margin-left", "margin-right", "margin-top", "margin-bottom"};
59 extractor_->ExtractDomTree( 59 extractor_->ExtractDomTree(
60 css_whitelist, 60 css_whitelist,
61 base::Bind(&DomTreeExtractorBrowserTest::OnDomTreeExtracted, 61 base::Bind(&DomTreeExtractorBrowserTest::OnDomTreeExtracted,
62 base::Unretained(this))); 62 base::Unretained(this)));
63 } 63 }
64 64
65 void OnDomTreeExtracted(DomTreeExtractor::DomTree dom_tree) { 65 void OnDomTreeExtracted(DomTreeExtractor::DomTree dom_tree) {
66 GURL::Replacements replace_port; 66 GURL::Replacements replace_port;
67 replace_port.SetPortStr(""); 67 replace_port.SetPortStr("");
68 68
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 R"raw_string({ 175 R"raw_string({
176 "attributes": [ ], 176 "attributes": [ ],
177 "backendNodeId": 4, 177 "backendNodeId": 4,
178 "boundingBox": { 178 "boundingBox": {
179 "height": 600.0, 179 "height": 600.0,
180 "width": 800.0, 180 "width": 800.0,
181 "x": 0.0, 181 "x": 0.0,
182 "y": 0.0 182 "y": 0.0
183 }, 183 },
184 "childIndices": [ 2, 5 ], 184 "childIndices": [ 2, 6 ],
185 "frameId": "?", 185 "frameId": "?",
186 "localName": "html", 186 "localName": "html",
187 "nodeId": 2, 187 "nodeId": 2,
188 "nodeName": "HTML", 188 "nodeName": "HTML",
189 "nodeType": 1, 189 "nodeType": 1,
190 "nodeValue": "", 190 "nodeValue": "",
191 "styleIndex": 0 191 "styleIndex": 0
192 })raw_string", 192 })raw_string",
193 193
194 R"raw_string({ 194 R"raw_string({
195 "attributes": [ ], 195 "attributes": [ ],
196 "backendNodeId": 5, 196 "backendNodeId": 5,
197 "childIndices": [ 3 ], 197 "childIndices": [ 3, 5 ],
198 "localName": "head", 198 "localName": "head",
199 "nodeId": 3, 199 "nodeId": 3,
200 "nodeName": "HEAD", 200 "nodeName": "HEAD",
201 "nodeType": 1, 201 "nodeType": 1,
202 "nodeValue": "" 202 "nodeValue": ""
203 })raw_string", 203 })raw_string",
204 204
205 R"raw_string({ 205 R"raw_string({
206 "attributes": [ ], 206 "attributes": [ ],
207 "backendNodeId": 6, 207 "backendNodeId": 6,
208 "childIndices": [ 4 ], 208 "childIndices": [ 4 ],
209 "localName": "title", 209 "localName": "title",
210 "nodeId": 4, 210 "nodeId": 4,
211 "nodeName": "TITLE", 211 "nodeName": "TITLE",
212 "nodeType": 1, 212 "nodeType": 1,
213 "nodeValue": "" 213 "nodeValue": ""
214 })raw_string", 214 })raw_string",
215 215
216 R"raw_string({ 216 R"raw_string({
217 "backendNodeId": 7, 217 "backendNodeId": 7,
218 "localName": "", 218 "localName": "",
219 "nodeId": 5, 219 "nodeId": 5,
220 "nodeName": "#text", 220 "nodeName": "#text",
221 "nodeType": 3, 221 "nodeType": 3,
222 "nodeValue": "Hello world!" 222 "nodeValue": "Hello world!"
223 })raw_string", 223 })raw_string",
224 224
225 R"raw_string({ 225 R"raw_string({
226 "attributes": [ "href", "dom_tree_test.css", "rel", "stylesheet",
227 "type", "text/css" ],
228 "backendNodeId": 8,
229 "childIndices": [ ],
230 "localName": "link",
231 "nodeId": 6,
232 "nodeName": "LINK",
233 "nodeType": 1,
234 "nodeValue": ""
235 })raw_string",
236
237 R"raw_string({
226 "attributes": [ ], 238 "attributes": [ ],
227 "backendNodeId": 8, 239 "backendNodeId": 9,
228 "boundingBox": { 240 "boundingBox": {
229 "height": 584.0, 241 "height": 584.0,
230 "width": 784.0, 242 "width": 784.0,
231 "x": 8.0, 243 "x": 8.0,
232 "y": 8.0 244 "y": 8.0
233 }, 245 },
234 "childIndices": [ 6 ], 246 "childIndices": [ 7 ],
235 "localName": "body", 247 "localName": "body",
236 "nodeId": 6, 248 "nodeId": 7,
237 "nodeName": "BODY", 249 "nodeName": "BODY",
238 "nodeType": 1, 250 "nodeType": 1,
239 "nodeValue": "", 251 "nodeValue": "",
240 "styleIndex": 1 252 "styleIndex": 1
241 })raw_string", 253 })raw_string",
242 254
243 R"raw_string({ 255 R"raw_string({
244 "attributes": [ "id", "id1" ], 256 "attributes": [ "id", "id1" ],
245 "backendNodeId": 9, 257 "backendNodeId": 10,
246 "boundingBox": { 258 "boundingBox": {
247 "height": 367.0, 259 "height": 354.0,
248 "width": 784.0, 260 "width": 784.0,
249 "x": 8.0, 261 "x": 8.0,
250 "y": 8.0 262 "y": 8.0
251 }, 263 },
252 "childIndices": [ 7, 9, 16 ], 264 "childIndices": [ 8, 10, 17 ],
253 "localName": "div", 265 "localName": "div",
254 "nodeId": 7, 266 "nodeId": 8,
255 "nodeName": "DIV", 267 "nodeName": "DIV",
256 "nodeType": 1, 268 "nodeType": 1,
257 "nodeValue": "", 269 "nodeValue": "",
258 "styleIndex": 0 270 "styleIndex": 0
259 })raw_string", 271 })raw_string",
260 272
261 R"raw_string({ 273 R"raw_string({
262 "attributes": [ "style", "color: red" ], 274 "attributes": [ "class", "red" ],
263 "backendNodeId": 10, 275 "backendNodeId": 11,
264 "boundingBox": { 276 "boundingBox": {
265 "height": 37.0, 277 "height": 32.0,
266 "width": 784.0, 278 "width": 784.0,
267 "x": 8.0, 279 "x": 8.0,
268 "y": 8.0 280 "y": 8.0
269 }, 281 },
270 "childIndices": [ 8 ], 282 "childIndices": [ 9 ],
271 "localName": "h1", 283 "localName": "h1",
272 "nodeId": 8, 284 "nodeId": 9,
273 "nodeName": "H1", 285 "nodeName": "H1",
274 "nodeType": 1, 286 "nodeType": 1,
275 "nodeValue": "", 287 "nodeValue": "",
276 "styleIndex": 2 288 "styleIndex": 2
277 })raw_string", 289 })raw_string",
278 290
279 R"raw_string({ 291 R"raw_string({
280 "backendNodeId": 11, 292 "backendNodeId": 12,
281 "boundingBox": { 293 "boundingBox": {
282 "height": 36.0, 294 "height": 32.0,
283 "width": 143.0, 295 "width": 320.0,
284 "x": 8.0, 296 "x": 8.0,
285 "y": 8.0 297 "y": 8.0
286 }, 298 },
287 "inlineTextNodes": [ { 299 "inlineTextNodes": [ {
288 "boundingBox": { 300 "boundingBox": {
289 "height": 36.0, 301 "height": 32.0,
290 "width": 142.171875, 302 "width": 320.0,
291 "x": 8.0, 303 "x": 8.0,
292 "y": 8.0 304 "y": 8.0
293 }, 305 },
294 "numCharacters": 10, 306 "numCharacters": 10,
295 "startCharacterIndex": 0 307 "startCharacterIndex": 0
296 } ], 308 } ],
297 "layoutText": "Some text.", 309 "layoutText": "Some text.",
298 "localName": "", 310 "localName": "",
299 "nodeId": 9, 311 "nodeId": 10,
300 "nodeName": "#text", 312 "nodeName": "#text",
301 "nodeType": 3, 313 "nodeType": 3,
302 "nodeValue": "Some text.", 314 "nodeValue": "Some text.",
303 "styleIndex": 2 315 "styleIndex": 2
304 })raw_string", 316 })raw_string",
305 317
306 R"raw_string({ 318 R"raw_string({
307 "attributes": [ 319 "attributes": [ "src", "/iframe.html", "width", "400", "height",
308 "src", "/iframe.html", "width", "400", "height", "200" ], 320 "200" ],
309 "backendNodeId": 12, 321 "backendNodeId": 13,
310 "boundingBox": { 322 "boundingBox": {
311 "height": 205.0, 323 "height": 205.0,
312 "width": 404.0, 324 "width": 404.0,
313 "x": 8.0, 325 "x": 8.0,
314 "y": 66.0 326 "y": 61.0
315 }, 327 },
316 "childIndices": [ ], 328 "childIndices": [ ],
317 "contentDocumentIndex": 10, 329 "contentDocumentIndex": 11,
318 "frameId": "?", 330 "frameId": "?",
319 "localName": "iframe", 331 "localName": "iframe",
320 "nodeId": 10, 332 "nodeId": 11,
321 "nodeName": "IFRAME", 333 "nodeName": "IFRAME",
322 "nodeType": 1, 334 "nodeType": 1,
323 "nodeValue": "", 335 "nodeValue": "",
324 "styleIndex": 4 336 "styleIndex": 6
325 })raw_string", 337 })raw_string",
326 338
327 R"raw_string({ 339 R"raw_string({
328 "backendNodeId": 13, 340 "backendNodeId": 14,
329 "baseURL": "http://127.0.0.1/iframe.html", 341 "baseURL": "http://127.0.0.1/iframe.html",
330 "childIndices": [ 11 ], 342 "childIndices": [ 12 ],
331 "documentURL": "http://127.0.0.1/iframe.html", 343 "documentURL": "http://127.0.0.1/iframe.html",
332 "localName": "", 344 "localName": "",
333 "nodeId": 11, 345 "nodeId": 12,
334 "nodeName": "#document", 346 "nodeName": "#document",
335 "nodeType": 9, 347 "nodeType": 9,
336 "nodeValue": "", 348 "nodeValue": "",
337 "xmlVersion": "" 349 "xmlVersion": ""
338 })raw_string", 350 })raw_string",
339 351
340 R"raw_string({ 352 R"raw_string({
341 "attributes": [ ], 353 "attributes": [ ],
342 "backendNodeId": 14, 354 "backendNodeId": 15,
343 "boundingBox": { 355 "boundingBox": {
344 "height": 200.0, 356 "height": 200.0,
345 "width": 400.0, 357 "width": 400.0,
346 "x": 10.0, 358 "x": 10.0,
347 "y": 68.0 359 "y": 63.0
348 }, 360 },
349 "childIndices": [ 12, 13 ], 361 "childIndices": [ 13, 14 ],
350 "frameId": "?", 362 "frameId": "?",
351 "localName": "html", 363 "localName": "html",
352 "nodeId": 12, 364 "nodeId": 13,
353 "nodeName": "HTML", 365 "nodeName": "HTML",
354 "nodeType": 1, 366 "nodeType": 1,
355 "nodeValue": "", 367 "nodeValue": "",
356 "styleIndex": 0 368 "styleIndex": 3
357 })raw_string", 369 })raw_string",
358 370
359 R"raw_string({ 371 R"raw_string({
360 "attributes": [ ], 372 "attributes": [ ],
361 "backendNodeId": 15, 373 "backendNodeId": 16,
362 "childIndices": [ ], 374 "childIndices": [ ],
363 "localName": "head", 375 "localName": "head",
364 "nodeId": 13, 376 "nodeId": 14,
365 "nodeName": "HEAD", 377 "nodeName": "HEAD",
366 "nodeType": 1, 378 "nodeType": 1,
367 "nodeValue": "" 379 "nodeValue": ""
368 })raw_string", 380 })raw_string",
369 381
370 R"raw_string({ 382 R"raw_string({
371 "attributes": [ ], 383 "attributes": [ ],
372 "backendNodeId": 16,
373 "boundingBox": {
374 "height": 171.0,
375 "width": 384.0,
376 "x": 18.0,
377 "y": 76.0
378 },
379 "childIndices": [ 14 ],
380 "localName": "body",
381 "nodeId": 14,
382 "nodeName": "BODY",
383 "nodeType": 1,
384 "nodeValue": "",
385 "styleIndex": 1
386 })raw_string",
387
388 R"raw_string({
389 "attributes": [ ],
390 "backendNodeId": 17, 384 "backendNodeId": 17,
391 "boundingBox": { 385 "boundingBox": {
386 "height": 171.0,
387 "width": 384.0,
388 "x": 18.0,
389 "y": 71.0
390 },
391 "childIndices": [ 15 ],
392 "localName": "body",
393 "nodeId": 15,
394 "nodeName": "BODY",
395 "nodeType": 1,
396 "nodeValue": "",
397 "styleIndex": 4
398 })raw_string",
399
400 R"raw_string({
401 "attributes": [ ],
402 "backendNodeId": 18,
403 "boundingBox": {
392 "height": 37.0, 404 "height": 37.0,
393 "width": 384.0, 405 "width": 384.0,
394 "x": 18.0, 406 "x": 18.0,
395 "y": 76.0 407 "y": 71.0
396 }, 408 },
397 "childIndices": [ 15 ], 409 "childIndices": [ 16 ],
398 "localName": "h1", 410 "localName": "h1",
399 "nodeId": 15, 411 "nodeId": 16,
400 "nodeName": "H1", 412 "nodeName": "H1",
401 "nodeType": 1, 413 "nodeType": 1,
402 "nodeValue": "", 414 "nodeValue": "",
403 "styleIndex": 3 415 "styleIndex": 5
404 })raw_string", 416 })raw_string",
405 417
406 R"raw_string({ 418 R"raw_string({
407 "backendNodeId": 18, 419 "backendNodeId": 19,
408 "boundingBox": { 420 "boundingBox": {
409 "height": 36.0, 421 "height": 36.0,
410 "width": 308.0, 422 "width": 308.0,
411 "x": 8.0, 423 "x": 8.0,
412 "y": 8.0 424 "y": 8.0
413 }, 425 },
414 "inlineTextNodes": [ { 426 "inlineTextNodes": [ {
415 "boundingBox": { 427 "boundingBox": {
416 "height": 36.0, 428 "height": 36.0,
417 "width": 307.734375, 429 "width": 307.734375,
418 "x": 8.0, 430 "x": 8.0,
419 "y": 8.0 431 "y": 8.0
420 }, 432 },
421 "numCharacters": 22, 433 "numCharacters": 22,
422 "startCharacterIndex": 0 434 "startCharacterIndex": 0
423 } ], 435 } ],
424 "layoutText": "Hello from the iframe!", 436 "layoutText": "Hello from the iframe!",
425 "localName": "", 437 "localName": "",
426 "nodeId": 16, 438 "nodeId": 17,
427 "nodeName": "#text", 439 "nodeName": "#text",
428 "nodeType": 3, 440 "nodeType": 3,
429 "nodeValue": "Hello from the iframe!", 441 "nodeValue": "Hello from the iframe!",
430 "styleIndex": 3 442 "styleIndex": 5
431 })raw_string", 443 })raw_string",
432 444
433 R"raw_string({ 445 R"raw_string({
434 "attributes": [ "id", "id2" ], 446 "attributes": [ "id", "id2" ],
435 "backendNodeId": 19, 447 "backendNodeId": 20,
436 "boundingBox": { 448 "boundingBox": {
437 "height": 105.0, 449 "height": 97.0,
438 "width": 784.0, 450 "width": 784.0,
439 "x": 8.0, 451 "x": 8.0,
440 "y": 270.0 452 "y": 265.0
441 }, 453 },
442 "childIndices": [ 17 ], 454 "childIndices": [ 18 ],
443 "localName": "div", 455 "localName": "div",
444 "nodeId": 17, 456 "nodeId": 18,
445 "nodeName": "DIV", 457 "nodeName": "DIV",
446 "nodeType": 1, 458 "nodeType": 1,
447 "nodeValue": "", 459 "nodeValue": "",
448 "styleIndex": 0 460 "styleIndex": 0
449 })raw_string", 461 })raw_string",
450 462
451 R"raw_string({ 463 R"raw_string({
452 "attributes": [ "id", "id3" ], 464 "attributes": [ "id", "id3" ],
453 "backendNodeId": 20, 465 "backendNodeId": 21,
454 "boundingBox": { 466 "boundingBox": {
455 "height": 105.0, 467 "height": 97.0,
456 "width": 784.0, 468 "width": 784.0,
457 "x": 8.0, 469 "x": 8.0,
458 "y": 270.0 470 "y": 265.0
459 }, 471 },
460 "childIndices": [ 18 ], 472 "childIndices": [ 19 ],
461 "localName": "div", 473 "localName": "div",
462 "nodeId": 18, 474 "nodeId": 19,
463 "nodeName": "DIV", 475 "nodeName": "DIV",
464 "nodeType": 1, 476 "nodeType": 1,
465 "nodeValue": "", 477 "nodeValue": "",
466 "styleIndex": 0 478 "styleIndex": 0
467 })raw_string", 479 })raw_string",
468 480
469 R"raw_string({ 481 R"raw_string({
470 "attributes": [ "id", "id4" ], 482 "attributes": [ "id", "id4" ],
471 "backendNodeId": 21, 483 "backendNodeId": 22,
472 "boundingBox": { 484 "boundingBox": {
473 "height": 105.0, 485 "height": 97.0,
474 "width": 784.0, 486 "width": 784.0,
475 "x": 8.0, 487 "x": 8.0,
476 "y": 270.0 488 "y": 265.0
477 }, 489 },
478 "childIndices": [ 19, 21, 23, 24 ], 490 "childIndices": [ 20, 22, 24, 25 ],
479 "localName": "div", 491 "localName": "div",
480 "nodeId": 19, 492 "nodeId": 20,
481 "nodeName": "DIV", 493 "nodeName": "DIV",
482 "nodeType": 1, 494 "nodeType": 1,
483 "nodeValue": "", 495 "nodeValue": "",
484 "styleIndex": 0 496 "styleIndex": 0
485 })raw_string", 497 })raw_string",
486 498
487 R"raw_string({ 499 R"raw_string({
488 "attributes": [ "href", "https://www.google.com" ], 500 "attributes": [ "href", "https://www.google.com" ],
489 "backendNodeId": 22, 501 "backendNodeId": 23,
490 "boundingBox": { 502 "boundingBox": {
491 "height": 18.0, 503 "height": 17.0,
492 "width": 53.0, 504 "width": 112.0,
493 "x": 8.0, 505 "x": 8.0,
494 "y": 270.0 506 "y": 265.0
495 }, 507 },
496 "childIndices": [ 20 ], 508 "childIndices": [ 21 ],
497 "localName": "a", 509 "localName": "a",
498 "nodeId": 20, 510 "nodeId": 21,
499 "nodeName": "A", 511 "nodeName": "A",
500 "nodeType": 1, 512 "nodeType": 1,
501 "nodeValue": "", 513 "nodeValue": "",
502 "styleIndex": 5 514 "styleIndex": 7
503 })raw_string", 515 })raw_string",
504 516
505 R"raw_string({ 517 R"raw_string({
506 "backendNodeId": 23, 518 "backendNodeId": 24,
507 "boundingBox": { 519 "boundingBox": {
508 "height": 18.0, 520 "height": 17.0,
509 "width": 53.0, 521 "width": 112.0,
510 "x": 8.0, 522 "x": 8.0,
511 "y": 270.0 523 "y": 265.0
512 }, 524 },
513 "inlineTextNodes": [ { 525 "inlineTextNodes": [ {
514 "boundingBox": { 526 "boundingBox": {
515 "height": 17.0, 527 "height": 16.0,
516 "width": 52.421875, 528 "width": 112.0,
517 "x": 8.0, 529 "x": 8.0,
518 "y": 270.4375 530 "y": 265.4375
519 }, 531 },
520 "numCharacters": 7, 532 "numCharacters": 7,
521 "startCharacterIndex": 0 533 "startCharacterIndex": 0
522 } ], 534 } ],
523 "layoutText": "Google!", 535 "layoutText": "Google!",
524 "localName": "", 536 "localName": "",
525 "nodeId": 21, 537 "nodeId": 22,
526 "nodeName": "#text", 538 "nodeName": "#text",
527 "nodeType": 3, 539 "nodeType": 3,
528 "nodeValue": "Google!", 540 "nodeValue": "Google!",
529 "styleIndex": 5 541 "styleIndex": 7
530 })raw_string", 542 })raw_string",
531 543
532 R"raw_string({ 544 R"raw_string({
533 "attributes": [ ], 545 "attributes": [ ],
534 "backendNodeId": 24, 546 "backendNodeId": 25,
535 "boundingBox": { 547 "boundingBox": {
536 "height": 19.0, 548 "height": 17.0,
537 "width": 784.0, 549 "width": 784.0,
538 "x": 8.0, 550 "x": 8.0,
539 "y": 304.0 551 "y": 297.0
540 }, 552 },
541 "childIndices": [ 22 ], 553 "childIndices": [ 23 ],
542 "localName": "p", 554 "localName": "p",
543 "nodeId": 22, 555 "nodeId": 23,
544 "nodeName": "P", 556 "nodeName": "P",
545 "nodeType": 1, 557 "nodeType": 1,
546 "nodeValue": "", 558 "nodeValue": "",
547 "styleIndex": 6 559 "styleIndex": 8
548 })raw_string", 560 })raw_string",
549 561
550 R"raw_string({ 562 R"raw_string({
551 "backendNodeId": 25, 563 "backendNodeId": 26,
552 "boundingBox": { 564 "boundingBox": {
553 "height": 18.0, 565 "height": 17.0,
554 "width": 85.0, 566 "width": 192.0,
555 "x": 8.0, 567 "x": 8.0,
556 "y": 304.0 568 "y": 297.0
557 }, 569 },
558 "inlineTextNodes": [ { 570 "inlineTextNodes": [ {
559 "boundingBox": { 571 "boundingBox": {
560 "height": 17.0, 572 "height": 16.0,
561 "width": 84.84375, 573 "width": 192.0,
562 "x": 8.0, 574 "x": 8.0,
563 "y": 304.4375 575 "y": 297.4375
564 }, 576 },
565 "numCharacters": 12, 577 "numCharacters": 12,
566 "startCharacterIndex": 0 578 "startCharacterIndex": 0
567 } ], 579 } ],
568 "layoutText": "A paragraph!", 580 "layoutText": "A paragraph!",
569 "localName": "", 581 "localName": "",
570 "nodeId": 23, 582 "nodeId": 24,
571 "nodeName": "#text", 583 "nodeName": "#text",
572 "nodeType": 3, 584 "nodeType": 3,
573 "nodeValue": "A paragraph!", 585 "nodeValue": "A paragraph!",
574 "styleIndex": 6 586 "styleIndex": 8
575 })raw_string", 587 })raw_string",
576 588
577 R"raw_string({ 589 R"raw_string({
578 "attributes": [ ], 590 "attributes": [ ],
579 "backendNodeId": 26, 591 "backendNodeId": 27,
580 "boundingBox": { 592 "boundingBox": {
581 "height": 0.0, 593 "height": 0.0,
582 "width": 0.0, 594 "width": 0.0,
583 "x": 0.0, 595 "x": 0.0,
584 "y": 0.0 596 "y": 0.0
585 }, 597 },
586 "childIndices": [ ], 598 "childIndices": [ ],
587 "inlineTextNodes": [ { 599 "inlineTextNodes": [ {
588 "boundingBox": { 600 "boundingBox": {
589 "height": 17.0, 601 "height": 16.0,
590 "width": 0.0, 602 "width": 0.0,
591 "x": 8.0, 603 "x": 8.0,
592 "y": 338.4375 604 "y": 329.4375
593 }, 605 },
594 "numCharacters": 1, 606 "numCharacters": 1,
595 "startCharacterIndex": 0 607 "startCharacterIndex": 0
596 } ], 608 } ],
597 "layoutText": "\n", 609 "layoutText": "\n",
598 "localName": "br", 610 "localName": "br",
599 "nodeId": 24, 611 "nodeId": 25,
600 "nodeName": "BR", 612 "nodeName": "BR",
601 "nodeType": 1, 613 "nodeType": 1,
602 "nodeValue": "", 614 "nodeValue": "",
603 "styleIndex": 4 615 "styleIndex": 6
604 })raw_string", 616 })raw_string",
605 617
606 R"raw_string({ 618 R"raw_string({
607 "attributes": [ "style", "color: green" ], 619 "attributes": [ "class", "green" ],
608 "backendNodeId": 27, 620 "backendNodeId": 28,
609 "boundingBox": { 621 "boundingBox": {
610 "height": 19.0, 622 "height": 17.0,
611 "width": 784.0, 623 "width": 784.0,
612 "x": 8.0, 624 "x": 8.0,
613 "y": 356.0 625 "y": 345.0
614 }, 626 },
615 "childIndices": [ 25, 26, 28 ], 627 "childIndices": [ 26, 27, 29 ],
616 "localName": "div", 628 "localName": "div",
617 "nodeId": 25, 629 "nodeId": 26,
618 "nodeName": "DIV", 630 "nodeName": "DIV",
619 "nodeType": 1, 631 "nodeType": 1,
620 "nodeValue": "", 632 "nodeValue": "",
621 "styleIndex": 7 633 "styleIndex": 9
622 })raw_string", 634 }
635 )raw_string",
623 636
624 R"raw_string({ 637 R"raw_string({
625 "backendNodeId": 28, 638 "backendNodeId": 29,
626 "boundingBox": { 639 "boundingBox": {
627 "height": 18.0, 640 "height": 17.0,
628 "width": 41.0, 641 "width": 80.0,
629 "x": 8.0, 642 "x": 8.0,
630 "y": 356.0 643 "y": 345.0
631 }, 644 },
632 "inlineTextNodes": [ { 645 "inlineTextNodes": [ {
633 "boundingBox": { 646 "boundingBox": {
634 "height": 17.0, 647 "height": 16.0,
635 "width": 40.4375, 648 "width": 80.0,
636 "x": 8.0, 649 "x": 8.0,
637 "y": 356.4375 650 "y": 345.4375
638 }, 651 },
639 "numCharacters": 5, 652 "numCharacters": 5,
640 "startCharacterIndex": 0 653 "startCharacterIndex": 0
641 } ], 654 } ],
642 "layoutText": "Some ", 655 "layoutText": "Some ",
643 "localName": "", 656 "localName": "",
644 "nodeId": 26, 657 "nodeId": 27,
645 "nodeName": "#text", 658 "nodeName": "#text",
646 "nodeType": 3, 659 "nodeType": 3,
647 "nodeValue": "Some ", 660 "nodeValue": "Some ",
648 "styleIndex": 7 661 "styleIndex": 9
649 })raw_string", 662 })raw_string",
650 663
651 R"raw_string({ 664 R"raw_string({
652 "attributes": [ ], 665 "attributes": [ ],
653 "backendNodeId": 29, 666 "backendNodeId": 30,
654 "boundingBox": { 667 "boundingBox": {
655 "height": 18.0, 668 "height": 17.0,
656 "width": 37.0, 669 "width": 80.0,
657 "x": 48.0, 670 "x": 88.0,
658 "y": 356.0 671 "y": 345.0
659 }, 672 },
660 "childIndices": [ 27 ], 673 "childIndices": [ 28 ],
661 "localName": "em", 674 "localName": "em",
662 "nodeId": 27, 675 "nodeId": 28,
663 "nodeName": "EM", 676 "nodeName": "EM",
664 "nodeType": 1, 677 "nodeType": 1,
665 "nodeValue": "", 678 "nodeValue": "",
666 "styleIndex": 8 679 "styleIndex": 10
667 })raw_string", 680 })raw_string",
668 681
669 R"raw_string({ 682 R"raw_string({
670 "backendNodeId": 30, 683 "backendNodeId": 31,
671 "boundingBox": { 684 "boundingBox": {
672 "height": 18.0, 685 "height": 17.0,
673 "width": 37.0, 686 "width": 80.0,
674 "x": 48.0, 687 "x": 88.0,
675 "y": 356.0 688 "y": 345.0
676 }, 689 },
677 "inlineTextNodes": [ { 690 "inlineTextNodes": [ {
678 "boundingBox": { 691 "boundingBox": {
679 "height": 17.0, 692 "height": 16.0,
680 "width": 35.828125, 693 "width": 80.0,
681 "x": 48.4375, 694 "x": 88.0,
682 "y": 356.4375 695 "y": 345.4375
683 }, 696 },
684 "numCharacters": 5, 697 "numCharacters": 5,
685 "startCharacterIndex": 0 698 "startCharacterIndex": 0
686 } ], 699 } ],
687 "layoutText": "green", 700 "layoutText": "green",
688 "localName": "", 701 "localName": "",
689 "nodeId": 28, 702 "nodeId": 29,
690 "nodeName": "#text", 703 "nodeName": "#text",
691 "nodeType": 3, 704 "nodeType": 3,
692 "nodeValue": "green", 705 "nodeValue": "green",
693 "styleIndex": 8 706 "styleIndex": 10
694 })raw_string", 707 })raw_string",
695 708
696 R"raw_string({ 709 R"raw_string({
697 "backendNodeId": 31, 710 "backendNodeId": 32,
698 "boundingBox": { 711 "boundingBox": {
699 "height": 18.0, 712 "height": 17.0,
700 "width": 41.0, 713 "width": 128.0,
701 "x": 84.0, 714 "x": 168.0,
702 "y": 356.0 715 "y": 345.0
703 }, 716 },
704 "inlineTextNodes": [ { 717 "inlineTextNodes": [ {
705 "boundingBox": { 718 "boundingBox": {
706 "height": 17.0, 719 "height": 16.0,
707 "width": 39.984375, 720 "width": 128.0,
708 "x": 84.265625, 721 "x": 168.0,
709 "y": 356.4375 722 "y": 345.4375
710 }, 723 },
711 "numCharacters": 8, 724 "numCharacters": 8,
712 "startCharacterIndex": 0 725 "startCharacterIndex": 0
713 } ], 726 } ],
714 "layoutText": " text...", 727 "layoutText": " text...",
715 "localName": "", 728 "localName": "",
716 "nodeId": 29, 729 "nodeId": 30,
717 "nodeName": "#text", 730 "nodeName": "#text",
718 "nodeType": 3, 731 "nodeType": 3,
719 "nodeValue": " text...", 732 "nodeValue": " text...",
720 "styleIndex": 7 733 "styleIndex": 9
721 })raw_string"}; 734 })raw_string"};
722 735
723 EXPECT_EQ(expected_dom_nodes.size(), dom_nodes.size()); 736 EXPECT_EQ(expected_dom_nodes.size(), dom_nodes.size());
724 737
725 for (size_t i = 0; i < dom_nodes.size(); i++) { 738 for (size_t i = 0; i < dom_nodes.size(); i++) {
726 std::string result_json; 739 std::string result_json;
727 base::JSONWriter::WriteWithOptions( 740 base::JSONWriter::WriteWithOptions(
728 *dom_nodes[i], base::JSONWriter::OPTIONS_PRETTY_PRINT, &result_json); 741 *dom_nodes[i], base::JSONWriter::OPTIONS_PRETTY_PRINT, &result_json);
729 742
730 ASSERT_LT(i, expected_dom_nodes.size()); 743 ASSERT_LT(i, expected_dom_nodes.size());
731 EXPECT_EQ(NormaliseJSON(expected_dom_nodes[i]), result_json) << " Node # " 744 EXPECT_EQ(NormaliseJSON(expected_dom_nodes[i]), result_json) << " Node # "
732 << i; 745 << i;
733 } 746 }
734 747
735 const std::vector<std::string> expected_styles = { 748 const std::vector<std::string> expected_styles = {
736 R"raw_string({ 749 R"raw_string({
737 "color": "rgb(0, 0, 0)", 750 "color": "rgb(0, 0, 0)",
738 "display": "block", 751 "display": "block",
752 "font-family": "ahem",
739 "font-style": "normal", 753 "font-style": "normal",
740 "margin-bottom": "0px", 754 "margin-bottom": "0px",
741 "margin-left": "0px", 755 "margin-left": "0px",
742 "margin-right": "0px", 756 "margin-right": "0px",
743 "margin-top": "0px" 757 "margin-top": "0px"
744 })raw_string", 758 })raw_string",
745 759
746 R"raw_string({ 760 R"raw_string({
747 "color": "rgb(0, 0, 0)", 761 "color": "rgb(0, 0, 0)",
748 "display": "block", 762 "display": "block",
763 "font-family": "ahem",
749 "font-style": "normal", 764 "font-style": "normal",
750 "margin-bottom": "8px", 765 "margin-bottom": "8px",
751 "margin-left": "8px", 766 "margin-left": "8px",
752 "margin-right": "8px", 767 "margin-right": "8px",
753 "margin-top": "8px" 768 "margin-top": "8px"
754 })raw_string", 769 })raw_string",
755 770
756 R"raw_string({ 771 R"raw_string({
757 "color": "rgb(255, 0, 0)", 772 "color": "rgb(255, 0, 0)",
758 "display": "block", 773 "display": "block",
774 "font-family": "ahem",
759 "font-style": "normal", 775 "font-style": "normal",
760 "margin-bottom": "21.44px", 776 "margin-bottom": "21.44px",
761 "margin-left": "0px", 777 "margin-left": "0px",
762 "margin-right": "0px", 778 "margin-right": "0px",
763 "margin-top": "21.44px" 779 "margin-top": "21.44px"
764 })raw_string", 780 })raw_string",
765 781
766 R"raw_string({ 782 R"raw_string({
767 "color": "rgb(0, 0, 0)", 783 "color": "rgb(0, 0, 0)",
768 "display": "block", 784 "display": "block",
785 "font-family": "\"Times New Roman\"",
786 "font-style": "normal",
787 "margin-bottom": "0px",
788 "margin-left": "0px",
789 "margin-right": "0px",
790 "margin-top": "0px"
791 })raw_string",
792
793 R"raw_string({
794 "color": "rgb(0, 0, 0)",
795 "display": "block",
796 "font-family": "\"Times New Roman\"",
797 "font-style": "normal",
798 "margin-bottom": "8px",
799 "margin-left": "8px",
800 "margin-right": "8px",
801 "margin-top": "8px"
802 })raw_string",
803
804 R"raw_string({
805 "color": "rgb(0, 0, 0)",
806 "display": "block",
807 "font-family": "\"Times New Roman\"",
769 "font-style": "normal", 808 "font-style": "normal",
770 "margin-bottom": "21.44px", 809 "margin-bottom": "21.44px",
771 "margin-left": "0px", 810 "margin-left": "0px",
772 "margin-right": "0px", 811 "margin-right": "0px",
773 "margin-top": "21.44px" 812 "margin-top": "21.44px"
774 })raw_string", 813 })raw_string",
775 814
776 R"raw_string({ 815 R"raw_string({
777 "color": "rgb(0, 0, 0)", 816 "color": "rgb(0, 0, 0)",
778 "display": "inline", 817 "display": "inline",
818 "font-family": "ahem",
779 "font-style": "normal", 819 "font-style": "normal",
780 "margin-bottom": "0px", 820 "margin-bottom": "0px",
781 "margin-left": "0px", 821 "margin-left": "0px",
782 "margin-right": "0px", 822 "margin-right": "0px",
783 "margin-top": "0px" 823 "margin-top": "0px"
784 })raw_string", 824 })raw_string",
785 825
786 R"raw_string({ 826 R"raw_string({
787 "color": "rgb(0, 0, 238)", 827 "color": "rgb(0, 0, 238)",
788 "display": "inline", 828 "display": "inline",
829 "font-family": "ahem",
789 "font-style": "normal", 830 "font-style": "normal",
790 "margin-bottom": "0px", 831 "margin-bottom": "0px",
791 "margin-left": "0px", 832 "margin-left": "0px",
792 "margin-right": "0px", 833 "margin-right": "0px",
793 "margin-top": "0px" 834 "margin-top": "0px"
794 })raw_string", 835 })raw_string",
795 836
796 R"raw_string({ 837 R"raw_string({
797 "color": "rgb(0, 0, 0)", 838 "color": "rgb(0, 0, 0)",
798 "display": "block", 839 "display": "block",
840 "font-family": "ahem",
799 "font-style": "normal", 841 "font-style": "normal",
800 "margin-bottom": "16px", 842 "margin-bottom": "16px",
801 "margin-left": "0px", 843 "margin-left": "0px",
802 "margin-right": "0px", 844 "margin-right": "0px",
803 "margin-top": "16px" 845 "margin-top": "16px"
804 })raw_string", 846 })raw_string",
805 847
806 R"raw_string({ 848 R"raw_string({
807 "color": "rgb(0, 128, 0)", 849 "color": "rgb(0, 128, 0)",
808 "display": "block", 850 "display": "block",
851 "font-family": "ahem",
809 "font-style": "normal", 852 "font-style": "normal",
810 "margin-bottom": "0px", 853 "margin-bottom": "0px",
811 "margin-left": "0px", 854 "margin-left": "0px",
812 "margin-right": "0px", 855 "margin-right": "0px",
813 "margin-top": "0px" 856 "margin-top": "0px"
814 })raw_string", 857 })raw_string",
815 858
816 R"raw_string({ 859 R"raw_string({
817 "color": "rgb(0, 128, 0)", 860 "color": "rgb(0, 128, 0)",
818 "display": "inline", 861 "display": "inline",
862 "font-family": "ahem",
819 "font-style": "italic", 863 "font-style": "italic",
820 "margin-bottom": "0px", 864 "margin-bottom": "0px",
821 "margin-left": "0px", 865 "margin-left": "0px",
822 "margin-right": "0px", 866 "margin-right": "0px",
823 "margin-top": "0px" 867 "margin-top": "0px"
824 })raw_string"}; 868 }
869 )raw_string"};
825 870
826 for (size_t i = 0; i < computed_styles.size(); i++) { 871 for (size_t i = 0; i < computed_styles.size(); i++) {
827 std::string result_json; 872 std::string result_json;
828 base::JSONWriter::WriteWithOptions(*computed_styles[i], 873 base::JSONWriter::WriteWithOptions(*computed_styles[i],
829 base::JSONWriter::OPTIONS_PRETTY_PRINT, 874 base::JSONWriter::OPTIONS_PRETTY_PRINT,
830 &result_json); 875 &result_json);
831 876
832 ASSERT_LT(i, expected_styles.size()); 877 ASSERT_LT(i, expected_styles.size());
833 EXPECT_EQ(NormaliseJSON(expected_styles[i]), result_json) << " Style # " 878 EXPECT_EQ(NormaliseJSON(expected_styles[i]), result_json) << " Style # "
834 << i; 879 << i;
835 } 880 }
836 881
837 FinishAsynchronousTest(); 882 FinishAsynchronousTest();
838 } 883 }
839 884
840 std::unique_ptr<DomTreeExtractor> extractor_; 885 std::unique_ptr<DomTreeExtractor> extractor_;
841 }; 886 };
842 887
843 HEADLESS_ASYNC_DEVTOOLED_TEST_F(DomTreeExtractorBrowserTest); 888 HEADLESS_ASYNC_DEVTOOLED_TEST_F(DomTreeExtractorBrowserTest);
844 889
845 } // namespace headless 890 } // namespace headless
OLDNEW
« no previous file with comments | « no previous file | headless/test/data/Ahem.ttf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698