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 gWalker = null; |
michael@0 | 25 | var gStyles = null; |
michael@0 | 26 | var gClient = null; |
michael@0 | 27 | |
michael@0 | 28 | addTest(function setup() { |
michael@0 | 29 | let url = document.getElementById("inspectorContent").href; |
michael@0 | 30 | attachURL(url, function(err, client, tab, doc) { |
michael@0 | 31 | gInspectee = doc; |
michael@0 | 32 | let {InspectorFront} = devtools.require("devtools/server/actors/inspector"); |
michael@0 | 33 | let inspector = InspectorFront(client, tab); |
michael@0 | 34 | promiseDone(inspector.getWalker().then(walker => { |
michael@0 | 35 | ok(walker, "getWalker() should return an actor."); |
michael@0 | 36 | gClient = client; |
michael@0 | 37 | gWalker = walker; |
michael@0 | 38 | return inspector.getPageStyle(); |
michael@0 | 39 | }).then(styles => { |
michael@0 | 40 | gStyles = styles; |
michael@0 | 41 | }).then(runNextTest)); |
michael@0 | 42 | }); |
michael@0 | 43 | }); |
michael@0 | 44 | |
michael@0 | 45 | addTest(function testComputed() { |
michael@0 | 46 | let localNode = gInspectee.querySelector("#computed-test-node"); |
michael@0 | 47 | let elementStyle = null; |
michael@0 | 48 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => { |
michael@0 | 49 | return gStyles.getComputed(node, {}); |
michael@0 | 50 | }).then(computed => { |
michael@0 | 51 | // Test a smattering of properties that include some system-defined |
michael@0 | 52 | // props, some props that were defined in this node's stylesheet, |
michael@0 | 53 | // and some default props. |
michael@0 | 54 | is(computed["white-space"].value, "normal", "Default value should appear"); |
michael@0 | 55 | is(computed["display"].value, "block", "System stylesheet item should appear"); |
michael@0 | 56 | is(computed["cursor"].value, "crosshair", "Included stylesheet rule should appear"); |
michael@0 | 57 | is(computed["color"].value, "rgb(255, 0, 0)", "Inherited style attribute should appear"); |
michael@0 | 58 | is(computed["font-size"].value, "15px", "Inherited inline rule should appear"); |
michael@0 | 59 | |
michael@0 | 60 | // We didn't request markMatched, so these shouldn't be set |
michael@0 | 61 | ok(!computed["cursor"].matched, "Didn't ask for matched, shouldn't get it"); |
michael@0 | 62 | ok(!computed["color"].matched, "Didn't ask for matched, shouldn't get it"); |
michael@0 | 63 | ok(!computed["font-size"].matched, "Didn't ask for matched, shouldn't get it"); |
michael@0 | 64 | }).then(runNextTest)); |
michael@0 | 65 | }); |
michael@0 | 66 | |
michael@0 | 67 | addTest(function testComputedUserMatched() { |
michael@0 | 68 | let localNode = gInspectee.querySelector("#computed-test-node"); |
michael@0 | 69 | let elementStyle = null; |
michael@0 | 70 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => { |
michael@0 | 71 | return gStyles.getComputed(node, { filter: "user", markMatched: true }); |
michael@0 | 72 | }).then(computed => { |
michael@0 | 73 | ok(!computed["white-space"].matched, "Default style shouldn't match"); |
michael@0 | 74 | ok(!computed["display"].matched, "Only user styles should match"); |
michael@0 | 75 | ok(computed["cursor"].matched, "Asked for matched, should get it"); |
michael@0 | 76 | ok(computed["color"].matched, "Asked for matched, should get it"); |
michael@0 | 77 | ok(computed["font-size"].matched, "Asked for matched, should get it"); |
michael@0 | 78 | }).then(runNextTest)); |
michael@0 | 79 | }); |
michael@0 | 80 | |
michael@0 | 81 | addTest(function testComputedSystemMatched() { |
michael@0 | 82 | let localNode = gInspectee.querySelector("#computed-test-node"); |
michael@0 | 83 | let elementStyle = null; |
michael@0 | 84 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => { |
michael@0 | 85 | return gStyles.getComputed(node, { filter: "ua", markMatched: true }); |
michael@0 | 86 | }).then(computed => { |
michael@0 | 87 | ok(!computed["white-space"].matched, "Default style shouldn't match"); |
michael@0 | 88 | ok(computed["display"].matched, "System stylesheets should match"); |
michael@0 | 89 | ok(computed["cursor"].matched, "Asked for matched, should get it"); |
michael@0 | 90 | ok(computed["color"].matched, "Asked for matched, should get it"); |
michael@0 | 91 | ok(computed["font-size"].matched, "Asked for matched, should get it"); |
michael@0 | 92 | }).then(runNextTest)); |
michael@0 | 93 | }); |
michael@0 | 94 | |
michael@0 | 95 | addTest(function testComputedUserOnlyMatched() { |
michael@0 | 96 | let localNode = gInspectee.querySelector("#computed-test-node"); |
michael@0 | 97 | let elementStyle = null; |
michael@0 | 98 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => { |
michael@0 | 99 | return gStyles.getComputed(node, { filter: "user", onlyMatched: true }); |
michael@0 | 100 | }).then(computed => { |
michael@0 | 101 | ok(!("white-space" in computed), "Default style shouldn't exist"); |
michael@0 | 102 | ok(!("display" in computed), "System stylesheets shouldn't exist"); |
michael@0 | 103 | ok(("cursor" in computed), "User items should exist."); |
michael@0 | 104 | ok(("color" in computed), "User items should exist."); |
michael@0 | 105 | ok(("font-size" in computed), "User items should exist."); |
michael@0 | 106 | }).then(runNextTest)); |
michael@0 | 107 | }); |
michael@0 | 108 | |
michael@0 | 109 | addTest(function testComputedSystemOnlyMatched() { |
michael@0 | 110 | let localNode = gInspectee.querySelector("#computed-test-node"); |
michael@0 | 111 | let elementStyle = null; |
michael@0 | 112 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => { |
michael@0 | 113 | return gStyles.getComputed(node, { filter: "ua", onlyMatched: true }); |
michael@0 | 114 | }).then(computed => { |
michael@0 | 115 | ok(!("white-space" in computed), "Default style shouldn't exist"); |
michael@0 | 116 | ok(("display" in computed), "System stylesheets should exist"); |
michael@0 | 117 | ok(("cursor" in computed), "User items should exist."); |
michael@0 | 118 | ok(("color" in computed), "User items should exist."); |
michael@0 | 119 | ok(("font-size" in computed), "User items should exist."); |
michael@0 | 120 | }).then(runNextTest)); |
michael@0 | 121 | }); |
michael@0 | 122 | |
michael@0 | 123 | addTest(function cleanup() { |
michael@0 | 124 | delete gStyles; |
michael@0 | 125 | delete gWalker; |
michael@0 | 126 | delete gClient; |
michael@0 | 127 | runNextTest(); |
michael@0 | 128 | }); |
michael@0 | 129 | |
michael@0 | 130 | </script> |
michael@0 | 131 | </head> |
michael@0 | 132 | <body> |
michael@0 | 133 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> |
michael@0 | 134 | <a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a> |
michael@0 | 135 | <p id="display"></p> |
michael@0 | 136 | <div id="content" style="display: none"> |
michael@0 | 137 | |
michael@0 | 138 | </div> |
michael@0 | 139 | <pre id="test"> |
michael@0 | 140 | </pre> |
michael@0 | 141 | </body> |
michael@0 | 142 | </html> |