tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug462789.html (2240B)


      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 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" srcdoc="<html><head><style>*{color:black;}</style></head><body>xxx" style="display: none;"></iframe></p>
     14 <div id="content" style="display: none">
     15  
     16 </div>
     17 <pre id="test">
     18 <script type="application/javascript">
     19 
     20 /** Test for Bug 462789 */
     21 
     22 const InspectorUtils = SpecialPowers.InspectorUtils;
     23 
     24 function do_test() {
     25  const DOCUMENT_NODE_TYPE = 9;
     26 
     27  var iframe = document.getElementById("bug462789_iframe");
     28  var docElement = iframe.contentDocument.documentElement;
     29  var body = docElement.children[1];
     30  var rule = iframe.contentDocument.styleSheets[0].cssRules[0];
     31  var text = body.firstChild;
     32 
     33  try {
     34    var res = InspectorUtils.getMatchingCSSRules(docElement);
     35    is(res.length, 0, "getMatchingCSSRules");
     36    res = InspectorUtils.getMatchingCSSRules(body);
     37    is(res.length, 0, "getMatchingCSSRules");
     38  }
     39  catch(e) { ok(false, "got an unexpected exception:" + e); }
     40 
     41  try {
     42    var res = InspectorUtils.getRuleLine(rule);
     43    is(res, 1, "getRuleLine");
     44  }
     45  catch(e) { ok(false, "got an unexpected exception:" + e); }
     46 
     47  try {
     48    var res = InspectorUtils.isIgnorableWhitespace(text);
     49    is(res, false, "isIgnorableWhitespace");
     50  }
     51  catch(e) { ok(false, "got an unexpected exception:" + e); }
     52 
     53  try {
     54    var res = InspectorUtils.getParentForNode(docElement, true);
     55    is(res.nodeType, DOCUMENT_NODE_TYPE, "getParentForNode(docElement, true)");
     56    res = InspectorUtils.getParentForNode(text, true);
     57    is(res.tagName, "BODY", "getParentForNode(text, true)");
     58  }
     59  catch(e) { ok(false, "got an unexpected exception:" + e); }
     60 
     61  try {
     62    InspectorUtils.getContentState(docElement);
     63    ok(true, "Should not throw"); 
     64  }
     65  catch(e) { ok(false, "Got an exception: " + e); }
     66 
     67  SimpleTest.finish();
     68 }
     69 
     70 SimpleTest.waitForExplicitFinish();
     71 addLoadEvent(do_test);
     72 
     73 </script>
     74 </pre>
     75 </body>
     76 </html>