4 https://bugzilla.mozilla.org/show_bug.cgi?id=386782
7 <title>Test for Bug
386782</title>
8 <script type=
"text/javascript" src=
"/MochiKit/packed.js"></script>
9 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <script type=
"text/javascript" src=
"/tests/SimpleTest/EventUtils.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
15 // This tests if we can load a document whose root is in designMode,
16 // edit it, navigate to a new page, navigate back, still edit, and still
17 // undo/redo. Note that this is different from the case where the
18 // designMode document is in a frame inside the window, as this means
19 // the editable region is not in the root docshell (a less complicated case).
24 // <html><body><p>designModeDocument</p></body></html>
25 url
: "data:text/html;charset=utf-8,<html><body><p>designModeDocument</p></body></html>",
26 name
: 'designModeNavigate',
27 onload: function(doc
) doc
.designMode
= "on",
28 expectedBodyBeforeEdit
: '<p>designModeDocument</p>',
29 expectedBodyAfterEdit
: '<p>EDITED designModeDocument</p>',
30 expectedBodyAfterSecondEdit
: '<p>EDITED TWICE designModeDocument</p>',
33 // <html><body contentEditable="true"><p>contentEditable</p></body></html>
34 url
: 'data:text/html;charset=utf-8,<html><body contentEditable="true"><p>contentEditable</p></body></html>',
35 name
: 'contentEditableNavigate',
36 expectedBodyBeforeEdit
: '<p>contentEditable</p>',
37 expectedBodyAfterEdit
: 'EDITED <br><p>contentEditable</p>',
38 expectedBodyAfterSecondEdit
: 'EDITED TWICE <br><p>contentEditable</p>',
45 window
.onload
= goNext();
49 if (gTestNum
>= gTests
.length
) {
53 gTest
= gTests
[gTestNum
];
54 gTest
.window
= window
.open(gTest
.url
, gTest
.name
, "width=500,height=500");
55 gTest
.window
.addEventListener("load", function() {
56 if ("onload" in gTest
) {
57 gTest
.onload(gTest
.window
.document
);
59 SimpleTest
.waitForFocus(beginTest
, gTest
.window
);
63 function beginTest() {
64 netscape
.security
.PrivilegeManager
.enablePrivilege("UniversalXPConnect");
65 gTest
.window
.document
.body
.focus();
67 // WARNING: If the following test fails, give the setTimeout() in the onload()
68 // a bit longer; the doc hasn't had enough time to setup its editor.
69 is(gTest
.window
.document
.body
.innerHTML
, gTest
.expectedBodyBeforeEdit
, "Is doc setup yet");
71 sendChar('E', gTest
.window
.document
.body
);
72 sendChar('D', gTest
.window
.document
.body
);
73 sendChar('I', gTest
.window
.document
.body
);
74 sendChar('T', gTest
.window
.document
.body
);
75 sendChar('E', gTest
.window
.document
.body
);
76 sendChar('D', gTest
.window
.document
.body
);
77 sendChar(' ', gTest
.window
.document
.body
);
78 is(gTest
.window
.document
.body
.innerHTML
, gTest
.expectedBodyAfterEdit
, "Editing failed.");
80 gTest
.window
.location
= 'data:text/html;charset=utf-8,SomeOtherDocument';
81 SimpleTest
.waitForFocus(goBack
, gTest
.window
);
85 netscape
.security
.PrivilegeManager
.enablePrivilege("UniversalXPConnect");
86 gTest
.window
.history
.back();
87 setTimeout(function() {
88 SimpleTest
.waitForFocus(checkStillEditable
, gTest
.window
);
92 function checkStillEditable() {
93 netscape
.security
.PrivilegeManager
.enablePrivilege("UniversalXPConnect");
95 // Check that the contents are correct.
96 is(gTest
.window
.document
.body
.innerHTML
, gTest
.expectedBodyAfterEdit
, "Edited contents still correct?");
98 // Check that we can undo/redo and the contents are correct.
99 gTest
.window
.document
.execCommand("undo", false, null);
100 is(gTest
.window
.document
.body
.innerHTML
, gTest
.expectedBodyBeforeEdit
, "Can we undo?");
102 gTest
.window
.document
.execCommand("redo", false, null);
103 is(gTest
.window
.document
.body
.innerHTML
, gTest
.expectedBodyAfterEdit
, "Can we redo?");
105 // Check that we can still edit the page.
106 gTest
.window
.document
.body
.focus();
107 sendChar('T', gTest
.window
.document
.body
);
108 sendChar('W', gTest
.window
.document
.body
);
109 sendChar('I', gTest
.window
.document
.body
);
110 sendChar('C', gTest
.window
.document
.body
);
111 sendChar('E', gTest
.window
.document
.body
);
112 sendChar(' ', gTest
.window
.document
.body
);
113 is(gTest
.window
.document
.body
.innerHTML
, gTest
.expectedBodyAfterSecondEdit
, "Can we still edit?");
115 gTest
.window
.close();
124 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=386782">Mozilla Bug
386782</a>
126 <div id=
"content" style=
"display: none">
130 <script class=
"testbody" type=
"text/javascript">
132 /** Test for Bug
386782 **/
134 SimpleTest.waitForExplicitFinish();