|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=468353 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 468353</title> |
|
8 <script type="text/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=468353">Mozilla Bug 468353</a> |
|
13 <p id="display"></p> |
|
14 <div id="content"> |
|
15 <iframe></iframe> |
|
16 </div> |
|
17 <pre id="test"> |
|
18 <script class="testbody" type="text/javascript"> |
|
19 |
|
20 var styleSheets = null; |
|
21 |
|
22 function checkStylesheets() { |
|
23 // Evidently RemoveStyleSheet is the only method in nsIEditorStyleSheets |
|
24 // that would throw. RemoveOverrideStyleSheet returns NS_OK even if the |
|
25 // sheet is not there |
|
26 var removed = 0; |
|
27 try |
|
28 { |
|
29 styleSheets.removeStyleSheet("resource://gre/res/designmode.css"); |
|
30 removed++; |
|
31 } |
|
32 catch (ex) { } |
|
33 |
|
34 try { |
|
35 styleSheets.removeStyleSheet("resource://gre/res/contenteditable.css"); |
|
36 removed++; |
|
37 } |
|
38 catch (ex) { } |
|
39 |
|
40 is(removed, 0, "Should have thrown if stylesheet was not there"); |
|
41 } |
|
42 |
|
43 function runTest() { |
|
44 const Ci = SpecialPowers.Ci; |
|
45 |
|
46 /** Found while fixing bug 440614 **/ |
|
47 var editframe = window.frames[0]; |
|
48 var editdoc = editframe.document; |
|
49 var editor = null; |
|
50 editdoc.write(''); |
|
51 editdoc.close(); |
|
52 |
|
53 editdoc.designMode='on'; |
|
54 |
|
55 // Hold the reference to the editor |
|
56 editor = SpecialPowers.wrap(editframe) |
|
57 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
58 .getInterface(Ci.nsIWebNavigation) |
|
59 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
60 .getInterface(Ci.nsIEditingSession) |
|
61 .getEditorForWindow(editframe); |
|
62 |
|
63 styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets); |
|
64 |
|
65 editdoc.designMode='off'; |
|
66 |
|
67 checkStylesheets(); |
|
68 |
|
69 // Let go |
|
70 editor = null; |
|
71 styleSheets = null; |
|
72 |
|
73 editdoc.body.contentEditable = true; |
|
74 |
|
75 // Hold the reference to the editor |
|
76 editor = SpecialPowers.wrap(editframe) |
|
77 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
78 .getInterface(Ci.nsIWebNavigation) |
|
79 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
80 .getInterface(Ci.nsIEditingSession) |
|
81 .getEditorForWindow(editframe); |
|
82 |
|
83 styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets); |
|
84 |
|
85 editdoc.body.contentEditable = false; |
|
86 |
|
87 checkStylesheets(); |
|
88 |
|
89 editdoc.designMode = "on"; |
|
90 editdoc.body.contentEditable = true; |
|
91 editdoc.designMode = "off"; |
|
92 |
|
93 // Hold the reference to the editor |
|
94 editor = SpecialPowers.wrap(editframe) |
|
95 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
96 .getInterface(Ci.nsIWebNavigation) |
|
97 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
98 .getInterface(Ci.nsIEditingSession) |
|
99 .getEditorForWindow(editframe); |
|
100 |
|
101 styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets); |
|
102 |
|
103 editdoc.body.contentEditable = false; |
|
104 |
|
105 checkStylesheets(); |
|
106 |
|
107 SimpleTest.finish(); |
|
108 } |
|
109 |
|
110 //XXX I don't know if this is necessary, but we're dealing with iframes... |
|
111 SimpleTest.waitForExplicitFinish(); |
|
112 addLoadEvent(runTest); |
|
113 |
|
114 </script> |
|
115 </pre> |
|
116 </body> |
|
117 </html> |