layout/inspector/tests/test_bug462789.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/inspector/tests/test_bug462789.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=462789
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 462789</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462789">Mozilla Bug 462789</a>
    1.16 +<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>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script type="application/javascript">
    1.22 +
    1.23 +/** Test for Bug 462789 **/
    1.24 +
    1.25 +function do_test() {
    1.26 +  const ERROR_FAILURE = 0x80004005;
    1.27 +  const DOCUMENT_NODE_TYPE = 9;
    1.28 +
    1.29 +  var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
    1.30 +                             .getService(SpecialPowers.Ci.inIDOMUtils);
    1.31 +
    1.32 +  var iframe = document.getElementById("bug462789_iframe");
    1.33 +  var docElement = iframe.contentDocument.documentElement;
    1.34 +  var body = docElement.children[1];
    1.35 +  var rule = iframe.contentDocument.styleSheets[0].cssRules[0];
    1.36 +  var text = body.firstChild;
    1.37 +
    1.38 +  try {
    1.39 +    var res = utils.getCSSStyleRules(docElement);
    1.40 +    is(res, null, "getCSSStyleRules");
    1.41 +    res = utils.getCSSStyleRules(body);
    1.42 +    is(res, null, "getCSSStyleRules");
    1.43 +  }
    1.44 +  catch(e) { ok(false, "got an unexpected exception:" + e); }
    1.45 +
    1.46 +  try {
    1.47 +    var res = utils.getRuleLine(rule);
    1.48 +    is(res, 1, "getRuleLine");
    1.49 +  }
    1.50 +  catch(e) { ok(false, "got an unexpected exception:" + e); }
    1.51 +
    1.52 +  try {
    1.53 +    var res = utils.isIgnorableWhitespace(text);
    1.54 +    is(res, false, "isIgnorableWhitespace");
    1.55 +  }
    1.56 +  catch(e) { ok(false, "got an unexpected exception:" + e); }
    1.57 +
    1.58 +  try {
    1.59 +    var res = utils.getParentForNode(docElement, true);
    1.60 +    is(res.nodeType, DOCUMENT_NODE_TYPE, "getParentForNode(docElement, true)");
    1.61 +    res = utils.getParentForNode(text, true);
    1.62 +    is(res.tagName, "BODY", "getParentForNode(text, true)");
    1.63 +  }
    1.64 +  catch(e) { ok(false, "got an unexpected exception:" + e); }
    1.65 +
    1.66 +  try {
    1.67 +    var res = utils.getBindingURLs(docElement);
    1.68 +    ok(SpecialPowers.call_Instanceof(res, SpecialPowers.Ci["nsIArray"]), "getBindingURLs result type");
    1.69 +    is(res.length, 0, "getBindingURLs array length");
    1.70 +  }
    1.71 +  catch(e) { ok(false, "got an unexpected exception:" + e); }
    1.72 +
    1.73 +  try {
    1.74 +    utils.getContentState(docElement);
    1.75 +    ok(true, "Should not throw"); 
    1.76 +  }
    1.77 +  catch(e) { ok(false, "Got an exception: " + e); }
    1.78 +
    1.79 +  try {
    1.80 +    utils.setContentState(docElement, false);
    1.81 +    ok(false, "expected an exception"); 
    1.82 +  }
    1.83 +  catch(e) {
    1.84 +    e = SpecialPowers.wrap(e);
    1.85 +    is(e.result, ERROR_FAILURE, "got the expected exception");
    1.86 +  }
    1.87 +
    1.88 +  SimpleTest.finish();
    1.89 +}
    1.90 +
    1.91 +SimpleTest.waitForExplicitFinish();
    1.92 +addLoadEvent(do_test);
    1.93 +
    1.94 +</script>
    1.95 +</pre>
    1.96 +</body>
    1.97 +</html>

mercurial