|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" |
|
3 type="text/css"?> |
|
4 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
|
5 type="text/css"?> |
|
6 <!-- |
|
7 https://bugzilla.mozilla.org/show_bug.cgi?id=434998 |
|
8 --> |
|
9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
10 title="Mozilla Bug 434998" onload="runTest();"> |
|
11 <script type="application/javascript" |
|
12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
|
13 <script type="application/javascript" |
|
14 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
15 |
|
16 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
17 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=434998" |
|
18 target="_blank">Mozilla Bug 434998</a> |
|
19 <p/> |
|
20 <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
21 id="editor" |
|
22 type="content-primary" |
|
23 editortype="html" |
|
24 style="width: 400px; height: 100px; border: thin solid black"/> |
|
25 <p/> |
|
26 <pre id="test"> |
|
27 </pre> |
|
28 </body> |
|
29 <script class="testbody" type="application/javascript"> |
|
30 <![CDATA[ |
|
31 |
|
32 SimpleTest.waitForExplicitFinish(); |
|
33 |
|
34 function EditorContentListener(aEditor) |
|
35 { |
|
36 this.init(aEditor); |
|
37 } |
|
38 |
|
39 EditorContentListener.prototype = { |
|
40 init : function(aEditor) |
|
41 { |
|
42 this.mEditor = aEditor; |
|
43 }, |
|
44 |
|
45 QueryInterface : function(aIID) |
|
46 { |
|
47 if (aIID.equals(Components.interfaces.nsIWebProgressListener) || |
|
48 aIID.equals(Components.interfaces.nsISupportsWeakReference) || |
|
49 aIID.equals(Components.interfaces.nsISupports)) |
|
50 return this; |
|
51 throw Components.results.NS_NOINTERFACE; |
|
52 }, |
|
53 |
|
54 onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) |
|
55 { |
|
56 if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) |
|
57 { |
|
58 var editor = this.mEditor.getEditor(this.mEditor.contentWindow); |
|
59 if (editor) { |
|
60 // Should not throw |
|
61 var threw = false; |
|
62 try { |
|
63 this.mEditor.contentDocument.execCommand("bold", false, null); |
|
64 } catch (e) { |
|
65 threw = true; |
|
66 } |
|
67 ok(!threw, "The execCommand API should work on <xul:editor>"); |
|
68 progress.removeProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); |
|
69 SimpleTest.finish(); |
|
70 } |
|
71 } |
|
72 }, |
|
73 |
|
74 |
|
75 onProgressChange : function(aWebProgress, aRequest, |
|
76 aCurSelfProgress, aMaxSelfProgress, |
|
77 aCurTotalProgress, aMaxTotalProgress) |
|
78 { |
|
79 }, |
|
80 |
|
81 onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags) |
|
82 { |
|
83 }, |
|
84 |
|
85 onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) |
|
86 { |
|
87 }, |
|
88 |
|
89 onSecurityChange : function(aWebProgress, aRequest, aState) |
|
90 { |
|
91 }, |
|
92 |
|
93 mEditor: null |
|
94 }; |
|
95 |
|
96 var progress, progressListener; |
|
97 |
|
98 function runTest() { |
|
99 var newEditorElement = document.getElementById("editor"); |
|
100 newEditorElement.makeEditable("html", true); |
|
101 var docShell = newEditorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).docShell; |
|
102 progress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress); |
|
103 progressListener = new EditorContentListener(newEditorElement); |
|
104 progress.addProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); |
|
105 newEditorElement.setAttribute("src", "data:text/html,"); |
|
106 } |
|
107 ]]> |
|
108 </script> |
|
109 </window> |