|
1 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> |
|
2 <?xml-stylesheet |
|
3 href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 |
|
5 <window title="View Source Test (bug 428653)" |
|
6 xmlns:html="http://www.w3.org/1999/xhtml" |
|
7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
8 |
|
9 <script type="application/javascript" |
|
10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
11 |
|
12 <html:body/> |
|
13 |
|
14 <browser id="content" type="content-primary" name="content" src="about:blank" flex="1" |
|
15 disablehistory="true" context="viewSourceContextMenu"/> |
|
16 |
|
17 <script type="application/javascript"> |
|
18 <![CDATA[ |
|
19 /* |
|
20 Test that we can't call the content browser's document.open() either via |
|
21 wrappedJSObject (SafeJSObjectWrapper) or not. |
|
22 */ |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 |
|
25 addLoadEvent(function testDocumentOpen() { |
|
26 var browser = document.getElementById("content"); |
|
27 ok(browser, "got browser"); |
|
28 var doc = browser.contentDocument; |
|
29 ok(doc, "got content document"); |
|
30 |
|
31 var opened = false; |
|
32 try { |
|
33 doc.open("text/html", "replace"); |
|
34 opened = true; |
|
35 } catch (e) { |
|
36 is(e.name, "SecurityError", "Unxpected exception") |
|
37 } |
|
38 is(opened, false, "Shouldn't have opened document"); |
|
39 |
|
40 try { |
|
41 doc.wrappedJSObject.open("text/html", "replace"); |
|
42 opened = true; |
|
43 } catch (e) { |
|
44 is(e.name, "SecurityError", |
|
45 "Unxpected exception via wrappedJSObject") |
|
46 } |
|
47 is(opened, false, "Shouldn't have opened document via wrappedJSObject"); |
|
48 |
|
49 SimpleTest.finish(); |
|
50 }); |
|
51 ]]> |
|
52 </script> |
|
53 </window> |