|
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"> |
|
15 |
|
16 </div> |
|
17 <pre id="test"> |
|
18 <script type="application/javascript"> |
|
19 |
|
20 /** Test for Bug 462789 **/ |
|
21 |
|
22 function do_test() { |
|
23 const ERROR_FAILURE = 0x80004005; |
|
24 const DOCUMENT_NODE_TYPE = 9; |
|
25 |
|
26 var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"] |
|
27 .getService(SpecialPowers.Ci.inIDOMUtils); |
|
28 |
|
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; |
|
34 |
|
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); } |
|
42 |
|
43 try { |
|
44 var res = utils.getRuleLine(rule); |
|
45 is(res, 1, "getRuleLine"); |
|
46 } |
|
47 catch(e) { ok(false, "got an unexpected exception:" + e); } |
|
48 |
|
49 try { |
|
50 var res = utils.isIgnorableWhitespace(text); |
|
51 is(res, false, "isIgnorableWhitespace"); |
|
52 } |
|
53 catch(e) { ok(false, "got an unexpected exception:" + e); } |
|
54 |
|
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); } |
|
62 |
|
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); } |
|
69 |
|
70 try { |
|
71 utils.getContentState(docElement); |
|
72 ok(true, "Should not throw"); |
|
73 } |
|
74 catch(e) { ok(false, "Got an exception: " + e); } |
|
75 |
|
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 } |
|
84 |
|
85 SimpleTest.finish(); |
|
86 } |
|
87 |
|
88 SimpleTest.waitForExplicitFinish(); |
|
89 addLoadEvent(do_test); |
|
90 |
|
91 </script> |
|
92 </pre> |
|
93 </body> |
|
94 </html> |