Commit 9d3555c2 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

Add a protocol test for async originURL in DOMSnapshot.captureSnapshot

Change-Id: Id8943bd70fa5fd7df1e2d4b5b02bff7117e6cf44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832915
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Reviewed-by: default avatarJohannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703545}
parent e2f74f94
Tests that DOMSnapshot.captureSnapshot records origin url of dom nodes generated by script.
DIV: http://a.test/script.js
(async function(testRunner) {
var {page, session, dp} = await testRunner.startBlank('Tests that DOMSnapshot.captureSnapshot records origin url of dom nodes generated by script.');
await dp.DOMSnapshot.enable();
await dp.Runtime.enable();
const res = await dp.Runtime.setAsyncCallStackDepth({maxDepth: 10});
await session.evaluateAsync(`
setTimeout("document.body.appendChild(document.createElement('div'))", 0);
new Promise(fulfill => setTimeout(fulfill), 0);
\n//# sourceURL=http://a.test/script.js`);
const {result} = await dp.DOMSnapshot.captureSnapshot({'computedStyles': []});
function lookupRareString(table, index) {
const entryIndex = table.index.indexOf(index);
return entryIndex >= 0 ? result.strings[table.value[entryIndex]] : "";
}
const nodes = result.documents[0].nodes;
let nodeIndex = 0;
for (const nameIndex of nodes.nodeName) {
const name = result.strings[nameIndex];
if (name === 'DIV') {
const originURL = lookupRareString(nodes.originURL, nodeIndex);
testRunner.log(`${name}: ${originURL}`);
}
++nodeIndex;
}
testRunner.completeTest();
})
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment