Bumping manifests a=b2g-bump
[gecko.git] / editor / libeditor / tests / test_bug468353.html
blob179c41cdc7ed9421ed67cdfa4ca31a9f1555a8f4
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">
20 var styleSheets = null;
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
29 styleSheets.removeStyleSheet("resource://gre/res/designmode.css");
30 removed++;
32 catch (ex) { }
34 try {
35 styleSheets.removeStyleSheet("resource://gre/res/contenteditable.css");
36 removed++;
38 catch (ex) { }
40 is(removed, 0, "Should have thrown if stylesheet was not there");
43 function runTest() {
44 const Ci = SpecialPowers.Ci;
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();
53 editdoc.designMode='on';
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);
63 styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
65 editdoc.designMode='off';
67 checkStylesheets();
69 // Let go
70 editor = null;
71 styleSheets = null;
73 editdoc.body.contentEditable = true;
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);
83 styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
85 editdoc.body.contentEditable = false;
87 checkStylesheets();
89 editdoc.designMode = "on";
90 editdoc.body.contentEditable = true;
91 editdoc.designMode = "off";
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);
101 styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
103 editdoc.body.contentEditable = false;
105 checkStylesheets();
107 SimpleTest.finish();
110 //XXX I don't know if this is necessary, but we're dealing with iframes...
111 SimpleTest.waitForExplicitFinish();
112 addLoadEvent(runTest);
114 </script>
115 </pre>
116 </body>
117 </html>