| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/inspector-protocol-test.js"></script> | |
| 4 <script type="text/javascript"> | |
| 5 | |
| 6 function test() | |
| 7 { | |
| 8 getDocument(); | |
| 9 | |
| 10 function getDocument() | |
| 11 { | |
| 12 InspectorTest.sendCommand("DOM.getDocument", {}, function(messageObject)
{ | |
| 13 if (messageObject.hasOwnProperty("error")) | |
| 14 InspectorTest.log("Backend error: " + messageObject.error.messag
e + " (" + messageObject.error.code + ")\n"); | |
| 15 | |
| 16 var bodyId = messageObject.result.root.children[0].children[1].nodeI
d; | |
| 17 requestChildNodes(bodyId); | |
| 18 }); | |
| 19 }; | |
| 20 | |
| 21 function requestChildNodes(bodyId) | |
| 22 { | |
| 23 InspectorTest.sendCommand("DOM.requestChildNodes", {"nodeId": bodyId, "d
epth": -1}, function(messageObject) { | |
| 24 if (messageObject.hasOwnProperty("error")) | |
| 25 InspectorTest.log("Backend error: " + messageObject.error.messag
e + " (" + messageObject.error.code + ")\n"); | |
| 26 }); | |
| 27 | |
| 28 InspectorTest.eventHandler["DOM.setChildNodes"] = function(messageObject
) | |
| 29 { | |
| 30 var iframeContentDocument = messageObject.params.nodes[0].children[0
].children[0].children[0].contentDocument; | |
| 31 if (iframeContentDocument.children) { | |
| 32 InspectorTest.log("Error IFrame node should not include children
: " + JSON.stringify(iframeContentDocument, null, " ")); | |
| 33 InspectorTest.completeTest(); | |
| 34 } else { | |
| 35 getDocumentIncludingIframe(); | |
| 36 } | |
| 37 }; | |
| 38 }; | |
| 39 | |
| 40 function getDocumentIncludingIframe() | |
| 41 { | |
| 42 InspectorTest.sendCommand("DOM.getDocument", {"pierce": true}, function(
messageObject) { | |
| 43 if (messageObject.hasOwnProperty("error")) | |
| 44 InspectorTest.log("Backend error: " + messageObject.error.messag
e + " (" + messageObject.error.code + ")\n"); | |
| 45 | |
| 46 var bodyId = messageObject.result.root.children[0].children[1].nodeI
d; | |
| 47 requestAllChildNodesIncludingIframe(bodyId); | |
| 48 }); | |
| 49 }; | |
| 50 | |
| 51 function replacePropertyRecursive(object, propertyNameToReplace) | |
| 52 { | |
| 53 for (var propertyName in object) { | |
| 54 if (!object.hasOwnProperty(propertyName)) | |
| 55 continue; | |
| 56 if (propertyName === propertyNameToReplace) { | |
| 57 object[propertyName] = "???"; | |
| 58 } else if (typeof object[propertyName] === "object") { | |
| 59 replacePropertyRecursive(object[propertyName], propertyNameToRep
lace); | |
| 60 } | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 function requestAllChildNodesIncludingIframe(bodyId) | |
| 65 { | |
| 66 InspectorTest.sendCommand("DOM.requestChildNodes", {"nodeId": bodyId, "d
epth": -1, "pierce": true}, function(messageObject) { | |
| 67 if (messageObject.hasOwnProperty("error")) | |
| 68 InspectorTest.log("Backend error: " + messageObject.error.messag
e + " (" + messageObject.error.code + ")\n"); | |
| 69 }); | |
| 70 | |
| 71 InspectorTest.eventHandler["DOM.setChildNodes"] = function(messageObject
) | |
| 72 { | |
| 73 // Replace properties that tend to change every run. | |
| 74 replacePropertyRecursive(messageObject, "frameId"); | |
| 75 replacePropertyRecursive(messageObject, "documentURL"); | |
| 76 replacePropertyRecursive(messageObject, "baseURL"); | |
| 77 function stabilize(key, value) { | |
| 78 var unstableKeys = ["backendNodeId"]; | |
| 79 if (unstableKeys.indexOf(key) !== -1) | |
| 80 return "<" + typeof(value) + ">"; | |
| 81 return value; | |
| 82 } | |
| 83 InspectorTest.log(JSON.stringify(messageObject, stabilize, " ")); | |
| 84 InspectorTest.completeTest(); | |
| 85 }; | |
| 86 }; | |
| 87 }; | |
| 88 | |
| 89 window.addEventListener("DOMContentLoaded", function () { | |
| 90 runTest(); | |
| 91 }, false); | |
| 92 | |
| 93 </script> | |
| 94 </head> | |
| 95 <body> | |
| 96 | |
| 97 <div id="depth-1"> | |
| 98 <div id="depth-2"> | |
| 99 <div id="depth-3"> | |
| 100 <iframe src="resources/iframe.html"></iframe> | |
| 101 </div> | |
| 102 </div> | |
| 103 </div> | |
| 104 | |
| 105 </body> | |
| 106 </html> | |
| OLD | NEW |