toolkit/devtools/server/tests/mochitest/test_styles-applied.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.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=
     5 -->
     6 <head>
     7   <meta charset="utf-8">
     8   <title>Test for Bug </title>
    10   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    11   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
    12   <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
    13   <script type="application/javascript;version=1.8">
    14 Components.utils.import("resource://gre/modules/devtools/Loader.jsm");
    15 const {Promise: promise} = Components.utils.import("resource://gre/modules/Promise.jsm", {});
    17 const inspector = devtools.require("devtools/server/actors/inspector");
    19 window.onload = function() {
    20   SimpleTest.waitForExplicitFinish();
    21   runNextTest();
    22 }
    24 var gWalker = null;
    25 var gStyles = null;
    26 var gClient = null;
    28 addTest(function setup() {
    29   let url = document.getElementById("inspectorContent").href;
    30   attachURL(url, function(err, client, tab, doc) {
    31     let {InspectorFront} = devtools.require("devtools/server/actors/inspector");
    32     let inspector = InspectorFront(client, tab);
    33     promiseDone(inspector.getWalker().then(walker => {
    34       ok(walker, "getWalker() should return an actor.");
    35       gClient = client;
    36       gWalker = walker;
    37       return inspector.getPageStyle();
    38     }).then(styles => {
    39       gStyles = styles;
    40     }).then(runNextTest));
    41   });
    42 });
    44 addTest(function inheritedUserStyles() {
    45   let node = node;
    46   promiseDone(gWalker.querySelector(gWalker.rootNode, "#test-node").then(node => {
    47     return gStyles.getApplied(node, { inherited: true, filter: "user" });
    48   }).then(applied => {
    49     ok(!applied[0].inherited, "Entry 0 should be uninherited");
    50     is(applied[0].rule.type, 100, "Entry 0 should be an element style");
    51     ok(!!applied[0].rule.href, "Element styles should have a URL");
    52     is(applied[0].rule.cssText, "", "Entry 0 should be an empty style");
    54     is(applied[1].inherited.id, "uninheritable-rule-inheritable-style",
    55        "Entry 1 should be inherited from the parent");
    56     is(applied[1].rule.type, 100, "Entry 1 should be an element style");
    57     is(applied[1].rule.cssText, "color: red;", "Entry 1 should have the expected cssText");
    59     is(applied[2].inherited.id, "inheritable-rule-inheritable-style",
    60        "Entry 2 should be inherited from the parent's parent");
    61     is(applied[2].rule.type, 100, "Entry 2 should be an element style");
    62     is(applied[2].rule.cssText, "color: blue;", "Entry 2 should have the expected cssText");
    64     is(applied[3].inherited.id, "inheritable-rule-inheritable-style",
    65        "Entry 3 should be inherited from the parent's parent");
    66     is(applied[3].rule.type, 1, "Entry 3 should be a rule style");
    67     is(applied[3].rule.cssText, "font-size: 15px;", "Entry 3 should have the expected cssText");
    68     ok(!applied[3].matchedSelectors, "Shouldn't get matchedSelectors with this request.");
    70     is(applied[4].inherited.id, "inheritable-rule-uninheritable-style",
    71        "Entry 4 should be inherited from the parent's parent");
    72     is(applied[4].rule.type, 1, "Entry 4 should be an rule style");
    73     is(applied[4].rule.cssText, "font-size: 15px;", "Entry 4 should have the expected cssText");
    74     ok(!applied[4].matchedSelectors, "Shouldn't get matchedSelectors with this request.");
    76     is(applied.length, 5, "Should have 5 rules.");
    77   }).then(runNextTest));
    78 });
    80 addTest(function inheritedSystemStyles() {
    81   let node = node;
    82   promiseDone(gWalker.querySelector(gWalker.rootNode, "#test-node").then(node => {
    83     return gStyles.getApplied(node, { inherited: true, filter: "ua" });
    84   }).then(applied => {
    85     // If our system stylesheets are prone to churn, this might be a fragile
    86     // test.  If you're here because of that I apologize, file a bug
    87     // and we can find a different way to test.
    89     ok(!applied[1].inherited, "Entry 1 should not be inherited");
    90     ok(!applied[1].rule.parentStyleSheet.system, "Entry 1 should be a system style");
    91     is(applied[1].rule.type, 1, "Entry 1 should be a rule style");
    93     is(applied.length, 7, "Should have 7 rules.");
    94   }).then(runNextTest));
    95 });
    97 addTest(function noInheritedStyles() {
    98   let node = node;
    99   promiseDone(gWalker.querySelector(gWalker.rootNode, "#test-node").then(node => {
   100     return gStyles.getApplied(node, { inherited: false, filter: "user" });
   101   }).then(applied => {
   102     ok(!applied[0].inherited, "Entry 0 should be uninherited");
   103     is(applied[0].rule.type, 100, "Entry 0 should be an element style");
   104     is(applied[0].rule.cssText, "", "Entry 0 should be an empty style");
   105     is(applied.length, 1, "Should have 1 rule.");
   106   }).then(runNextTest));
   107 });
   109 addTest(function matchedSelectors() {
   110   promiseDone(gWalker.querySelector(gWalker.rootNode, "#test-node").then(node => {
   111     return gStyles.getApplied(node, {
   112       inherited: true, filter: "user", matchedSelectors: true
   113     });
   114   }).then(applied => {
   115     is(applied[3].matchedSelectors[0], ".inheritable-rule", "Entry 3 should have a matched selector");
   116     is(applied[4].matchedSelectors[0], ".inheritable-rule", "Entry 4 should have a matched selector");
   117   }).then(runNextTest));
   118 });
   120 addTest(function testMediaQuery() {
   121   let node = node;
   122   promiseDone(gWalker.querySelector(gWalker.rootNode, "#mediaqueried").then(node => {
   123     return gStyles.getApplied(node, {
   124       inherited: false, filter: "user", matchedSelectors: true
   125     });
   126   }).then(applied => {
   127     is(applied[1].rule.type, 1, "Entry 1 is a rule style");
   128     is(applied[1].rule.parentRule.type, 4, "Entry 1's parent rule is a media rule");
   129     is(applied[1].rule.parentRule.media[0], "screen", "Entry 1's parent rule has the expected medium");
   130   }).then(runNextTest));
   131 });
   133 addTest(function cleanup() {
   134   delete gStyles;
   135   delete gWalker;
   136   delete gClient;
   137   runNextTest();
   138 });
   140   </script>
   141 </head>
   142 <body>
   143 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
   144 <a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
   145 <p id="display"></p>
   146 <div id="content" style="display: none">
   148 </div>
   149 <pre id="test">
   150 </pre>
   151 </body>
   152 </html>

mercurial