Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id= |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug </title> |
michael@0 | 9 | |
michael@0 | 10 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> |
michael@0 | 12 | <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script> |
michael@0 | 13 | <script type="application/javascript;version=1.8"> |
michael@0 | 14 | Components.utils.import("resource://gre/modules/devtools/Loader.jsm"); |
michael@0 | 15 | const {Promise: promise} = Components.utils.import("resource://gre/modules/Promise.jsm", {}); |
michael@0 | 16 | |
michael@0 | 17 | const inspector = devtools.require("devtools/server/actors/inspector"); |
michael@0 | 18 | |
michael@0 | 19 | window.onload = function() { |
michael@0 | 20 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 21 | runNextTest(); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | var gInspectee = null; |
michael@0 | 25 | var gWalker = null; |
michael@0 | 26 | var gClient = null; |
michael@0 | 27 | var attrNode; |
michael@0 | 28 | var attrFront; |
michael@0 | 29 | |
michael@0 | 30 | addTest(function setup() { |
michael@0 | 31 | let url = document.getElementById("inspectorContent").href; |
michael@0 | 32 | attachURL(url, function(err, client, tab, doc) { |
michael@0 | 33 | gInspectee = doc; |
michael@0 | 34 | let {InspectorFront} = devtools.require("devtools/server/actors/inspector"); |
michael@0 | 35 | let inspector = InspectorFront(client, tab); |
michael@0 | 36 | promiseDone(inspector.getWalker().then(walker => { |
michael@0 | 37 | ok(walker, "getWalker() should return an actor."); |
michael@0 | 38 | gClient = client; |
michael@0 | 39 | gWalker = walker; |
michael@0 | 40 | }).then(runNextTest)); |
michael@0 | 41 | }); |
michael@0 | 42 | }); |
michael@0 | 43 | |
michael@0 | 44 | addTest(setupAttrTest); |
michael@0 | 45 | addTest(testAddAttribute); |
michael@0 | 46 | addTest(testChangeAttribute); |
michael@0 | 47 | addTest(testRemoveAttribute); |
michael@0 | 48 | addTest(setupFrameAttrTest); |
michael@0 | 49 | addTest(testAddAttribute); |
michael@0 | 50 | addTest(testChangeAttribute); |
michael@0 | 51 | addTest(testRemoveAttribute); |
michael@0 | 52 | |
michael@0 | 53 | function setupAttrTest() { |
michael@0 | 54 | attrNode = gInspectee.querySelector("#a") |
michael@0 | 55 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(node => { |
michael@0 | 56 | attrFront = node; |
michael@0 | 57 | }).then(runNextTest)); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | function setupFrameAttrTest() { |
michael@0 | 61 | let frame = gInspectee.querySelector('#childFrame'); |
michael@0 | 62 | attrNode = frame.contentDocument.querySelector("#a"); |
michael@0 | 63 | |
michael@0 | 64 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => { |
michael@0 | 65 | return gWalker.children(childFrame); |
michael@0 | 66 | }).then(children => { |
michael@0 | 67 | let nodes = children.nodes; |
michael@0 | 68 | ok(nodes.length, 1, "There should be only one child of the iframe"); |
michael@0 | 69 | is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node"); |
michael@0 | 70 | return gWalker.querySelector(nodes[0], "#a"); |
michael@0 | 71 | }).then(node => { |
michael@0 | 72 | attrFront = node; |
michael@0 | 73 | }).then(runNextTest)); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | function testAddAttribute() { |
michael@0 | 77 | attrNode.setAttribute("data-newattr", "newvalue"); |
michael@0 | 78 | attrNode.setAttribute("data-newattr2", "newvalue"); |
michael@0 | 79 | gWalker.once("mutations", () => { |
michael@0 | 80 | is(attrFront.attributes.length, 3, "Should have id and two new attributes."); |
michael@0 | 81 | is(attrFront.getAttribute("data-newattr"), "newvalue", "Node front should have the first new attribute"); |
michael@0 | 82 | is(attrFront.getAttribute("data-newattr2"), "newvalue", "Node front should have the second new attribute."); |
michael@0 | 83 | runNextTest(); |
michael@0 | 84 | }); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | function testChangeAttribute() { |
michael@0 | 88 | attrNode.setAttribute("data-newattr", "changedvalue"); |
michael@0 | 89 | gWalker.once("mutations", () => { |
michael@0 | 90 | is(attrFront.attributes.length, 3, "Should have id and two new attributes."); |
michael@0 | 91 | is(attrFront.getAttribute("data-newattr"), "changedvalue", "Node front should have the changed first value"); |
michael@0 | 92 | is(attrFront.getAttribute("data-newattr2"), "newvalue", "Second value should remain unchanged."); |
michael@0 | 93 | runNextTest(); |
michael@0 | 94 | }); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | function testRemoveAttribute() { |
michael@0 | 98 | attrNode.removeAttribute("data-newattr2"); |
michael@0 | 99 | gWalker.once("mutations", () => { |
michael@0 | 100 | is(attrFront.attributes.length, 2, "Should have id and one remaining attribute."); |
michael@0 | 101 | is(attrFront.getAttribute("data-newattr"), "changedvalue", "Node front should still have the first value"); |
michael@0 | 102 | ok(!attrFront.hasAttribute("data-newattr2"), "Second value should be removed."); |
michael@0 | 103 | runNextTest(); |
michael@0 | 104 | }) |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | addTest(function cleanup() { |
michael@0 | 108 | delete gInspectee; |
michael@0 | 109 | delete gWalker; |
michael@0 | 110 | delete gClient; |
michael@0 | 111 | runNextTest(); |
michael@0 | 112 | }); |
michael@0 | 113 | |
michael@0 | 114 | |
michael@0 | 115 | </script> |
michael@0 | 116 | </head> |
michael@0 | 117 | <body> |
michael@0 | 118 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> |
michael@0 | 119 | <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a> |
michael@0 | 120 | <p id="display"></p> |
michael@0 | 121 | <div id="content" style="display: none"> |
michael@0 | 122 | |
michael@0 | 123 | </div> |
michael@0 | 124 | <pre id="test"> |
michael@0 | 125 | </pre> |
michael@0 | 126 | </body> |
michael@0 | 127 | </html> |