Index: third_party/WebKit/LayoutTests/inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot.js |
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot.html b/third_party/WebKit/LayoutTests/inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot.js |
similarity index 46% |
rename from third_party/WebKit/LayoutTests/inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot.html |
rename to third_party/WebKit/LayoutTests/inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot.js |
index c914938e56b16ee6d55a82beedea04a2f1949919..516b2daaa3de598652fd9297be9eb9c1599786cc 100644 |
--- a/third_party/WebKit/LayoutTests/inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot.html |
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot.js |
@@ -1,29 +1,13 @@ |
+(async function(testRunner) { |
+ let {page, session, dp} = await testRunner.startHTML(` |
<html> |
<head> |
<style> |
@font-face { |
font-family: 'ahem'; |
- src: url(../../resources/Ahem.ttf); |
+ src: url(${testRunner.url('../../resources/Ahem.ttf')}); |
} |
</style> |
-<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script> |
-<script> |
- |
-async function test() { |
- function stabilize(key, value) { |
- var unstableKeys = ["documentURL", "baseURL", "frameId"]; |
- if (unstableKeys.indexOf(key) !== -1) |
- return "<" + typeof(value) + ">"; |
- return value; |
- } |
- |
- var whitelist = ["transform", "transform-origin", "height", "width", "display", "outline-color", "color"]; |
- var response = await InspectorTest.sendCommandOrDie("DOMSnapshot.getSnapshot", {"computedStyleWhitelist": whitelist}); |
- InspectorTest.log(JSON.stringify(response, stabilize, 2)); |
- InspectorTest.completeTest(); |
-} |
- |
-</script> |
<template id="shadow-template"> |
<style> |
:host { |
@@ -49,15 +33,35 @@ async function test() { |
</ul> |
</div> |
<div style="transform: rotateZ(90deg); width: 200px">Rotated text!</div> |
- <iframe src="../dom/resources/simple-iframe.html" width="400" height="200"></iframe> |
+ <iframe src='${testRunner.url('../resources/simple-iframe.html')}' width="400" height="200"></iframe> |
<div id="shadow-host"></div> |
- <script type="text/javascript"> |
- var host = document.querySelector("#shadow-host").createShadowRoot(); |
- var template = document.querySelector("#shadow-template"); |
- host.appendChild(template.content); |
- template.remove(); |
- window.onload = runTest; |
- </script> |
</div> |
</body> |
</html> |
+ `, 'Tests DOMSnapshot.getSnapshot method.'); |
+ |
+ await session.evaluate(` |
+ var host = document.querySelector('#shadow-host').createShadowRoot(); |
+ var template = document.querySelector('#shadow-template'); |
+ host.appendChild(template.content); |
+ template.remove(); |
+ `); |
+ |
+ function stabilize(key, value) { |
+ var unstableKeys = ['documentURL', 'baseURL', 'frameId']; |
+ if (unstableKeys.indexOf(key) !== -1) |
+ return '<' + typeof(value) + '>'; |
+ if (typeof value === 'string' && value.indexOf('/dom-snapshot/') !== -1) |
+ value = '<value>'; |
+ return value; |
+ } |
+ |
+ var whitelist = ['transform', 'transform-origin', 'height', 'width', 'display', 'outline-color', 'color']; |
+ var response = await dp.DOMSnapshot.getSnapshot({'computedStyleWhitelist': whitelist}); |
+ if (response.error) |
+ testRunner.log(response); |
+ else |
+ testRunner.log(JSON.stringify(response.result, stabilize, 2)); |
+ testRunner.completeTest(); |
+}) |
+ |