| OLD | NEW |
| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 "x": 0.0, | 182 "x": 0.0, |
| 183 "y": 0.0 | 183 "y": 0.0 |
| 184 }, | 184 }, |
| 185 "childIndices": [ 2, 6 ], | 185 "childIndices": [ 2, 6 ], |
| 186 "frameId": "?", | 186 "frameId": "?", |
| 187 "localName": "html", | 187 "localName": "html", |
| 188 "nodeId": 2, | 188 "nodeId": 2, |
| 189 "nodeName": "HTML", | 189 "nodeName": "HTML", |
| 190 "nodeType": 1, | 190 "nodeType": 1, |
| 191 "nodeValue": "", | 191 "nodeValue": "", |
| 192 "parentId": 1, |
| 192 "styleIndex": 0 | 193 "styleIndex": 0 |
| 193 })raw_string", | 194 })raw_string", |
| 194 | 195 |
| 195 R"raw_string({ | 196 R"raw_string({ |
| 196 "attributes": [ ], | 197 "attributes": [ ], |
| 197 "backendNodeId": 5, | 198 "backendNodeId": 5, |
| 198 "childIndices": [ 3, 5 ], | 199 "childIndices": [ 3, 5 ], |
| 199 "localName": "head", | 200 "localName": "head", |
| 200 "nodeId": 3, | 201 "nodeId": 3, |
| 201 "nodeName": "HEAD", | 202 "nodeName": "HEAD", |
| 202 "nodeType": 1, | 203 "nodeType": 1, |
| 203 "nodeValue": "" | 204 "nodeValue": "", |
| 205 "parentId": 2 |
| 204 })raw_string", | 206 })raw_string", |
| 205 | 207 |
| 206 R"raw_string({ | 208 R"raw_string({ |
| 207 "attributes": [ ], | 209 "attributes": [ ], |
| 208 "backendNodeId": 6, | 210 "backendNodeId": 6, |
| 209 "childIndices": [ 4 ], | 211 "childIndices": [ 4 ], |
| 210 "localName": "title", | 212 "localName": "title", |
| 211 "nodeId": 4, | 213 "nodeId": 4, |
| 212 "nodeName": "TITLE", | 214 "nodeName": "TITLE", |
| 213 "nodeType": 1, | 215 "nodeType": 1, |
| 214 "nodeValue": "" | 216 "nodeValue": "", |
| 217 "parentId": 3 |
| 215 })raw_string", | 218 })raw_string", |
| 216 | 219 |
| 217 R"raw_string({ | 220 R"raw_string({ |
| 218 "backendNodeId": 7, | 221 "backendNodeId": 7, |
| 219 "localName": "", | 222 "localName": "", |
| 220 "nodeId": 5, | 223 "nodeId": 5, |
| 221 "nodeName": "#text", | 224 "nodeName": "#text", |
| 222 "nodeType": 3, | 225 "nodeType": 3, |
| 223 "nodeValue": "Hello world!" | 226 "nodeValue": "Hello world!", |
| 227 "parentId": 4 |
| 224 })raw_string", | 228 })raw_string", |
| 225 | 229 |
| 226 R"raw_string({ | 230 R"raw_string({ |
| 227 "attributes": [ "href", "dom_tree_test.css", "rel", "stylesheet", | 231 "attributes": [ "href", "dom_tree_test.css", "rel", "stylesheet", |
| 228 "type", "text/css" ], | 232 "type", "text/css" ], |
| 229 "backendNodeId": 8, | 233 "backendNodeId": 8, |
| 230 "childIndices": [ ], | 234 "childIndices": [ ], |
| 231 "localName": "link", | 235 "localName": "link", |
| 232 "nodeId": 6, | 236 "nodeId": 6, |
| 233 "nodeName": "LINK", | 237 "nodeName": "LINK", |
| 234 "nodeType": 1, | 238 "nodeType": 1, |
| 235 "nodeValue": "" | 239 "nodeValue": "", |
| 240 "parentId": 3 |
| 236 })raw_string", | 241 })raw_string", |
| 237 | 242 |
| 238 R"raw_string({ | 243 R"raw_string({ |
| 239 "attributes": [ ], | 244 "attributes": [ ], |
| 240 "backendNodeId": 9, | 245 "backendNodeId": 9, |
| 241 "boundingBox": { | 246 "boundingBox": { |
| 242 "height": 584.0, | 247 "height": 584.0, |
| 243 "width": 784.0, | 248 "width": 784.0, |
| 244 "x": 8.0, | 249 "x": 8.0, |
| 245 "y": 8.0 | 250 "y": 8.0 |
| 246 }, | 251 }, |
| 247 "childIndices": [ 7 ], | 252 "childIndices": [ 7 ], |
| 248 "localName": "body", | 253 "localName": "body", |
| 249 "nodeId": 7, | 254 "nodeId": 7, |
| 250 "nodeName": "BODY", | 255 "nodeName": "BODY", |
| 251 "nodeType": 1, | 256 "nodeType": 1, |
| 252 "nodeValue": "", | 257 "nodeValue": "", |
| 258 "parentId": 2, |
| 253 "styleIndex": 1 | 259 "styleIndex": 1 |
| 254 })raw_string", | 260 })raw_string", |
| 255 | 261 |
| 256 R"raw_string({ | 262 R"raw_string({ |
| 257 "attributes": [ "id", "id1" ], | 263 "attributes": [ "id", "id1" ], |
| 258 "backendNodeId": 10, | 264 "backendNodeId": 10, |
| 259 "boundingBox": { | 265 "boundingBox": { |
| 260 "height": 354.0, | 266 "height": 354.0, |
| 261 "width": 784.0, | 267 "width": 784.0, |
| 262 "x": 8.0, | 268 "x": 8.0, |
| 263 "y": 8.0 | 269 "y": 8.0 |
| 264 }, | 270 }, |
| 265 "childIndices": [ 8, 10, 17 ], | 271 "childIndices": [ 8, 10, 17 ], |
| 266 "localName": "div", | 272 "localName": "div", |
| 267 "nodeId": 8, | 273 "nodeId": 8, |
| 268 "nodeName": "DIV", | 274 "nodeName": "DIV", |
| 269 "nodeType": 1, | 275 "nodeType": 1, |
| 270 "nodeValue": "", | 276 "nodeValue": "", |
| 277 "parentId": 7, |
| 271 "styleIndex": 0 | 278 "styleIndex": 0 |
| 272 })raw_string", | 279 })raw_string", |
| 273 | 280 |
| 274 R"raw_string({ | 281 R"raw_string({ |
| 275 "attributes": [ "class", "red" ], | 282 "attributes": [ "class", "red" ], |
| 276 "backendNodeId": 11, | 283 "backendNodeId": 11, |
| 277 "boundingBox": { | 284 "boundingBox": { |
| 278 "height": 32.0, | 285 "height": 32.0, |
| 279 "width": 784.0, | 286 "width": 784.0, |
| 280 "x": 8.0, | 287 "x": 8.0, |
| 281 "y": 8.0 | 288 "y": 8.0 |
| 282 }, | 289 }, |
| 283 "childIndices": [ 9 ], | 290 "childIndices": [ 9 ], |
| 284 "localName": "h1", | 291 "localName": "h1", |
| 285 "nodeId": 9, | 292 "nodeId": 9, |
| 286 "nodeName": "H1", | 293 "nodeName": "H1", |
| 287 "nodeType": 1, | 294 "nodeType": 1, |
| 288 "nodeValue": "", | 295 "nodeValue": "", |
| 296 "parentId": 8, |
| 289 "styleIndex": 2 | 297 "styleIndex": 2 |
| 290 })raw_string", | 298 })raw_string", |
| 291 | 299 |
| 292 R"raw_string({ | 300 R"raw_string({ |
| 293 "backendNodeId": 12, | 301 "backendNodeId": 12, |
| 294 "boundingBox": { | 302 "boundingBox": { |
| 295 "height": 32.0, | 303 "height": 32.0, |
| 296 "width": 320.0, | 304 "width": 320.0, |
| 297 "x": 8.0, | 305 "x": 8.0, |
| 298 "y": 8.0 | 306 "y": 8.0 |
| 299 }, | 307 }, |
| 300 "inlineTextNodes": [ { | 308 "inlineTextNodes": [ { |
| 301 "boundingBox": { | 309 "boundingBox": { |
| 302 "height": 32.0, | 310 "height": 32.0, |
| 303 "width": 320.0, | 311 "width": 320.0, |
| 304 "x": 8.0, | 312 "x": 8.0, |
| 305 "y": 8.0 | 313 "y": 8.0 |
| 306 }, | 314 }, |
| 307 "numCharacters": 10, | 315 "numCharacters": 10, |
| 308 "startCharacterIndex": 0 | 316 "startCharacterIndex": 0 |
| 309 } ], | 317 } ], |
| 310 "layoutText": "Some text.", | 318 "layoutText": "Some text.", |
| 311 "localName": "", | 319 "localName": "", |
| 312 "nodeId": 10, | 320 "nodeId": 10, |
| 313 "nodeName": "#text", | 321 "nodeName": "#text", |
| 314 "nodeType": 3, | 322 "nodeType": 3, |
| 315 "nodeValue": "Some text.", | 323 "nodeValue": "Some text.", |
| 324 "parentId": 9, |
| 316 "styleIndex": 2 | 325 "styleIndex": 2 |
| 317 })raw_string", | 326 })raw_string", |
| 318 | 327 |
| 319 R"raw_string({ | 328 R"raw_string({ |
| 320 "attributes": [ "src", "/iframe.html", "width", "400", "height", | 329 "attributes": [ "src", "/iframe.html", "width", "400", "height", |
| 321 "200" ], | 330 "200" ], |
| 322 "backendNodeId": 13, | 331 "backendNodeId": 13, |
| 323 "boundingBox": { | 332 "boundingBox": { |
| 324 "height": 205.0, | 333 "height": 205.0, |
| 325 "width": 404.0, | 334 "width": 404.0, |
| 326 "x": 8.0, | 335 "x": 8.0, |
| 327 "y": 61.0 | 336 "y": 61.0 |
| 328 }, | 337 }, |
| 329 "childIndices": [ ], | 338 "childIndices": [ ], |
| 330 "contentDocumentIndex": 11, | 339 "contentDocumentIndex": 11, |
| 331 "frameId": "?", | 340 "frameId": "?", |
| 332 "localName": "iframe", | 341 "localName": "iframe", |
| 333 "nodeId": 11, | 342 "nodeId": 11, |
| 334 "nodeName": "IFRAME", | 343 "nodeName": "IFRAME", |
| 335 "nodeType": 1, | 344 "nodeType": 1, |
| 336 "nodeValue": "", | 345 "nodeValue": "", |
| 346 "parentId": 8, |
| 337 "styleIndex": 6 | 347 "styleIndex": 6 |
| 338 })raw_string", | 348 })raw_string", |
| 339 | 349 |
| 340 R"raw_string({ | 350 R"raw_string({ |
| 341 "backendNodeId": 14, | 351 "backendNodeId": 14, |
| 342 "baseURL": "http://127.0.0.1/iframe.html", | 352 "baseURL": "http://127.0.0.1/iframe.html", |
| 343 "childIndices": [ 12 ], | 353 "childIndices": [ 12 ], |
| 344 "documentURL": "http://127.0.0.1/iframe.html", | 354 "documentURL": "http://127.0.0.1/iframe.html", |
| 345 "localName": "", | 355 "localName": "", |
| 346 "nodeId": 12, | 356 "nodeId": 12, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 359 "x": 10.0, | 369 "x": 10.0, |
| 360 "y": 63.0 | 370 "y": 63.0 |
| 361 }, | 371 }, |
| 362 "childIndices": [ 13, 14 ], | 372 "childIndices": [ 13, 14 ], |
| 363 "frameId": "?", | 373 "frameId": "?", |
| 364 "localName": "html", | 374 "localName": "html", |
| 365 "nodeId": 13, | 375 "nodeId": 13, |
| 366 "nodeName": "HTML", | 376 "nodeName": "HTML", |
| 367 "nodeType": 1, | 377 "nodeType": 1, |
| 368 "nodeValue": "", | 378 "nodeValue": "", |
| 379 "parentId": 12, |
| 369 "styleIndex": 3 | 380 "styleIndex": 3 |
| 370 })raw_string", | 381 })raw_string", |
| 371 | 382 |
| 372 R"raw_string({ | 383 R"raw_string({ |
| 373 "attributes": [ ], | 384 "attributes": [ ], |
| 374 "backendNodeId": 16, | 385 "backendNodeId": 16, |
| 375 "childIndices": [ ], | 386 "childIndices": [ ], |
| 376 "localName": "head", | 387 "localName": "head", |
| 377 "nodeId": 14, | 388 "nodeId": 14, |
| 378 "nodeName": "HEAD", | 389 "nodeName": "HEAD", |
| 379 "nodeType": 1, | 390 "nodeType": 1, |
| 380 "nodeValue": "" | 391 "nodeValue": "", |
| 392 "parentId": 13 |
| 381 })raw_string", | 393 })raw_string", |
| 382 | 394 |
| 383 R"raw_string({ | 395 R"raw_string({ |
| 384 "attributes": [ ], | 396 "attributes": [ ], |
| 385 "backendNodeId": 17, | 397 "backendNodeId": 17, |
| 386 "boundingBox": { | 398 "boundingBox": { |
| 387 "height": 171.0, | 399 "height": 171.0, |
| 388 "width": 384.0, | 400 "width": 384.0, |
| 389 "x": 18.0, | 401 "x": 18.0, |
| 390 "y": 71.0 | 402 "y": 71.0 |
| 391 }, | 403 }, |
| 392 "childIndices": [ 15 ], | 404 "childIndices": [ 15 ], |
| 393 "localName": "body", | 405 "localName": "body", |
| 394 "nodeId": 15, | 406 "nodeId": 15, |
| 395 "nodeName": "BODY", | 407 "nodeName": "BODY", |
| 396 "nodeType": 1, | 408 "nodeType": 1, |
| 397 "nodeValue": "", | 409 "nodeValue": "", |
| 410 "parentId": 13, |
| 398 "styleIndex": 4 | 411 "styleIndex": 4 |
| 399 })raw_string", | 412 })raw_string", |
| 400 | 413 |
| 401 R"raw_string({ | 414 R"raw_string({ |
| 402 "attributes": [ ], | 415 "attributes": [ ], |
| 403 "backendNodeId": 18, | 416 "backendNodeId": 18, |
| 404 "boundingBox": { | 417 "boundingBox": { |
| 405 "height": 37.0, | 418 "height": 37.0, |
| 406 "width": 384.0, | 419 "width": 384.0, |
| 407 "x": 18.0, | 420 "x": 18.0, |
| 408 "y": 71.0 | 421 "y": 71.0 |
| 409 }, | 422 }, |
| 410 "childIndices": [ 16 ], | 423 "childIndices": [ 16 ], |
| 411 "localName": "h1", | 424 "localName": "h1", |
| 412 "nodeId": 16, | 425 "nodeId": 16, |
| 413 "nodeName": "H1", | 426 "nodeName": "H1", |
| 414 "nodeType": 1, | 427 "nodeType": 1, |
| 415 "nodeValue": "", | 428 "nodeValue": "", |
| 429 "parentId": 15, |
| 416 "styleIndex": 5 | 430 "styleIndex": 5 |
| 417 })raw_string", | 431 })raw_string", |
| 418 | 432 |
| 419 R"raw_string({ | 433 R"raw_string({ |
| 420 "backendNodeId": 19, | 434 "backendNodeId": 19, |
| 421 "boundingBox": { | 435 "boundingBox": { |
| 422 "height": 36.0, | 436 "height": 36.0, |
| 423 "width": 308.0, | 437 "width": 308.0, |
| 424 "x": 8.0, | 438 "x": 8.0, |
| 425 "y": 8.0 | 439 "y": 8.0 |
| 426 }, | 440 }, |
| 427 "inlineTextNodes": [ { | 441 "inlineTextNodes": [ { |
| 428 "boundingBox": { | 442 "boundingBox": { |
| 429 "height": 36.0, | 443 "height": 36.0, |
| 430 "width": 307.734375, | 444 "width": 307.734375, |
| 431 "x": 8.0, | 445 "x": 8.0, |
| 432 "y": 8.0 | 446 "y": 8.0 |
| 433 }, | 447 }, |
| 434 "numCharacters": 22, | 448 "numCharacters": 22, |
| 435 "startCharacterIndex": 0 | 449 "startCharacterIndex": 0 |
| 436 } ], | 450 } ], |
| 437 "layoutText": "Hello from the iframe!", | 451 "layoutText": "Hello from the iframe!", |
| 438 "localName": "", | 452 "localName": "", |
| 439 "nodeId": 17, | 453 "nodeId": 17, |
| 440 "nodeName": "#text", | 454 "nodeName": "#text", |
| 441 "nodeType": 3, | 455 "nodeType": 3, |
| 442 "nodeValue": "Hello from the iframe!", | 456 "nodeValue": "Hello from the iframe!", |
| 457 "parentId": 16, |
| 443 "styleIndex": 5 | 458 "styleIndex": 5 |
| 444 })raw_string", | 459 })raw_string", |
| 445 | 460 |
| 446 R"raw_string({ | 461 R"raw_string({ |
| 447 "attributes": [ "id", "id2" ], | 462 "attributes": [ "id", "id2" ], |
| 448 "backendNodeId": 20, | 463 "backendNodeId": 20, |
| 449 "boundingBox": { | 464 "boundingBox": { |
| 450 "height": 97.0, | 465 "height": 97.0, |
| 451 "width": 784.0, | 466 "width": 784.0, |
| 452 "x": 8.0, | 467 "x": 8.0, |
| 453 "y": 265.0 | 468 "y": 265.0 |
| 454 }, | 469 }, |
| 455 "childIndices": [ 18 ], | 470 "childIndices": [ 18 ], |
| 456 "localName": "div", | 471 "localName": "div", |
| 457 "nodeId": 18, | 472 "nodeId": 18, |
| 458 "nodeName": "DIV", | 473 "nodeName": "DIV", |
| 459 "nodeType": 1, | 474 "nodeType": 1, |
| 460 "nodeValue": "", | 475 "nodeValue": "", |
| 476 "parentId": 8, |
| 461 "styleIndex": 0 | 477 "styleIndex": 0 |
| 462 })raw_string", | 478 })raw_string", |
| 463 | 479 |
| 464 R"raw_string({ | 480 R"raw_string({ |
| 465 "attributes": [ "id", "id3" ], | 481 "attributes": [ "id", "id3" ], |
| 466 "backendNodeId": 21, | 482 "backendNodeId": 21, |
| 467 "boundingBox": { | 483 "boundingBox": { |
| 468 "height": 97.0, | 484 "height": 97.0, |
| 469 "width": 784.0, | 485 "width": 784.0, |
| 470 "x": 8.0, | 486 "x": 8.0, |
| 471 "y": 265.0 | 487 "y": 265.0 |
| 472 }, | 488 }, |
| 473 "childIndices": [ 19 ], | 489 "childIndices": [ 19 ], |
| 474 "localName": "div", | 490 "localName": "div", |
| 475 "nodeId": 19, | 491 "nodeId": 19, |
| 476 "nodeName": "DIV", | 492 "nodeName": "DIV", |
| 477 "nodeType": 1, | 493 "nodeType": 1, |
| 478 "nodeValue": "", | 494 "nodeValue": "", |
| 495 "parentId": 18, |
| 479 "styleIndex": 0 | 496 "styleIndex": 0 |
| 480 })raw_string", | 497 })raw_string", |
| 481 | 498 |
| 482 R"raw_string({ | 499 R"raw_string({ |
| 483 "attributes": [ "id", "id4" ], | 500 "attributes": [ "id", "id4" ], |
| 484 "backendNodeId": 22, | 501 "backendNodeId": 22, |
| 485 "boundingBox": { | 502 "boundingBox": { |
| 486 "height": 97.0, | 503 "height": 97.0, |
| 487 "width": 784.0, | 504 "width": 784.0, |
| 488 "x": 8.0, | 505 "x": 8.0, |
| 489 "y": 265.0 | 506 "y": 265.0 |
| 490 }, | 507 }, |
| 491 "childIndices": [ 20, 22, 24, 25 ], | 508 "childIndices": [ 20, 22, 24, 25 ], |
| 492 "localName": "div", | 509 "localName": "div", |
| 493 "nodeId": 20, | 510 "nodeId": 20, |
| 494 "nodeName": "DIV", | 511 "nodeName": "DIV", |
| 495 "nodeType": 1, | 512 "nodeType": 1, |
| 496 "nodeValue": "", | 513 "nodeValue": "", |
| 514 "parentId": 19, |
| 497 "styleIndex": 0 | 515 "styleIndex": 0 |
| 498 })raw_string", | 516 })raw_string", |
| 499 | 517 |
| 500 R"raw_string({ | 518 R"raw_string({ |
| 501 "attributes": [ "href", "https://www.google.com" ], | 519 "attributes": [ "href", "https://www.google.com" ], |
| 502 "backendNodeId": 23, | 520 "backendNodeId": 23, |
| 503 "boundingBox": { | 521 "boundingBox": { |
| 504 "height": 17.0, | 522 "height": 17.0, |
| 505 "width": 112.0, | 523 "width": 112.0, |
| 506 "x": 8.0, | 524 "x": 8.0, |
| 507 "y": 265.0 | 525 "y": 265.0 |
| 508 }, | 526 }, |
| 509 "childIndices": [ 21 ], | 527 "childIndices": [ 21 ], |
| 510 "localName": "a", | 528 "localName": "a", |
| 511 "nodeId": 21, | 529 "nodeId": 21, |
| 512 "nodeName": "A", | 530 "nodeName": "A", |
| 513 "nodeType": 1, | 531 "nodeType": 1, |
| 514 "nodeValue": "", | 532 "nodeValue": "", |
| 533 "parentId": 20, |
| 515 "styleIndex": 7 | 534 "styleIndex": 7 |
| 516 })raw_string", | 535 })raw_string", |
| 517 | 536 |
| 518 R"raw_string({ | 537 R"raw_string({ |
| 519 "backendNodeId": 24, | 538 "backendNodeId": 24, |
| 520 "boundingBox": { | 539 "boundingBox": { |
| 521 "height": 17.0, | 540 "height": 17.0, |
| 522 "width": 112.0, | 541 "width": 112.0, |
| 523 "x": 8.0, | 542 "x": 8.0, |
| 524 "y": 265.0 | 543 "y": 265.0 |
| 525 }, | 544 }, |
| 526 "inlineTextNodes": [ { | 545 "inlineTextNodes": [ { |
| 527 "boundingBox": { | 546 "boundingBox": { |
| 528 "height": 16.0, | 547 "height": 16.0, |
| 529 "width": 112.0, | 548 "width": 112.0, |
| 530 "x": 8.0, | 549 "x": 8.0, |
| 531 "y": 265.4375 | 550 "y": 265.4375 |
| 532 }, | 551 }, |
| 533 "numCharacters": 7, | 552 "numCharacters": 7, |
| 534 "startCharacterIndex": 0 | 553 "startCharacterIndex": 0 |
| 535 } ], | 554 } ], |
| 536 "layoutText": "Google!", | 555 "layoutText": "Google!", |
| 537 "localName": "", | 556 "localName": "", |
| 538 "nodeId": 22, | 557 "nodeId": 22, |
| 539 "nodeName": "#text", | 558 "nodeName": "#text", |
| 540 "nodeType": 3, | 559 "nodeType": 3, |
| 541 "nodeValue": "Google!", | 560 "nodeValue": "Google!", |
| 561 "parentId": 21, |
| 542 "styleIndex": 7 | 562 "styleIndex": 7 |
| 543 })raw_string", | 563 })raw_string", |
| 544 | 564 |
| 545 R"raw_string({ | 565 R"raw_string({ |
| 546 "attributes": [ ], | 566 "attributes": [ ], |
| 547 "backendNodeId": 25, | 567 "backendNodeId": 25, |
| 548 "boundingBox": { | 568 "boundingBox": { |
| 549 "height": 17.0, | 569 "height": 17.0, |
| 550 "width": 784.0, | 570 "width": 784.0, |
| 551 "x": 8.0, | 571 "x": 8.0, |
| 552 "y": 297.0 | 572 "y": 297.0 |
| 553 }, | 573 }, |
| 554 "childIndices": [ 23 ], | 574 "childIndices": [ 23 ], |
| 555 "localName": "p", | 575 "localName": "p", |
| 556 "nodeId": 23, | 576 "nodeId": 23, |
| 557 "nodeName": "P", | 577 "nodeName": "P", |
| 558 "nodeType": 1, | 578 "nodeType": 1, |
| 559 "nodeValue": "", | 579 "nodeValue": "", |
| 580 "parentId": 20, |
| 560 "styleIndex": 8 | 581 "styleIndex": 8 |
| 561 })raw_string", | 582 })raw_string", |
| 562 | 583 |
| 563 R"raw_string({ | 584 R"raw_string({ |
| 564 "backendNodeId": 26, | 585 "backendNodeId": 26, |
| 565 "boundingBox": { | 586 "boundingBox": { |
| 566 "height": 17.0, | 587 "height": 17.0, |
| 567 "width": 192.0, | 588 "width": 192.0, |
| 568 "x": 8.0, | 589 "x": 8.0, |
| 569 "y": 297.0 | 590 "y": 297.0 |
| 570 }, | 591 }, |
| 571 "inlineTextNodes": [ { | 592 "inlineTextNodes": [ { |
| 572 "boundingBox": { | 593 "boundingBox": { |
| 573 "height": 16.0, | 594 "height": 16.0, |
| 574 "width": 192.0, | 595 "width": 192.0, |
| 575 "x": 8.0, | 596 "x": 8.0, |
| 576 "y": 297.4375 | 597 "y": 297.4375 |
| 577 }, | 598 }, |
| 578 "numCharacters": 12, | 599 "numCharacters": 12, |
| 579 "startCharacterIndex": 0 | 600 "startCharacterIndex": 0 |
| 580 } ], | 601 } ], |
| 581 "layoutText": "A paragraph!", | 602 "layoutText": "A paragraph!", |
| 582 "localName": "", | 603 "localName": "", |
| 583 "nodeId": 24, | 604 "nodeId": 24, |
| 584 "nodeName": "#text", | 605 "nodeName": "#text", |
| 585 "nodeType": 3, | 606 "nodeType": 3, |
| 586 "nodeValue": "A paragraph!", | 607 "nodeValue": "A paragraph!", |
| 608 "parentId": 23, |
| 587 "styleIndex": 8 | 609 "styleIndex": 8 |
| 588 })raw_string", | 610 })raw_string", |
| 589 | 611 |
| 590 R"raw_string({ | 612 R"raw_string({ |
| 591 "attributes": [ ], | 613 "attributes": [ ], |
| 592 "backendNodeId": 27, | 614 "backendNodeId": 27, |
| 593 "boundingBox": { | 615 "boundingBox": { |
| 594 "height": 0.0, | 616 "height": 0.0, |
| 595 "width": 0.0, | 617 "width": 0.0, |
| 596 "x": 0.0, | 618 "x": 0.0, |
| 597 "y": 0.0 | 619 "y": 0.0 |
| 598 }, | 620 }, |
| 599 "childIndices": [ ], | 621 "childIndices": [ ], |
| 600 "inlineTextNodes": [ { | 622 "inlineTextNodes": [ { |
| 601 "boundingBox": { | 623 "boundingBox": { |
| 602 "height": 16.0, | 624 "height": 16.0, |
| 603 "width": 0.0, | 625 "width": 0.0, |
| 604 "x": 8.0, | 626 "x": 8.0, |
| 605 "y": 329.4375 | 627 "y": 329.4375 |
| 606 }, | 628 }, |
| 607 "numCharacters": 1, | 629 "numCharacters": 1, |
| 608 "startCharacterIndex": 0 | 630 "startCharacterIndex": 0 |
| 609 } ], | 631 } ], |
| 610 "layoutText": "\n", | 632 "layoutText": "\n", |
| 611 "localName": "br", | 633 "localName": "br", |
| 612 "nodeId": 25, | 634 "nodeId": 25, |
| 613 "nodeName": "BR", | 635 "nodeName": "BR", |
| 614 "nodeType": 1, | 636 "nodeType": 1, |
| 615 "nodeValue": "", | 637 "nodeValue": "", |
| 638 "parentId": 20, |
| 616 "styleIndex": 6 | 639 "styleIndex": 6 |
| 617 })raw_string", | 640 })raw_string", |
| 618 | 641 |
| 619 R"raw_string({ | 642 R"raw_string({ |
| 620 "attributes": [ "class", "green" ], | 643 "attributes": [ "class", "green" ], |
| 621 "backendNodeId": 28, | 644 "backendNodeId": 28, |
| 622 "boundingBox": { | 645 "boundingBox": { |
| 623 "height": 17.0, | 646 "height": 17.0, |
| 624 "width": 784.0, | 647 "width": 784.0, |
| 625 "x": 8.0, | 648 "x": 8.0, |
| 626 "y": 345.0 | 649 "y": 345.0 |
| 627 }, | 650 }, |
| 628 "childIndices": [ 26, 27, 29 ], | 651 "childIndices": [ 26, 27, 29 ], |
| 629 "localName": "div", | 652 "localName": "div", |
| 630 "nodeId": 26, | 653 "nodeId": 26, |
| 631 "nodeName": "DIV", | 654 "nodeName": "DIV", |
| 632 "nodeType": 1, | 655 "nodeType": 1, |
| 633 "nodeValue": "", | 656 "nodeValue": "", |
| 657 "parentId": 20, |
| 634 "styleIndex": 9 | 658 "styleIndex": 9 |
| 635 } | 659 })raw_string", |
| 636 )raw_string", | |
| 637 | 660 |
| 638 R"raw_string({ | 661 R"raw_string({ |
| 639 "backendNodeId": 29, | 662 "backendNodeId": 29, |
| 640 "boundingBox": { | 663 "boundingBox": { |
| 641 "height": 17.0, | 664 "height": 17.0, |
| 642 "width": 80.0, | 665 "width": 80.0, |
| 643 "x": 8.0, | 666 "x": 8.0, |
| 644 "y": 345.0 | 667 "y": 345.0 |
| 645 }, | 668 }, |
| 646 "inlineTextNodes": [ { | 669 "inlineTextNodes": [ { |
| 647 "boundingBox": { | 670 "boundingBox": { |
| 648 "height": 16.0, | 671 "height": 16.0, |
| 649 "width": 80.0, | 672 "width": 80.0, |
| 650 "x": 8.0, | 673 "x": 8.0, |
| 651 "y": 345.4375 | 674 "y": 345.4375 |
| 652 }, | 675 }, |
| 653 "numCharacters": 5, | 676 "numCharacters": 5, |
| 654 "startCharacterIndex": 0 | 677 "startCharacterIndex": 0 |
| 655 } ], | 678 } ], |
| 656 "layoutText": "Some ", | 679 "layoutText": "Some ", |
| 657 "localName": "", | 680 "localName": "", |
| 658 "nodeId": 27, | 681 "nodeId": 27, |
| 659 "nodeName": "#text", | 682 "nodeName": "#text", |
| 660 "nodeType": 3, | 683 "nodeType": 3, |
| 661 "nodeValue": "Some ", | 684 "nodeValue": "Some ", |
| 685 "parentId": 26, |
| 662 "styleIndex": 9 | 686 "styleIndex": 9 |
| 663 })raw_string", | 687 })raw_string", |
| 664 | 688 |
| 665 R"raw_string({ | 689 R"raw_string({ |
| 666 "attributes": [ ], | 690 "attributes": [ ], |
| 667 "backendNodeId": 30, | 691 "backendNodeId": 30, |
| 668 "boundingBox": { | 692 "boundingBox": { |
| 669 "height": 17.0, | 693 "height": 17.0, |
| 670 "width": 80.0, | 694 "width": 80.0, |
| 671 "x": 88.0, | 695 "x": 88.0, |
| 672 "y": 345.0 | 696 "y": 345.0 |
| 673 }, | 697 }, |
| 674 "childIndices": [ 28 ], | 698 "childIndices": [ 28 ], |
| 675 "localName": "em", | 699 "localName": "em", |
| 676 "nodeId": 28, | 700 "nodeId": 28, |
| 677 "nodeName": "EM", | 701 "nodeName": "EM", |
| 678 "nodeType": 1, | 702 "nodeType": 1, |
| 679 "nodeValue": "", | 703 "nodeValue": "", |
| 704 "parentId": 26, |
| 680 "styleIndex": 10 | 705 "styleIndex": 10 |
| 681 })raw_string", | 706 })raw_string", |
| 682 | 707 |
| 683 R"raw_string({ | 708 R"raw_string({ |
| 684 "backendNodeId": 31, | 709 "backendNodeId": 31, |
| 685 "boundingBox": { | 710 "boundingBox": { |
| 686 "height": 17.0, | 711 "height": 17.0, |
| 687 "width": 80.0, | 712 "width": 80.0, |
| 688 "x": 88.0, | 713 "x": 88.0, |
| 689 "y": 345.0 | 714 "y": 345.0 |
| 690 }, | 715 }, |
| 691 "inlineTextNodes": [ { | 716 "inlineTextNodes": [ { |
| 692 "boundingBox": { | 717 "boundingBox": { |
| 693 "height": 16.0, | 718 "height": 16.0, |
| 694 "width": 80.0, | 719 "width": 80.0, |
| 695 "x": 88.0, | 720 "x": 88.0, |
| 696 "y": 345.4375 | 721 "y": 345.4375 |
| 697 }, | 722 }, |
| 698 "numCharacters": 5, | 723 "numCharacters": 5, |
| 699 "startCharacterIndex": 0 | 724 "startCharacterIndex": 0 |
| 700 } ], | 725 } ], |
| 701 "layoutText": "green", | 726 "layoutText": "green", |
| 702 "localName": "", | 727 "localName": "", |
| 703 "nodeId": 29, | 728 "nodeId": 29, |
| 704 "nodeName": "#text", | 729 "nodeName": "#text", |
| 705 "nodeType": 3, | 730 "nodeType": 3, |
| 706 "nodeValue": "green", | 731 "nodeValue": "green", |
| 732 "parentId": 28, |
| 707 "styleIndex": 10 | 733 "styleIndex": 10 |
| 708 })raw_string", | 734 })raw_string", |
| 709 | 735 |
| 710 R"raw_string({ | 736 R"raw_string({ |
| 711 "backendNodeId": 32, | 737 "backendNodeId": 32, |
| 712 "boundingBox": { | 738 "boundingBox": { |
| 713 "height": 17.0, | 739 "height": 17.0, |
| 714 "width": 128.0, | 740 "width": 128.0, |
| 715 "x": 168.0, | 741 "x": 168.0, |
| 716 "y": 345.0 | 742 "y": 345.0 |
| 717 }, | 743 }, |
| 718 "inlineTextNodes": [ { | 744 "inlineTextNodes": [ { |
| 719 "boundingBox": { | 745 "boundingBox": { |
| 720 "height": 16.0, | 746 "height": 16.0, |
| 721 "width": 128.0, | 747 "width": 128.0, |
| 722 "x": 168.0, | 748 "x": 168.0, |
| 723 "y": 345.4375 | 749 "y": 345.4375 |
| 724 }, | 750 }, |
| 725 "numCharacters": 8, | 751 "numCharacters": 8, |
| 726 "startCharacterIndex": 0 | 752 "startCharacterIndex": 0 |
| 727 } ], | 753 } ], |
| 728 "layoutText": " text...", | 754 "layoutText": " text...", |
| 729 "localName": "", | 755 "localName": "", |
| 730 "nodeId": 30, | 756 "nodeId": 30, |
| 731 "nodeName": "#text", | 757 "nodeName": "#text", |
| 732 "nodeType": 3, | 758 "nodeType": 3, |
| 733 "nodeValue": " text...", | 759 "nodeValue": " text...", |
| 760 "parentId": 26, |
| 734 "styleIndex": 9 | 761 "styleIndex": 9 |
| 735 })raw_string"}; | 762 })raw_string"}; |
| 736 | 763 |
| 737 EXPECT_EQ(expected_dom_nodes.size(), dom_nodes.size()); | 764 EXPECT_EQ(expected_dom_nodes.size(), dom_nodes.size()); |
| 738 | 765 |
| 739 for (size_t i = 0; i < dom_nodes.size(); i++) { | 766 for (size_t i = 0; i < dom_nodes.size(); i++) { |
| 740 std::string result_json; | 767 std::string result_json; |
| 741 base::JSONWriter::WriteWithOptions( | 768 base::JSONWriter::WriteWithOptions( |
| 742 *dom_nodes[i], base::JSONWriter::OPTIONS_PRETTY_PRINT, &result_json); | 769 *dom_nodes[i], base::JSONWriter::OPTIONS_PRETTY_PRINT, &result_json); |
| 743 | 770 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 | 909 |
| 883 FinishAsynchronousTest(); | 910 FinishAsynchronousTest(); |
| 884 } | 911 } |
| 885 | 912 |
| 886 std::unique_ptr<DomTreeExtractor> extractor_; | 913 std::unique_ptr<DomTreeExtractor> extractor_; |
| 887 }; | 914 }; |
| 888 | 915 |
| 889 HEADLESS_ASYNC_DEVTOOLED_TEST_F(DomTreeExtractorBrowserTest); | 916 HEADLESS_ASYNC_DEVTOOLED_TEST_F(DomTreeExtractorBrowserTest); |
| 890 | 917 |
| 891 } // namespace headless | 918 } // namespace headless |
| OLD | NEW |