Bug 1271119 - Port test_bug646194.xul from chrome to mochitest; r=masayuki

MozReview-Commit-ID: Lx05BEKQiwO

--HG--
rename : editor/libeditor/tests/test_bug646194.xul => editor/libeditor/tests/test_bug646194.html
This commit is contained in:
Aryeh Gregor 2016-08-30 18:40:55 +03:00
Родитель 35558fd4e9
Коммит 7d842d8033
4 изменённых файлов: 39 добавлений и 64 удалений

Просмотреть файл

@ -10,7 +10,6 @@ skip-if = buildapp == 'mulet'
[test_bug607584.xul]
[test_bug616590.xul]
[test_bug636465.xul]
[test_bug646194.xul]
[test_bug780908.xul]
[test_bug1101392.html]
subsuite = clipboard

Просмотреть файл

@ -126,6 +126,7 @@ skip-if = e10s || os == 'android'
skip-if = android_version == '18' # bug 1147989
[test_bug641466.html]
[test_bug645914.html]
[test_bug646194.html]
[test_bug668599.html]
[test_bug674770-1.html]
subsuite = clipboard

Просмотреть файл

@ -0,0 +1,38 @@
<!doctype html>
<title>Mozilla Bug 646194</title>
<link rel=stylesheet href="/tests/SimpleTest/test.css">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=646194"
target="_blank">Mozilla Bug 646194</a>
<iframe id="i" src="data:text/html,&lt;div contenteditable=true id=t&gt;test me now&lt;/div&gt;"></iframe>
<script>
SimpleTest.expectAssertions(1);
function runTest() {
var i = document.getElementById("i");
i.focus();
var win = i.contentWindow;
var doc = i.contentDocument;
var t = doc.getElementById("t");
t.focus();
// put the caret at the end
win.getSelection().collapse(t.firstChild, 11);
// Simulate pression Option+Delete on Mac
// We do things this way because not every platform can invoke this
// command using the available key bindings.
SpecialPowers.doCommand(window, "cmd_wordPrevious");
SpecialPowers.doCommand(window, "cmd_wordPrevious");
SpecialPowers.doCommand(window, "cmd_deleteWordBackward");
SpecialPowers.doCommand(window, "cmd_deleteWordBackward");
// If we reach here, we haven't crashed. Phew!
// But let's check the value too, now that we're here.
is(t.textContent, "me now", "The command has worked correctly");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(runTest);
</script>

Просмотреть файл

@ -1,63 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin"
type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=646194
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Mozilla Bug 646194" onload="runTest();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=646194"
target="_blank">Mozilla Bug 646194</a>
<p/>
<iframe id="i" src="data:text/html,&lt;div contenteditable=true id=t&gt;test me now&lt;/div&gt;"/>
<p/>
<pre id="test">
</pre>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.expectAssertions(1);
function runTest() {
function doCommand(aCmd) {
var controller = top.document.commandDispatcher
.getControllerForCommand(aCmd);
ok((controller && controller.isCommandEnabled(aCmd)), "command available");
controller.doCommand(aCmd);
}
var i = document.getElementById("i");
i.focus();
var win = i.contentWindow;
var doc = i.contentDocument;
var t = doc.getElementById("t");
t.focus();
// put the caret at the end
win.getSelection().collapse(t.firstChild, 11);
// Simulate pression Option+Delete on Mac
// We do things this way because not every platform can invoke this
// command using the available key bindings.
doCommand("cmd_wordPrevious");
doCommand("cmd_wordPrevious");
doCommand("cmd_deleteWordBackward");
doCommand("cmd_deleteWordBackward");
// If we reach here, we haven't crashed. Phew!
// But let's check the value too, now that we're here.
is(t.textContent, "me now", "The command has worked correctly");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
]]>
</script>
</window>