layout/inspector/tests/test_bug462789.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=462789
     5 -->
     6 <head>
     7   <title>Test for Bug 462789</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462789">Mozilla Bug 462789</a>
    13 <p id="display"><iframe id="bug462789_iframe" src="data:text/html,<html><head><style>*{color:black;}</style></head><body>xxx" style="display: none;"></iframe></p>
    14 <div id="content" style="display: none">
    16 </div>
    17 <pre id="test">
    18 <script type="application/javascript">
    20 /** Test for Bug 462789 **/
    22 function do_test() {
    23   const ERROR_FAILURE = 0x80004005;
    24   const DOCUMENT_NODE_TYPE = 9;
    26   var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
    27                              .getService(SpecialPowers.Ci.inIDOMUtils);
    29   var iframe = document.getElementById("bug462789_iframe");
    30   var docElement = iframe.contentDocument.documentElement;
    31   var body = docElement.children[1];
    32   var rule = iframe.contentDocument.styleSheets[0].cssRules[0];
    33   var text = body.firstChild;
    35   try {
    36     var res = utils.getCSSStyleRules(docElement);
    37     is(res, null, "getCSSStyleRules");
    38     res = utils.getCSSStyleRules(body);
    39     is(res, null, "getCSSStyleRules");
    40   }
    41   catch(e) { ok(false, "got an unexpected exception:" + e); }
    43   try {
    44     var res = utils.getRuleLine(rule);
    45     is(res, 1, "getRuleLine");
    46   }
    47   catch(e) { ok(false, "got an unexpected exception:" + e); }
    49   try {
    50     var res = utils.isIgnorableWhitespace(text);
    51     is(res, false, "isIgnorableWhitespace");
    52   }
    53   catch(e) { ok(false, "got an unexpected exception:" + e); }
    55   try {
    56     var res = utils.getParentForNode(docElement, true);
    57     is(res.nodeType, DOCUMENT_NODE_TYPE, "getParentForNode(docElement, true)");
    58     res = utils.getParentForNode(text, true);
    59     is(res.tagName, "BODY", "getParentForNode(text, true)");
    60   }
    61   catch(e) { ok(false, "got an unexpected exception:" + e); }
    63   try {
    64     var res = utils.getBindingURLs(docElement);
    65     ok(SpecialPowers.call_Instanceof(res, SpecialPowers.Ci["nsIArray"]), "getBindingURLs result type");
    66     is(res.length, 0, "getBindingURLs array length");
    67   }
    68   catch(e) { ok(false, "got an unexpected exception:" + e); }
    70   try {
    71     utils.getContentState(docElement);
    72     ok(true, "Should not throw"); 
    73   }
    74   catch(e) { ok(false, "Got an exception: " + e); }
    76   try {
    77     utils.setContentState(docElement, false);
    78     ok(false, "expected an exception"); 
    79   }
    80   catch(e) {
    81     e = SpecialPowers.wrap(e);
    82     is(e.result, ERROR_FAILURE, "got the expected exception");
    83   }
    85   SimpleTest.finish();
    86 }
    88 SimpleTest.waitForExplicitFinish();
    89 addLoadEvent(do_test);
    91 </script>
    92 </pre>
    93 </body>
    94 </html>

mercurial