2008-04-23 14:36:17 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=386782
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 386782</title>
|
2009-05-06 13:46:04 -07:00
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
2008-04-23 14:36:17 -07:00
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
// This tests if we can load a document whose root is in designMode,
|
|
|
|
// edit it, navigate to a new page, navigate back, still edit, and still
|
|
|
|
// undo/redo. Note that this is different from the case where the
|
|
|
|
// designMode document is in a frame inside the window, as this means
|
|
|
|
// the editable region is not in the root docshell (a less complicated case).
|
|
|
|
|
|
|
|
|
|
|
|
var gTests = [
|
|
|
|
{
|
2010-07-11 14:48:46 -07:00
|
|
|
// <html><body><p>designModeDocument</p></body></html>
|
|
|
|
url: "data:text/html;charset=utf-8,<html><body><p>designModeDocument</p></body></html>",
|
2008-04-23 14:36:17 -07:00
|
|
|
name: 'designModeNavigate',
|
2010-07-11 14:48:46 -07:00
|
|
|
onload: function(doc) doc.designMode = "on",
|
2008-04-23 14:36:17 -07:00
|
|
|
expectedBodyBeforeEdit: '<p>designModeDocument</p>',
|
|
|
|
expectedBodyAfterEdit: '<p>EDITED designModeDocument</p>',
|
|
|
|
expectedBodyAfterSecondEdit: '<p>EDITED TWICE designModeDocument</p>',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// <html><body contentEditable="true"><p>contentEditable</p></body></html>
|
2010-02-22 04:17:33 -08:00
|
|
|
url: 'data:text/html;charset=utf-8,<html><body contentEditable="true"><p>contentEditable</p></body></html>',
|
2008-04-23 14:36:17 -07:00
|
|
|
name: 'contentEditableNavigate',
|
|
|
|
expectedBodyBeforeEdit: '<br><p>contentEditable</p>',
|
|
|
|
expectedBodyAfterEdit: 'EDITED <br><p>contentEditable</p>',
|
|
|
|
expectedBodyAfterSecondEdit: 'EDITED TWICE <br><p>contentEditable</p>',
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
var gTestNum = -1;
|
|
|
|
var gTest = null;
|
|
|
|
|
|
|
|
window.onload = goNext();
|
|
|
|
|
|
|
|
function goNext() {
|
|
|
|
gTestNum++;
|
|
|
|
if (gTestNum >= gTests.length) {
|
|
|
|
SimpleTest.finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gTest = gTests[gTestNum];
|
2010-06-10 19:46:51 -07:00
|
|
|
gTest.window = window.open(gTest.url, gTest.name, "width=500,height=500");
|
|
|
|
gTest.window.addEventListener("load", function() {
|
2010-07-11 14:48:46 -07:00
|
|
|
if ("onload" in gTest) {
|
|
|
|
gTest.onload(gTest.window.document);
|
|
|
|
}
|
2010-06-10 19:46:51 -07:00
|
|
|
SimpleTest.waitForFocus(beginTest, gTest.window);
|
|
|
|
}, false);
|
2008-04-23 14:36:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function beginTest() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
gTest.window.document.body.focus();
|
|
|
|
|
|
|
|
// WARNING: If the following test fails, give the setTimeout() in the onload()
|
|
|
|
// a bit longer; the doc hasn't had enough time to setup its editor.
|
|
|
|
is(gTest.window.document.body.innerHTML, gTest.expectedBodyBeforeEdit, "Is doc setup yet");
|
|
|
|
|
|
|
|
sendChar('E', gTest.window.document.body);
|
|
|
|
sendChar('D', gTest.window.document.body);
|
|
|
|
sendChar('I', gTest.window.document.body);
|
|
|
|
sendChar('T', gTest.window.document.body);
|
|
|
|
sendChar('E', gTest.window.document.body);
|
|
|
|
sendChar('D', gTest.window.document.body);
|
|
|
|
sendChar(' ', gTest.window.document.body);
|
|
|
|
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Editing failed.");
|
|
|
|
|
|
|
|
gTest.window.location = 'data:text/html;charset=utf-8,SomeOtherDocument';
|
2010-06-10 19:46:51 -07:00
|
|
|
SimpleTest.waitForFocus(goBack, gTest.window);
|
2008-04-23 14:36:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function goBack() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
gTest.window.history.back();
|
2010-06-10 19:46:51 -07:00
|
|
|
setTimeout(function() {
|
|
|
|
SimpleTest.waitForFocus(checkStillEditable, gTest.window);
|
|
|
|
}, 0);
|
2008-04-23 14:36:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkStillEditable() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
|
|
|
|
// Check that the contents are correct.
|
|
|
|
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Edited contents still correct?");
|
|
|
|
|
|
|
|
// Check that we can undo/redo and the contents are correct.
|
|
|
|
gTest.window.document.execCommand("undo", false, null);
|
|
|
|
is(gTest.window.document.body.innerHTML, gTest.expectedBodyBeforeEdit, "Can we undo?");
|
|
|
|
|
|
|
|
gTest.window.document.execCommand("redo", false, null);
|
|
|
|
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Can we redo?");
|
|
|
|
|
|
|
|
// Check that we can still edit the page.
|
|
|
|
gTest.window.document.body.focus();
|
|
|
|
sendChar('T', gTest.window.document.body);
|
|
|
|
sendChar('W', gTest.window.document.body);
|
|
|
|
sendChar('I', gTest.window.document.body);
|
|
|
|
sendChar('C', gTest.window.document.body);
|
|
|
|
sendChar('E', gTest.window.document.body);
|
|
|
|
sendChar(' ', gTest.window.document.body);
|
|
|
|
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterSecondEdit, "Can we still edit?");
|
|
|
|
|
|
|
|
gTest.window.close();
|
|
|
|
goNext();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=386782">Mozilla Bug 386782</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 386782 **/
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|