toolkit/devtools/server/tests/mochitest/test_styles-matched.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 const {CssLogic} = devtools.require("devtools/styleinspector/css-logic");
michael@0 19
michael@0 20 window.onload = function() {
michael@0 21 SimpleTest.waitForExplicitFinish();
michael@0 22 runNextTest();
michael@0 23 }
michael@0 24
michael@0 25 var gWalker = null;
michael@0 26 var gStyles = null;
michael@0 27 var gClient = null;
michael@0 28
michael@0 29 addTest(function setup() {
michael@0 30 let url = document.getElementById("inspectorContent").href;
michael@0 31 attachURL(url, function(err, client, tab, doc) {
michael@0 32 gInspectee = doc;
michael@0 33 let {InspectorFront} = devtools.require("devtools/server/actors/inspector");
michael@0 34 let inspector = InspectorFront(client, tab);
michael@0 35 promiseDone(inspector.getWalker().then(walker => {
michael@0 36 ok(walker, "getWalker() should return an actor.");
michael@0 37 gClient = client;
michael@0 38 gWalker = walker;
michael@0 39 return inspector.getPageStyle();
michael@0 40 }).then(styles => {
michael@0 41 gStyles = styles;
michael@0 42 }).then(runNextTest));
michael@0 43 });
michael@0 44 });
michael@0 45
michael@0 46 addTest(function testMatchedStyles() {
michael@0 47 promiseDone(gWalker.querySelector(gWalker.rootNode, "#matched-test-node").then(node => {
michael@0 48 return gStyles.getMatchedSelectors(node, "font-size", {});
michael@0 49 }).then(matched => {
michael@0 50 is(matched[0].sourceText, "this.style", "First match comes from the element style");
michael@0 51 is(matched[0].selector, "@element.style", "Element style has a special selector");
michael@0 52 is(matched[0].value, "10px", "First match has the expected value");
michael@0 53 is(matched[0].status, CssLogic.STATUS.BEST, "First match is the best match")
michael@0 54 is(matched[0].rule.type, 100, "First match is an element style");
michael@0 55 is(matched[0].rule.href, gInspectee.defaultView.location.href, "Node style comes from this document")
michael@0 56
michael@0 57 is(matched[1].sourceText, ".inheritable-rule", "Second match comes from a rule");
michael@0 58 is(matched[1].selector, ".inheritable-rule", "Second style has a selector");
michael@0 59 is(matched[1].value, "15px", "Second match has the expected value");
michael@0 60 is(matched[1].status, CssLogic.STATUS.PARENT_MATCH, "Second match is from the parent")
michael@0 61 is(matched[1].rule.parentStyleSheet.href, null, "Inline stylesheet shouldn't have an href");
michael@0 62 is(matched[1].rule.parentStyleSheet.nodeHref, gInspectee.defaultView.location.href, "Inline stylesheet's nodeHref should match the current document");
michael@0 63 ok(!matched[1].rule.parentStyleSheet.system, "Inline stylesheet shouldn't be a system stylesheet.");
michael@0 64 }).then(runNextTest));
michael@0 65 });
michael@0 66
michael@0 67 addTest(function testSystemStyles() {
michael@0 68 let testNode = null;
michael@0 69
michael@0 70 promiseDone(gWalker.querySelector(gWalker.rootNode, "#matched-test-node").then(node => {
michael@0 71 testNode = node;
michael@0 72 return gStyles.getMatchedSelectors(testNode, "display", { filter: "user" });
michael@0 73 }).then(matched => {
michael@0 74 is(matched.length, 0, "No user selectors apply to this rule.");
michael@0 75 return gStyles.getMatchedSelectors(testNode, "display", { filter: "ua" });
michael@0 76 }).then(matched => {
michael@0 77 is(matched[0].selector, "div", "Should match system div selector");
michael@0 78 is(matched[0].value, "block");
michael@0 79 }).then(runNextTest));
michael@0 80 });
michael@0 81
michael@0 82 addTest(function cleanup() {
michael@0 83 delete gStyles;
michael@0 84 delete gWalker;
michael@0 85 delete gClient;
michael@0 86 runNextTest();
michael@0 87 });
michael@0 88
michael@0 89 </script>
michael@0 90 </head>
michael@0 91 <body>
michael@0 92 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
michael@0 93 <a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
michael@0 94 <p id="display"></p>
michael@0 95 <div id="content" style="display: none">
michael@0 96
michael@0 97 </div>
michael@0 98 <pre id="test">
michael@0 99 </pre>
michael@0 100 </body>
michael@0 101 </html>

mercurial