|
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=780908 |
|
8 |
|
9 adapted from test_bug607584.xul by Kent James <kent@caspia.com> |
|
10 --> |
|
11 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
12 title="Mozilla Bug 780908" onload="runTest();"> |
|
13 <script type="application/javascript" |
|
14 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
|
15 <script type="application/javascript" |
|
16 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
17 |
|
18 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
19 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=780908" |
|
20 target="_blank">Mozilla Bug 780908</a> |
|
21 <p/> |
|
22 <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
23 id="editor" |
|
24 type="content-primary" |
|
25 editortype="html" |
|
26 style="width: 400px; height: 100px; border: thin solid black"/> |
|
27 <p/> |
|
28 <pre id="test"> |
|
29 </pre> |
|
30 </body> |
|
31 <script class="testbody" type="application/javascript"> |
|
32 <![CDATA[ |
|
33 |
|
34 SimpleTest.waitForExplicitFinish(); |
|
35 |
|
36 function EditorContentListener(aEditor) |
|
37 { |
|
38 this.init(aEditor); |
|
39 } |
|
40 |
|
41 EditorContentListener.prototype = { |
|
42 init : function(aEditor) |
|
43 { |
|
44 this.mEditor = aEditor; |
|
45 }, |
|
46 |
|
47 QueryInterface : function(aIID) |
|
48 { |
|
49 if (aIID.equals(Components.interfaces.nsIWebProgressListener) || |
|
50 aIID.equals(Components.interfaces.nsISupportsWeakReference) || |
|
51 aIID.equals(Components.interfaces.nsISupports)) |
|
52 return this; |
|
53 throw Components.results.NS_NOINTERFACE; |
|
54 }, |
|
55 |
|
56 onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) |
|
57 { |
|
58 if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) |
|
59 { |
|
60 var editor = this.mEditor.getEditor(this.mEditor.contentWindow); |
|
61 if (editor) { |
|
62 this.mEditor.focus(); |
|
63 editor instanceof Components.interfaces.nsIHTMLEditor; |
|
64 editor.returnInParagraphCreatesNewParagraph = true; |
|
65 source = "<html><body><table><head></table></body></html>"; |
|
66 editor.rebuildDocumentFromSource(source); |
|
67 ok(true, "Don't crash when head appears after body"); |
|
68 source = "<html></head><head><body></body></html>"; |
|
69 editor.rebuildDocumentFromSource(source); |
|
70 ok(true, "Don't crash when /head appears before head"); |
|
71 SimpleTest.finish(); |
|
72 progress.removeProgressListener(this); |
|
73 } |
|
74 } |
|
75 |
|
76 }, |
|
77 |
|
78 |
|
79 onProgressChange : function(aWebProgress, aRequest, |
|
80 aCurSelfProgress, aMaxSelfProgress, |
|
81 aCurTotalProgress, aMaxTotalProgress) |
|
82 { |
|
83 }, |
|
84 |
|
85 onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags) |
|
86 { |
|
87 }, |
|
88 |
|
89 onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) |
|
90 { |
|
91 }, |
|
92 |
|
93 onSecurityChange : function(aWebProgress, aRequest, aState) |
|
94 { |
|
95 }, |
|
96 |
|
97 mEditor: null |
|
98 }; |
|
99 |
|
100 var progress, progressListener; |
|
101 |
|
102 function runTest() { |
|
103 var newEditorElement = document.getElementById("editor"); |
|
104 newEditorElement.makeEditable("html", true); |
|
105 var docShell = newEditorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).docShell; |
|
106 progress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress); |
|
107 progressListener = new EditorContentListener(newEditorElement); |
|
108 progress.addProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); |
|
109 newEditorElement.setAttribute("src", "data:text/html,"); |
|
110 } |
|
111 ]]> |
|
112 </script> |
|
113 </window> |