Bug 1489980 - Enable ESLint for editor/ - automatic fixes r=masayuki

These are all automatically generated by ESLint with the --fix option.

Depends on D5584

Differential Revision: https://phabricator.services.mozilla.com/D5585

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2018-09-13 07:58:19 +00:00
parent 3720c020c0
commit d5e3a6a9e5
132 changed files with 702 additions and 798 deletions

View file

@ -39,8 +39,7 @@ function onSpellCheck(editableElement, callback) {
// False is important here. Pass false so that the inline spell checker
// isn't created if it doesn't already exist.
var isc = editor.getInlineSpellChecker(false);
}
catch (err) {
} catch (err) {
// getInlineSpellChecker throws if spell checking is not enabled instead of
// just returning null, which seems kind of lame. (Spell checking is not
// enabled on Android.) The point here is only to determine whether spell
@ -77,4 +76,4 @@ function onSpellCheck(editableElement, callback) {
os.removeObserver(observe, SPELL_CHECK_ENDED_TOPIC);
callback();
}, 0, Ci.nsITimer.TYPE_REPEATING_SLACK);
};
}

View file

@ -32,13 +32,13 @@ var helperAppDlgPromise = new Promise(function(resolve) {
}
HelperAppLauncherDialog.prototype = {
show: function(aLauncher, aWindowContext, aReason) {
show(aLauncher, aWindowContext, aReason) {
ok(true, "Whether showing Dialog");
resolve();
registrar.unregisterFactory(MOCK_HELPERAPP_DIALOG_CID,
mockHelperAppService);
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIHelperAppLauncherDialog])
QueryInterface: ChromeUtils.generateQI([Ci.nsIHelperAppLauncherDialog]),
};
mockHelperAppService = XPCOMUtils._getFactory(HelperAppLauncherDialog);

View file

@ -20,13 +20,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=348497
/** Test for Bug 348497 **/
function doe() {
document.getElementById('testIframe').style.display = 'block';
document.getElementById('testIframe').contentDocument.designMode = 'on';
document.getElementById("testIframe").style.display = "block";
document.getElementById("testIframe").contentDocument.designMode = "on";
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doe);
addLoadEvent(function() { ok(true, "enabling designmode on an iframe onload does not crash Mozilla")});
addLoadEvent(function() { ok(true, "enabling designmode on an iframe onload does not crash Mozilla"); });
addLoadEvent(SimpleTest.finish);
</script>

View file

@ -12,10 +12,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=389350
function runTest() {
var e = document.getElementById("edit");
e.contentDocument.designMode='on';
e.style.display='block';
e.contentDocument.designMode = "on";
e.style.display = "block";
e.focus();
sendString('abc');
sendString("abc");
var expected = "<head></head><body>abc</body>";
var result = e.contentDocument.documentElement.innerHTML;
is(result, expected, "iframe with designmode on had incorrect content");

View file

@ -4,7 +4,7 @@ add_task(async function() {
const kPageURL = "http://example.org/browser/editor/libeditor/tests/bug527935.html";
await BrowserTestUtils.withNewTab({
gBrowser,
url: kPageURL
url: kPageURL,
}, async function(aBrowser) {
var popupShown = false;
function listener() {

View file

@ -4,7 +4,7 @@ add_task(async function() {
const kPageURL = "http://example.org/browser/editor/libeditor/tests/bug629172.html";
await BrowserTestUtils.withNewTab({
gBrowser,
url: kPageURL
url: kPageURL,
}, async function(aBrowser) {
await ContentTask.spawn(aBrowser, {}, async function() {
var window = content.window.wrappedJSObject;
@ -76,7 +76,7 @@ add_task(async function() {
await simulateCtrlShiftX(aBrowser);
await ContentTask.spawn(aBrowser, {initialDir}, function({initialDir}) {
var window = content.window.wrappedJSObject;
var expectedDir = initialDir == "ltr" ? "rtl" : "ltr"
var expectedDir = initialDir == "ltr" ? "rtl" : "ltr";
is(window.t.getAttribute("dir"), expectedDir,
"The dir attribute must be correctly updated");
is(window.inputEventCount, 1, "input event count must be 1 after");

View file

@ -1,5 +1,5 @@
<!DOCTYPE>
<script>
localStorage["clicked"] = "true";
localStorage.clicked = "true";
close();
</script>

View file

@ -2,20 +2,17 @@
<head>
<script type="text/javascript">
function is(aLeft, aRight, aMessage)
{
function is(aLeft, aRight, aMessage) {
window.opener.SimpleTest.is(aLeft, aRight, aMessage);
}
function unload()
{
function unload() {
window.opener.SimpleTest.finish();
}
function boom()
{
function boom() {
var root = document.documentElement;
while(root.firstChild) {
while (root.firstChild) {
root.firstChild.remove();
}
root.appendChild(document.createTextNode("Mozilla"));
@ -25,7 +22,7 @@ function boom()
root.appendChild(cespan);
try {
document.execCommand("selectAll", false, null);
} catch(e) { }
} catch (e) { }
is(window.getSelection().toString(), "Mozilla",
"The nodes are not selected");

View file

@ -67,7 +67,7 @@ SimpleTest.waitForFocus(async function() {
// left is abs positioned element's left + margin-left + border-left-width + 12.
// XXX Perhaps, we need to add border-left-width here if you add new test to have thick border.
const kPositionerX = 18
const kPositionerX = 18;
// top is abs positioned element's top + margin-top + border-top-width - 14.
// XXX Perhaps, we need to add border-top-width here if you add new test to have thick border.
const kPositionerY = -7;
@ -90,9 +90,9 @@ SimpleTest.waitForFocus(async function() {
isfuzzy(newRect.y, rect.y + aDeltaY, 1, description + "The top should be increased by " + aDeltaY + "pixels");
}
await testPositioner( 10, 10);
await testPositioner( 10, 10);
await testPositioner( 10, -10);
await testPositioner(-10, 10);
await testPositioner(-10, 10);
await testPositioner(-10, -10);
}

View file

@ -21,15 +21,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1026397
/** Test for Bug 1026397 **/
SimpleTest.waitForExplicitFinish();
function runTests()
{
function runTests() {
var input = document.getElementById("input");
input.focus();
function doTest(aMaxLength, aInitialValue, aCaretOffset,
aInsertString, aExpectedValueDuringComposition,
aExpectedValueAfterCompositionEnd, aAdditionalExplanation)
{
aExpectedValueAfterCompositionEnd, aAdditionalExplanation) {
input.value = aInitialValue;
var maxLengthStr = "";
if (aMaxLength >= 0) {
@ -51,10 +49,10 @@ function runTests()
{ "string": aInsertString,
"clauses":
[
{ "length": aInsertString.length, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
]
{ "length": aInsertString.length, "attr": COMPOSITION_ATTR_RAW_CLAUSE },
],
},
"caret": { "start": aInsertString.length, "length": 0 }
"caret": { "start": aInsertString.length, "length": 0 },
});
is(input.value, aExpectedValueDuringComposition,
"The value of input whose maxlength is " + maxLengthStr + " should be "

View file

@ -17,8 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1053048
const nsISelectionListener = SpecialPowers.Ci.nsISelectionListener;
function runTests()
{
function runTests() {
var textarea = SpecialPowers.wrap(document.getElementById("textarea"));
textarea.focus();
@ -27,12 +26,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1053048
var selectionListener = {
count: 0,
notifySelectionChanged: function (aDocument, aSelection, aReason)
{
ok(true, "selectionStart: " + textarea.selectionStart);
ok(true, "selectionEnd: " + textarea.selectionEnd);
this.count++;
}
notifySelectionChanged(aDocument, aSelection, aReason) {
ok(true, "selectionStart: " + textarea.selectionStart);
ok(true, "selectionEnd: " + textarea.selectionEnd);
this.count++;
},
};
// Move caret to the end of the textarea

View file

@ -30,8 +30,7 @@ SimpleTest.waitForExplicitFinish();
const kIsLinux = navigator.platform.indexOf("Linux") == 0;
function runTests()
{
function runTests() {
var editor0 = document.getElementById("editor0");
var editor1 = document.getElementById("editor1");
var editor2 = document.getElementById("editor2");

View file

@ -47,8 +47,8 @@ SimpleTest.waitForFocus(function() {
SimpleTest.finish();
});
},0);
},0);
}, 0);
}, 0);
});
});

View file

@ -14,8 +14,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1101392
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests);
function runCopyCommand(element, compareText, nextTest)
{
function runCopyCommand(element, compareText, nextTest) {
element.focus();
var expectedEndpoint, sel;
if (element.localName == "textarea") {
@ -48,20 +47,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1101392
checkCollapse, checkCollapse);
}
function testDiv()
{
function testDiv() {
var content = document.getElementById("content");
runCopyCommand(content, 'abc', testTextarea);
runCopyCommand(content, "abc", testTextarea);
}
function testTextarea()
{
function testTextarea() {
var textarea = document.getElementById("textarea");
runCopyCommand(textarea, 'def', SimpleTest.finish);
runCopyCommand(textarea, "def", SimpleTest.finish);
}
function runTests()
{
function runTests() {
testDiv();
}
</script>

View file

@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1102906
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus( () => {
let content = document.getElementById("content");
let drag = document.getElementById("drag")
let drag = document.getElementById("drag");
let selection = window.getSelection();
/* Perform drag-and-drop for an arbitrary content. The caret should be at

View file

@ -43,10 +43,10 @@ SimpleTest.waitForFocus(function() {
{ "string": composingString,
"clauses":
[
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
]
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE },
],
},
"caret": { "start": 1, "length": 0 }
"caret": { "start": 1, "length": 0 },
});
synthesizeComposition({ type: "compositioncommitasis" });
is(t.value, "foo\u306B\nbar", "Correct value after composition");

View file

@ -11,7 +11,7 @@ getSelection().collapse(div.firstChild, 2);
try {
document.execCommand("inserttext", false, "\n");
ok(true, "No exception thrown");
} catch(e) {
} catch (e) {
ok(false, "Exception: " + e);
}
</script>

View file

@ -11,7 +11,7 @@ function runTest() {
SpecialPowers.setCommandNode(window, document.getElementById("i"));
SpecialPowers.doCommand(window, "cmd_copyImageContents");
var e = document.getElementById('i1');
var e = document.getElementById("i1");
var doc = e.contentDocument;
doc.designMode = "on";
doc.defaultView.focus();

View file

@ -15,12 +15,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1153237
// Avoid platform selection differences
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({
"set": [["layout.word_select.eat_space_to_next_word", true]]
"set": [["layout.word_select.eat_space_to_next_word", true]],
}, runTests);
});
function runTests()
{
function runTests() {
var element = document.getElementById("editor");
var sel = window.getSelection();

View file

@ -47,8 +47,8 @@ SimpleTest.waitForFocus(function() {
SimpleTest.finish();
});
},0);
},0);
}, 0);
}, 0);
});
});

View file

@ -21,19 +21,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1162952
/** Test for Bug 1162952 **/
var userCallbackRun = false;
document.addEventListener('keydown', function() {
document.addEventListener("keydown", function() {
// During a user callback, the commands should be enabled
userCallbackRun = true;
is(true, document.queryCommandEnabled('cut'));
is(true, document.queryCommandEnabled('copy'));
is(true, document.queryCommandEnabled("cut"));
is(true, document.queryCommandEnabled("copy"));
});
// Otherwise, they should be disabled
is(false, document.queryCommandEnabled('cut'));
is(false, document.queryCommandEnabled('copy'));
is(false, document.queryCommandEnabled("cut"));
is(false, document.queryCommandEnabled("copy"));
// Fire a user callback
sendString('A');
sendString("A");
ok(userCallbackRun, "User callback should've been run");

View file

@ -32,16 +32,16 @@ SimpleTest.waitForFocus(function() {
{ "string": "\u3042",
"clauses":
[
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
]
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE },
],
},
"caret": { "start": 1, "length": 0 }
"caret": { "start": 1, "length": 0 },
});
ok(isThereIMESelection(), "There should be IME selection");
var compositionEnd = false;
editor.addEventListener("compositionend", function () { compositionEnd = true; }, true);
editor.addEventListener("compositionend", function() { compositionEnd = true; }, true);
synthesizeMouseAtCenter(span, {});
@ -51,8 +51,7 @@ SimpleTest.waitForFocus(function() {
SimpleTest.finish();
});
function isThereIMESelection()
{
function isThereIMESelection() {
var selCon = SpecialPowers.wrap(window).
docShell.
editingSession.
@ -62,7 +61,7 @@ function isThereIMESelection()
SpecialPowers.Ci.nsISelectionController.SELECTION_IME_RAWINPUT,
SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDRAWTEXT,
SpecialPowers.Ci.nsISelectionController.SELECTION_IME_CONVERTEDTEXT,
SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDCONVERTEDTEXT
SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDCONVERTEDTEXT,
];
for (var i = 0; i < kIMESelections.length; i++) {
var sel = selCon.getSelection(kIMESelections[i]);

View file

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1230473
<script type="application/javascript">
/** Test for Bug 1230473 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(()=>{
SimpleTest.waitForFocus(() => {
function runTest(aEditor) {
function committer() {
aEditor.blur();
@ -31,7 +31,7 @@ SimpleTest.waitForFocus(()=>{
return isNSEditableElement() ? aEditor.value : aEditor.textContent;
}
function isComposing() {
return isNSEditableElement() ? SpecialPowers.wrap(aEditor)
return isNSEditableElement() ? SpecialPowers.wrap(aEditor)
.editor
.composing :
SpecialPowers.wrap(window)

View file

@ -15,12 +15,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1248185
// Avoid platform selection differences
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({
"set": [["layout.word_select.eat_space_to_next_word", true]]
"set": [["layout.word_select.eat_space_to_next_word", true]],
}, runTests);
});
function runTests()
{
function runTests() {
var editor = document.querySelector("#test");
editor.focus();

View file

@ -21,8 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1250010
<script class="testbody" type="application/javascript">
function getImageDataURI()
{
function getImageDataURI() {
return document.getElementsByTagName("img")[0].getAttribute("src");
}

View file

@ -18,23 +18,23 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1270235
<div id="edit1" contenteditable="true"><p>AB</p></div>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(()=>{
let element = document.getElementById('edit1');
SimpleTest.waitForFocus(() => {
let element = document.getElementById("edit1");
element.focus();
let textNode = element.firstChild.firstChild;
let node = textNode.splitText(0);
node.parentNode.removeChild(node);
ok(!node.parentNode, 'parent must be null');
ok(!node.parentNode, "parent must be null");
let newRange = document.createRange();
let newRange = document.createRange();
newRange.setStart(node, 0);
newRange.setEnd(node, 0);
let selection = document.getSelection();
selection.removeAllRanges();
selection.addRange(newRange);
ok(selection.isCollapsed, 'isCollapsed must be true');
ok(selection.isCollapsed, "isCollapsed must be true");
// Don't crash by user input
sendString("X");

View file

@ -32,10 +32,10 @@ SimpleTest.waitForFocus(function() {
composition: {
string: "DEF",
clauses: [
{ length: 3, attr: COMPOSITION_ATTR_RAW_CLAUSE }
]
{ length: 3, attr: COMPOSITION_ATTR_RAW_CLAUSE },
],
},
caret: { start: 3, length: 0 }
caret: { start: 3, length: 0 },
});
ok(elm.textContent == "ABCDEF", "composing text should be set");
@ -44,10 +44,10 @@ SimpleTest.waitForFocus(function() {
composition: {
string: "GHI",
clauses: [
{ length: 3, attr: COMPOSITION_ATTR_CONVERTED_CLAUSE }
]
{ length: 3, attr: COMPOSITION_ATTR_CONVERTED_CLAUSE },
],
},
caret: { start: 0, length: 0 }
caret: { start: 0, length: 0 },
});
ok(elm.textContent == "ABCGHI", "composing text should be replaced");
@ -56,10 +56,10 @@ SimpleTest.waitForFocus(function() {
composition: {
string: "JKL",
clauses: [
{ length: 3, attr: COMPOSITION_ATTR_CONVERTED_CLAUSE }
]
{ length: 3, attr: COMPOSITION_ATTR_CONVERTED_CLAUSE },
],
},
caret: { start: 0, length: 0 }
caret: { start: 0, length: 0 },
});
ok(elm.textContent == "ABCJKL", "composing text should be replaced");
@ -68,10 +68,10 @@ SimpleTest.waitForFocus(function() {
composition: {
string: "MNO",
clauses: [
{ length: 3, attr: COMPOSITION_ATTR_CONVERTED_CLAUSE }
]
{ length: 3, attr: COMPOSITION_ATTR_CONVERTED_CLAUSE },
],
},
caret: { start: 1, length: 0 }
caret: { start: 1, length: 0 },
});
ok(elm.textContent == "ABCMNO", "composing text should be replaced");

View file

@ -16,7 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1315065
<script type="application/javascript">
/** Test for Bug 1315065 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(()=>{
SimpleTest.waitForFocus(() => {
var editor = document.getElementsByTagName("div")[0];
function initForBackspace(aSelectionCollapsedTo /* = 0 ~ 3 */) {
editor.innerHTML = "<p id='p'>abc<br></p>";

View file

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1316302
<script type="application/javascript">
/** Test for Bug 1316302 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(()=>{
SimpleTest.waitForFocus(() => {
var editor = document.getElementsByTagName("div")[0];
var blockquote = document.getElementsByTagName("blockquote")[0];
var selection = window.getSelection();

View file

@ -17,8 +17,7 @@
var outerEditor = document.getElementById("outerEditor");
function runTests()
{
function runTests() {
outerEditor.focus();
is(document.activeElement, outerEditor,
"outerEditor should have focus");

View file

@ -55,7 +55,7 @@ var tests = [
"<span>&gt; mailcite<br></span>x<br>" ],
// No <br> at the end to simulate prior deletion to the end of the quote.
[ "<span _moz_quote=true>&gt; mailcite</span>", 10,
"<span>&gt; mailcite</span><br>x<br>" ]
"<span>&gt; mailcite</span><br>x<br>" ],
];
/** Test for Bug 1330796 **/

View file

@ -26,20 +26,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=795418
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var iframe = document.querySelector("iframe");
iframe.contentDocument.designMode='on';
iframe.contentDocument.designMode = "on";
iframe.contentWindow.addEventListener('keypress', function() {
iframe.style.display='none';
iframe.contentWindow.addEventListener("keypress", function() {
iframe.style.display = "none";
document.body.offsetHeight;
ok(true, "did not crash");
SimpleTest.finish();
});
iframe.contentWindow.addEventListener('click', function() {
synthesizeKey('a', {}, iframe.contentWindow);
iframe.contentWindow.addEventListener("click", function() {
synthesizeKey("a", {}, iframe.contentWindow);
});
synthesizeMouse(iframe,20,20,{})
synthesizeMouse(iframe, 20, 20, {});
});
</script>

View file

@ -25,53 +25,53 @@ SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
var input = document.getElementById("input");
var inputcontainer = document.getElementById('input-container');
input.setAttribute('maxlength', 2);
inputcontainer.style.display = 'block';
var inputcontainer = document.getElementById("input-container");
input.setAttribute("maxlength", 2);
inputcontainer.style.display = "block";
input.focus();
sendString("123");
is(input.value, '12', 'value should be 12 with maxlength = 2');
is(input.value, "12", "value should be 12 with maxlength = 2");
input.value = '';
inputcontainer.style.display = 'none';
input.value = "";
inputcontainer.style.display = "none";
window.setTimeout(() => {
input.setAttribute('maxlength', 4);
inputcontainer.style.display = 'block';
input.setAttribute("maxlength", 4);
inputcontainer.style.display = "block";
input.focus();
sendString("45678");
is(input.value, '4567', 'value should be 4567 with maxlength = 4');
is(input.value, "4567", "value should be 4567 with maxlength = 4");
inputcontainer.style.display = 'none';
inputcontainer.style.display = "none";
window.setTimeout(() => {
input.setAttribute('maxlength', 2);
inputcontainer.style.display = 'block';
input.setAttribute("maxlength", 2);
inputcontainer.style.display = "block";
input.focus();
sendString("12");
todo_is(input.value, '45', 'value should be 45 with maxlength = 2');
todo_is(input.value, "45", "value should be 45 with maxlength = 2");
input.value = '';
inputcontainer.style.display = 'none';
input.value = "";
inputcontainer.style.display = "none";
window.setTimeout(() => {
input.removeAttribute('maxlength');
inputcontainer.style.display = 'block';
input.removeAttribute("maxlength");
inputcontainer.style.display = "block";
input.focus();
sendString("12345678");
is(input.value, '12345678', 'value should be 12345678 without maxlength');
is(input.value, "12345678", "value should be 12345678 without maxlength");
SimpleTest.finish();
}, 0);

View file

@ -31,25 +31,25 @@ SimpleTest.waitForFocus(() => {
// Enable undo because this is user input
SpecialPowers.wrap(input).setUserInput("");
is(input.value, "", "value is empty");
ok(controller.isCommandEnabled('cmd_undo'),
ok(controller.isCommandEnabled("cmd_undo"),
"Undo is enabled by same empty string");
SpecialPowers.wrap(input).setUserInput("ABC");
is(input.value, "ABC", "value is ABC");
ok(controller.isCommandEnabled('cmd_undo'), "Undo is enabled by a string");
ok(controller.isCommandEnabled("cmd_undo"), "Undo is enabled by a string");
SpecialPowers.wrap(input).setUserInput("ABC");
is(input.value, "ABC", "value is ABC");
ok(controller.isCommandEnabled('cmd_undo'), "Undo is enabled by same string");
ok(controller.isCommandEnabled("cmd_undo"), "Undo is enabled by same string");
SpecialPowers.wrap(input).setUserInput("DEF");
is(input.value, "DEF", "value is DEF");
ok(controller.isCommandEnabled('cmd_undo'),
ok(controller.isCommandEnabled("cmd_undo"),
"Undo is enabled by different string");
SpecialPowers.wrap(input).setUserInput("");
is(input.value, "", "value is empty");
ok(controller.isCommandEnabled('cmd_undo'),
ok(controller.isCommandEnabled("cmd_undo"),
"Undo is enabled by empty string");
// disable undo because this is by script
@ -57,38 +57,38 @@ SimpleTest.waitForFocus(() => {
// But Edge and Chrome still turn on undo when setting empty value from
// empty value. So we are same behaviour for this case.
input.value = "";
is (input.value, "", "value is empty");
ok(controller.isCommandEnabled('cmd_undo'),
is(input.value, "", "value is empty");
ok(controller.isCommandEnabled("cmd_undo"),
"Undo is still enabled by same empty string");
input.value = "ABC";
is(input.value, "ABC", "value is ABC");
ok(!controller.isCommandEnabled('cmd_undo'), "Undo is disabled by a string");
ok(!controller.isCommandEnabled("cmd_undo"), "Undo is disabled by a string");
// When setting same value by script, all browsers (Edge, Safari and Chrome)
// keep undo state.
input.value = "";
SpecialPowers.wrap(input).setUserInput("ABC");
ok(controller.isCommandEnabled('cmd_undo'), "Undo is enabled");
ok(controller.isCommandEnabled("cmd_undo"), "Undo is enabled");
input.value = "ABC";
is(input.value, "ABC", "value is ABC");
ok(controller.isCommandEnabled('cmd_undo'),
ok(controller.isCommandEnabled("cmd_undo"),
"Undo is still enabled by same string");
input.value = "";
SpecialPowers.wrap(input).setUserInput("ABC");
ok(controller.isCommandEnabled('cmd_undo'), "Undo is enabled");
ok(controller.isCommandEnabled("cmd_undo"), "Undo is enabled");
input.value = "DEF";
is(input.value, "DEF", "value is DEF");
ok(!controller.isCommandEnabled('cmd_undo'),
ok(!controller.isCommandEnabled("cmd_undo"),
"Undo is disabled by different string");
input.value = "";
SpecialPowers.wrap(input).setUserInput("DEF");
ok(controller.isCommandEnabled('cmd_undo'), "Undo is enabled");
ok(controller.isCommandEnabled("cmd_undo"), "Undo is enabled");
input.value = "";
is(input.value, "", "value is empty");
ok(!controller.isCommandEnabled('cmd_undo'),
ok(!controller.isCommandEnabled("cmd_undo"),
"Undo is disabled by empty string");
SimpleTest.finish();

View file

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi=id=1361008
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
document.execCommand("defaultparagraphseparator", false, "div")
document.execCommand("defaultparagraphseparator", false, "div");
let edit1 = document.getElementById("edit1");
edit1.focus();
let selection = window.getSelection();
@ -31,14 +31,14 @@ SimpleTest.waitForFocus(() => {
sendString("AB");
synthesizeKey("KEY_Enter");
// count <div> element into contenteidable
is(edit1.getElementsByTagName('div').length, 2,
is(edit1.getElementsByTagName("div").length, 2,
"DIV element should be 2 children");
is(edit1.getElementsByTagName('div')[0].innerText,
is(edit1.getElementsByTagName("div")[0].innerText,
"AB", "AB should be in 1st DIV element");
is(edit1.getElementsByTagName('div')[1].innerHTML,
is(edit1.getElementsByTagName("div")[1].innerHTML,
"<br>", "BR element should be in 2nd DIV element");
document.execCommand("defaultparagraphseparator", false, "p")
document.execCommand("defaultparagraphseparator", false, "p");
let edit2 = document.getElementById("edit2");
edit2.focus();
selection.collapse(edit2, 0);
@ -46,11 +46,11 @@ SimpleTest.waitForFocus(() => {
sendString("AB");
synthesizeKey("KEY_Enter");
is(edit2.getElementsByTagName('p').length, 2,
is(edit2.getElementsByTagName("p").length, 2,
"P element should be 2 children");
is(edit2.getElementsByTagName('p')[0].innerText,
is(edit2.getElementsByTagName("p")[0].innerText,
"AB", "AB should be in 1st P element");
is(edit2.getElementsByTagName('p')[1].innerHTML,
is(edit2.getElementsByTagName("p")[1].innerHTML,
"<br>", "BR element should be into 2nd P element");
SimpleTest.finish();

View file

@ -17,14 +17,14 @@
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
var strike = document.createElement('strike');
var strike = document.createElement("strike");
strike.contentEditable = true;
document.documentElement.appendChild(strike);
var textarea = document.createElement('textarea');
var textarea = document.createElement("textarea");
document.documentElement.appendChild(textarea);
var h5 = document.createElement('h5');
var h5 = document.createElement("h5");
strike.appendChild(h5);
textarea.setCustomValidity("A");

View file

@ -22,7 +22,7 @@ SimpleTest.waitForFocus(() => {
let editor = SpecialPowers.wrap(textarea).editor;
let spellChecker =
SpecialPowers.Cc['@mozilla.org/editor/editorspellchecker;1']
SpecialPowers.Cc["@mozilla.org/editor/editorspellchecker;1"]
.createInstance(SpecialPowers.Ci.nsIEditorSpellCheck);
spellChecker.InitSpellChecker(editor, false);

View file

@ -26,8 +26,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1394758
/** Test for Bug 611182 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var editable = document.getElementById('editable');
var span = document.getElementById('span');
var editable = document.getElementById("editable");
var span = document.getElementById("span");
var beforeSpan = span.textContent;
editable.focus();

View file

@ -28,7 +28,7 @@ SimpleTest.waitForFocus(function() {
var editor = document.getElementById("editor");
editor.focus();
selection.collapse(editor, 0);
document.execCommand('insertText', false, 'A');
document.execCommand("insertText", false, "A");
is(editor.firstChild.textContent, "A",
"'A' should be inserted at start of the editor");
is(editor.firstChild.nextSibling.tagName, "SELECT",

View file

@ -45,7 +45,7 @@ SimpleTest.waitForFocus(function() {
editor.addEventListener("DOMCharacterDataModified", onCharacterDataModified, { once: true });
editor.focus();
selection.selectAllChildren(document.getElementById("inline"));
document.execCommand('insertHTML', false, 'text');
document.execCommand("insertHTML", false, "text");
// This expected result is just same as the result of Chrome.
// If the spec says this is wrong, feel free to change this result.
todo_is(editor.innerHTML, "\n<!-- --><span id=\"inline\">text</span>",

View file

@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=290026
SimpleTest.waitForExplicitFinish();
var editor = document.getElementById("editor");
editor.innerHTML = '<p></p><ul><li>Item 1</li><li>Item 2</li></ul><p></p>';
editor.innerHTML = "<p></p><ul><li>Item 1</li><li>Item 2</li></ul><p></p>";
editor.focus();
addLoadEvent(function() {

View file

@ -38,7 +38,7 @@ addLoadEvent(function() {
var expected = '<ul style="margin-left: 40px;"><li>Item 1</li><ul><li>Item 2</li><li>Item 3</li></ul><li>Item 4</li></ul>';
is(editor.innerHTML, expected, "indenting part of an already indented bulleted list");
document.execCommand("outdent", false, false);
is(editor.innerHTML, original, "outdenting the partially indented part of an already indented bulleted list");
is(editor.innerHTML, original, "outdenting the partially indented part of an already indented bulleted list");
// done
SimpleTest.finish();

View file

@ -40,7 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=318065
is(this.value, expectedValues[step], messages[step]);
step++;
if (step == expectedValues.length) {
this.removeEventListener("input", onInput);
this.removeEventListener("input", onInput);
SimpleTest.finish();
}
}

View file

@ -21,7 +21,7 @@ SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
let input = document.getElementById("input1");
input.value = "ABC DEF"
input.value = "ABC DEF";
input.focus();
input.setSelectionRange(4, 7, "backward");
synthesizeKey("KEY_Backspace");

View file

@ -26,7 +26,7 @@ addLoadEvent(runTest);
var gMisspeltWords;
function getEdit() {
return document.getElementById('edit');
return document.getElementById("edit");
}
function editDoc() {

View file

@ -25,8 +25,7 @@ function runTests() {
var win = document.getElementById("testIframe").contentWindow;
var doc = document.getElementById("testIframe").contentDocument;
function testFormatBlock(tag, withAngleBrackets, shouldSucceed)
{
function testFormatBlock(tag, withAngleBrackets, shouldSucceed) {
win.getSelection().selectAllChildren(doc.body.firstChild);
doc.execCommand("FormatBlock", false,
withAngleBrackets ? tag : "<" + tag + ">");
@ -34,16 +33,14 @@ function runTests() {
if (shouldSucceed && (tag == "dd" || tag == "dt")) {
is(doc.body.firstChild.tagName, "DL", "tag was changed");
resultNode = doc.body.firstChild.firstChild;
}
else {
} else {
resultNode = doc.body.firstChild;
}
is(resultNode.tagName, shouldSucceed ? tag.toUpperCase() : "P", "tag was changed");
}
function formatBlockTests(tags, shouldSucceed)
{
function formatBlockTests(tags, shouldSucceed) {
var html = "<p>Content</p>";
for (var i = 0; i < tags.length; ++i) {
var tag = tags[i];

View file

@ -56,7 +56,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["underline", "true"],
["undo", "false"],
["unlink", "true"],
["not-a-command", "false"]
["not-a-command", "false"],
];
var commandIndetermResults = [
@ -85,7 +85,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["justifyleft", "false"],
["justifyright", "false"],
["outdent", "false"],
//["paste", "false"],
// ["paste", "false"],
["redo", "false"],
["removeformat", "false"],
["selectall", "false"],
@ -96,9 +96,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["underline", "false"],
["undo", "false"],
["unlink", "false"],
["not-a-command", "false"]
["not-a-command", "false"],
];
var commandStateResults = [
["contentReadOnly", "false"],
["copy", "false"],
@ -125,7 +125,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["justifyleft", "true"],
["justifyright", "false"],
["outdent", "false"],
//["paste", "false"],
// ["paste", "false"],
["redo", "false"],
["removeformat", "false"],
["selectall", "false"],
@ -136,9 +136,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["underline", "false"],
["undo", "false"],
["unlink", "false"],
["not-a-command", "false"]
["not-a-command", "false"],
];
var commandValueResults = [
["contentReadOnly", ""],
["copy", ""],
@ -165,7 +165,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["justifyleft", "left"],
["justifyright", "left"],
["outdent", ""],
//["paste", ""],
// ["paste", ""],
["redo", ""],
["removeformat", ""],
["selectall", ""],
@ -178,14 +178,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["unlink", ""],
["not-a-command", ""],
];
function callQueryCommandEnabled(cmdName) {
var result;
try {
result = '' + document.queryCommandEnabled( cmdName );
} catch( error ) {
result = 'name' in error ? error.name : 'exception';
result = "" + document.queryCommandEnabled( cmdName );
} catch ( error ) {
result = "name" in error ? error.name : "exception";
}
return result;
}
@ -193,19 +193,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
function callQueryCommandIndeterm(cmdName) {
var result;
try {
result = '' + document.queryCommandIndeterm( cmdName );
} catch( error ) {
result = 'name' in error ? error.name : 'exception';
result = "" + document.queryCommandIndeterm( cmdName );
} catch ( error ) {
result = "name" in error ? error.name : "exception";
}
return result;
}
function callQueryCommandState(cmdName) {
var result;
try {
result = '' + document.queryCommandState( cmdName );
} catch( error ) {
result = 'name' in error ? error.name : 'exception';
result = "" + document.queryCommandState( cmdName );
} catch ( error ) {
result = "name" in error ? error.name : "exception";
}
return result;
}
@ -213,33 +213,33 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
function callQueryCommandValue(cmdName) {
var result;
try {
result = '' + document.queryCommandValue( cmdName );
} catch( error ) {
result = 'name' in error ? error.name : 'exception';
result = "" + document.queryCommandValue( cmdName );
} catch ( error ) {
result = "name" in error ? error.name : "exception";
}
return result;
return result;
}
function testQueryCommand(expectedResults, fun, funName) {
for (i=0; i<expectedResults.length; i++) {
for (i = 0; i < expectedResults.length; i++) {
var commandName = expectedResults[i][0];
var expectedResult = expectedResults[i][1];
var result = fun(commandName);
ok(result == expectedResult, funName + '('+commandName+') result=' +result+ ' expected=' + expectedResult);
ok(result == expectedResult, funName + "(" + commandName + ") result=" + result + " expected=" + expectedResult);
}
}
function runTests() {
document.designMode='on';
document.designMode = "on";
window.getSelection().collapse(document.body, 0);
testQueryCommand(commandEnabledResults, callQueryCommandEnabled, "queryCommandEnabled");
testQueryCommand(commandIndetermResults, callQueryCommandIndeterm, "queryCommandIndeterm");
testQueryCommand(commandStateResults, callQueryCommandState, "queryCommandState");
testQueryCommand(commandValueResults, callQueryCommandValue, "queryCommandValue");
document.designMode='off';
document.designMode = "off";
SimpleTest.finish();
}
window.onload = runTests;
SimpleTest.waitForExplicitFinish();

View file

@ -18,25 +18,21 @@
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests);
function runTests()
{
function runTests() {
var container = document.getElementById("display");
function reset()
{
function reset() {
document.execCommand("Undo", false, null);
}
var selection = window.getSelection();
function moveCaretToStartOf(aEditor)
{
function moveCaretToStartOf(aEditor) {
selection.selectAllChildren(aEditor);
selection.collapseToStart();
}
function moveCaretToEndOf(aEditor)
{
function moveCaretToEndOf(aEditor) {
selection.selectAllChildren(aEditor);
selection.collapseToEnd();
}

View file

@ -31,14 +31,14 @@ function resetSelection() {
}
function runTest() {
var rightClickDown = {type: 'mousedown', button: 2},
rightClickUp = {type: 'mouseup', button: 2},
singleClickDown = {type: 'mousedown', button: 0},
singleClickUp = {type: 'mouseup', button: 0};
var rightClickDown = {type: "mousedown", button: 2},
rightClickUp = {type: "mouseup", button: 2},
singleClickDown = {type: "mousedown", button: 0},
singleClickUp = {type: "mouseup", button: 0};
var selection = window.getSelection();
var div = document.getElementById('display');
var img = document.getElementById('img');
var div = document.getElementById("display");
var img = document.getElementById("img");
var divRect = div.getBoundingClientRect();
var imgselected;

View file

@ -40,7 +40,7 @@ function test() {
synthesizeKey("KEY_Backspace");
// For some reason this test fails if the separator is not "br"
}, () => document.queryCommandValue("defaultParagraphSeparator") == "br"
? undefined : " A; B ; C "],
? undefined : " A; B ; C "],
["adding shift-returns", () => {
getSelection().collapse(edit.firstChild, 0);
synthesizeKey("KEY_ArrowRight");
@ -57,7 +57,7 @@ function test() {
.forEach(item => {
var cmd = Array.isArray(item) ? item[0] : item;
var param = Array.isArray(item) ? item[1] : "";
tests.push([cmd, () => { document.execCommand(cmd, false, param) }]);
tests.push([cmd, () => { document.execCommand(cmd, false, param); }]);
});
// These are all TODO -- they don't move the non-editable elements
[
@ -74,15 +74,15 @@ function test() {
["fontsize", "1"],
"justifyright",
"justifycenter",
"justifyfull"
"justifyfull",
]
.forEach(item => {
var cmd = Array.isArray(item) ? item[0] : item;
var param = Array.isArray(item) ? item[1] : "";
tests.push([cmd, () => { document.execCommand(cmd, false, param) },
tests.push([cmd, () => { document.execCommand(cmd, false, param); },
" A ; ; BC "]);
});
tests.push(["indent", () => { document.execCommand("indent") },
tests.push(["indent", () => { document.execCommand("indent"); },
" ; ; ABC"]);
tests.forEach(arr => {
["div", "br", "p"].forEach(sep => {

View file

@ -29,7 +29,7 @@ addLoadEvent(runTest);
var gMisspeltWords = [];
function getEdit() {
return document.getElementById('edit');
return document.getElementById("edit");
}
function editDoc() {
@ -46,8 +46,8 @@ function getEditor() {
function runTest() {
editDoc().designMode = "on";
setTimeout(function() { addWords(100); }, 0);
}
}
function addWords(aLimit) {
if (aLimit == 0) {
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
@ -56,10 +56,10 @@ function addWords(aLimit) {
return;
}
getEdit().focus();
sendString('aa OK ');
sendString("aa OK ");
gMisspeltWords.push("aa");
onSpellCheck(editDoc(), function() {
addWords(aLimit-1);
addWords(aLimit - 1);
});
}
</script>

View file

@ -45,14 +45,14 @@ function split(element, caretPos, nbKeyPresses) {
pos = 0;
break;
case CARET_MIDDLE:
pos = Math.floor(len/2);
pos = Math.floor(len / 2);
break;
case CARET_END:
pos = len;
break;
}
sel.collapse(element.firstChild, pos);
// simulates a [Return] keypress
for (var i = 0; i < nbKeyPresses; i++)
synthesizeKey("KEY_Enter");
@ -85,30 +85,30 @@ function runTests() {
// beginning of selection: split current node
split(header, CARET_BEGIN, 1);
ok(SameTypeAsPreviousSibling(header),
"Pressing [Return] at the beginning of a header " +
"Pressing [Return] at the beginning of a header " +
"should create another header.");
split(ulItem, CARET_BEGIN, 2);
ok(SameTypeAsPreviousSibling(ulItem),
"Pressing [Return] at the beginning of an unordered list item " +
"Pressing [Return] at the beginning of an unordered list item " +
"should create another list item.");
split(olItem, CARET_BEGIN, 2);
ok(SameTypeAsPreviousSibling(olItem),
"Pressing [Return] at the beginning of an ordered list item " +
"Pressing [Return] at the beginning of an ordered list item " +
"should create another list item.");
undo(3);
// middle of selection: split current node
split(header, CARET_MIDDLE, 1);
ok(SameTypeAsPreviousSibling(header),
"Pressing [Return] at the middle of a header " +
"Pressing [Return] at the middle of a header " +
"should create another header.");
split(ulItem, CARET_MIDDLE, 2);
ok(SameTypeAsPreviousSibling(ulItem),
"Pressing [Return] at the middle of an unordered list item " +
"Pressing [Return] at the middle of an unordered list item " +
"should create another list item.");
split(olItem, CARET_MIDDLE, 2);
ok(SameTypeAsPreviousSibling(olItem),
"Pressing [Return] at the middle of an ordered list item " +
"Pressing [Return] at the middle of an ordered list item " +
"should create another list item.");
undo(3);

View file

@ -17,7 +17,7 @@ function runTest() {
function setupIframe(id) {
var e = document.getElementById(id);
var doc = e.contentDocument;
doc.body.innerHTML = String.fromCharCode(10)+'<span id="' + id + '_span" style="border:1px solid blue" contenteditable="true">X</span>'+String.fromCharCode(10);
doc.body.innerHTML = String.fromCharCode(10) + '<span id="' + id + '_span" style="border:1px solid blue" contenteditable="true">X</span>' + String.fromCharCode(10);
e = doc.getElementById(id + "_span");
e.focus();
return e;
@ -54,7 +54,7 @@ function runTest() {
sendKey("right");
sendChar(" ");
is(e.parentNode.childNodes[2].nodeValue, before, msg + " with id=" + e.id);
is(e.innerHTML, "X" + (e.tagName=="SPAN" ? "&nbsp;" : " <br>"), msg + " with id=" + e.id);
is(e.innerHTML, "X" + (e.tagName == "SPAN" ? "&nbsp;" : " <br>"), msg + " with id=" + e.id);
}
test_begin_bs(select("t1"));
@ -63,10 +63,10 @@ function runTest() {
test_end_space(select("t4"));
test_end_space(select("t5"));
test_begin_bs(setupIframe('i1'));
test_begin_space(setupIframe('i2'));
test_end_delete(setupIframe('i3'));
test_end_space(setupIframe('i4'));
test_begin_bs(setupIframe("i1"));
test_begin_space(setupIframe("i2"));
test_end_delete(setupIframe("i3"));
test_end_space(setupIframe("i4"));
SimpleTest.finish();
}

View file

@ -17,7 +17,7 @@ function runTest() {
function setupIframe(id) {
var e = document.getElementById(id);
var doc = e.contentDocument;
doc.body.innerHTML = String.fromCharCode(10)+'<span id="' + id + '_span" style="border:1px solid blue" contenteditable="true">X</span>'+String.fromCharCode(10);
doc.body.innerHTML = String.fromCharCode(10) + '<span id="' + id + '_span" style="border:1px solid blue" contenteditable="true">X</span>' + String.fromCharCode(10);
e = doc.getElementById(id + "_span");
e.focus();
return e;
@ -34,11 +34,11 @@ function runTest() {
}
test_end_bs(select("t1"));
test_end_bs(setupIframe('i1',0));
test_end_bs(setupIframe("i1", 0));
{
const msg = "Deleting all text in contenteditable body element";
var e = document.getElementById('i2');
var e = document.getElementById("i2");
var doc = e.contentDocument;
doc.body.setAttribute("contenteditable", "true");
doc.body.focus();

View file

@ -74,7 +74,7 @@ function split(element, caretPos) {
pos = 0;
break;
case CARET_MIDDLE:
pos = Math.floor(len/2);
pos = Math.floor(len / 2);
break;
case CARET_END:
pos = len;
@ -87,7 +87,7 @@ function split(element, caretPos) {
range.setStart(element.firstChild, pos);
range.setEnd(element.firstChild, pos);
sel.addRange(range);
// simulates a [Return] keypress
synthesizeKey("VK_RETURN", {shiftKey: true});
}

View file

@ -23,7 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471319
<script type="application/javascript">
/** Test for Bug 471319 **/
SimpleTest.waitForExplicitFinish();
function doTest() {

View file

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471722
<script type="application/javascript">
/** Test for Bug 471722 **/
SimpleTest.waitForExplicitFinish();
function doTest() {
@ -41,7 +41,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471722
ok(editor.canCut(), "can cut text");
editor.cut();
is(t1.value, "", "initial text was removed");
// So now we will have emptied the textfield
// and the editor will have created a bogus node
// Check the transaction is in the undo stack...
@ -67,7 +67,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471722
// Did the editor notice a bogus node reappeared?
is(t1.value, "", "editor found bogus node");
} catch (e) {
ok(false, "test failed with error "+e);
ok(false, "test failed with error " + e);
}
SimpleTest.finish();
}

View file

@ -9,13 +9,13 @@
function runTest() {
function verifyContent(s) {
var e = document.getElementById('i1');
var e = document.getElementById("i1");
var doc = e.contentDocument;
is(doc.body.innerHTML, s, "");
}
function pasteInto(html,target_id) {
var e = document.getElementById('i1');
function pasteInto(html, target_id) {
var e = document.getElementById("i1");
var doc = e.contentDocument;
doc.designMode = "on";
doc.body.innerHTML = html;
@ -29,8 +29,8 @@ function runTest() {
return e;
}
function copyToClipBoard(s,asHTML,target_id) {
var e = document.getElementById('i2');
function copyToClipBoard(s, asHTML, target_id) {
var e = document.getElementById("i2");
var doc = e.contentDocument;
if (asHTML) {
doc.body.innerHTML = s;
@ -54,39 +54,39 @@ function runTest() {
}
copyToClipBoard("<dl><dd>Hello Kitty</dd></dl>", true);
pasteInto('<ol><li id="paste_here">X</li></ol>',"paste_here");
pasteInto('<ol><li id="paste_here">X</li></ol>', "paste_here");
verifyContent('<ol><li id="paste_here">X<dl><dd>Hello Kitty</dd></dl></li></ol>');
copyToClipBoard("<li>Hello Kitty</li>", true);
pasteInto('<ol><li id="paste_here">X</li></ol>',"paste_here");
pasteInto('<ol><li id="paste_here">X</li></ol>', "paste_here");
verifyContent('<ol><li id="paste_here">X</li><li>Hello Kitty</li></ol>');
copyToClipBoard("<ol><li>Hello Kitty</li></ol>", true);
pasteInto('<ol><li id="paste_here">X</li></ol>',"paste_here");
pasteInto('<ol><li id="paste_here">X</li></ol>', "paste_here");
verifyContent('<ol><li id="paste_here">X</li><li>Hello Kitty</li></ol>');
copyToClipBoard("<ul><li>Hello Kitty</li></ul>", true);
pasteInto('<ol><li id="paste_here">X</li></ol>',"paste_here");
pasteInto('<ol><li id="paste_here">X</li></ol>', "paste_here");
verifyContent('<ol><li id="paste_here">X</li><li>Hello Kitty</li></ol>');
copyToClipBoard("<ul><li>Hello</li><ul><li>Kitty</li></ul></ul>", true);
pasteInto('<ol><li id="paste_here">X</li></ol>',"paste_here");
pasteInto('<ol><li id="paste_here">X</li></ol>', "paste_here");
verifyContent('<ol><li id="paste_here">X</li><li>Hello</li><ul><li>Kitty</li></ul></ol>');
copyToClipBoard("<dl><dd>Hello</dd><dd>Kitty</dd></dl>", true);
pasteInto('<dl><dd id="paste_here">X</dd></dl>',"paste_here");
pasteInto('<dl><dd id="paste_here">X</dd></dl>', "paste_here");
verifyContent('<dl><dd id="paste_here">X</dd><dd>Hello</dd><dd>Kitty</dd></dl>');
copyToClipBoard("<dl><dd>Hello</dd><dd>Kitty</dd></dl>", true);
pasteInto('<dl><dt id="paste_here">X</dt></dl>',"paste_here");
pasteInto('<dl><dt id="paste_here">X</dt></dl>', "paste_here");
verifyContent('<dl><dt id="paste_here">X</dt><dd>Hello</dd><dd>Kitty</dd></dl>');
copyToClipBoard("<dl><dt>Hello</dt><dd>Kitty</dd></dl>", true);
pasteInto('<dl><dd id="paste_here">X</dd></dl>',"paste_here");
pasteInto('<dl><dd id="paste_here">X</dd></dl>', "paste_here");
verifyContent('<dl><dd id="paste_here">X</dd><dt>Hello</dt><dd>Kitty</dd></dl>');
copyToClipBoard("<pre>Kitty</pre>", true);
pasteInto('<pre id="paste_here">Hello </pre>',"paste_here");
pasteInto('<pre id="paste_here">Hello </pre>', "paste_here");
verifyContent('<pre id="paste_here">Hello Kitty</pre>');
// I was expecting these to trigger the special TABLE/TR rules in nsHTMLEditor::InsertHTMLWithContext

View file

@ -9,13 +9,13 @@
function runTest() {
function verifyContent(s) {
var e = document.getElementById('i1');
var e = document.getElementById("i1");
var doc = e.contentDocument;
is(doc.body.innerHTML, s, "");
}
function pasteInto(html,target_id) {
var e = document.getElementById('i1');
function pasteInto(html, target_id) {
var e = document.getElementById("i1");
var doc = e.contentDocument;
doc.designMode = "on";
doc.body.innerHTML = html;
@ -32,8 +32,8 @@ function runTest() {
return e;
}
function copyToClipBoard(s,asHTML,target_id) {
var e = document.getElementById('i2');
function copyToClipBoard(s, asHTML, target_id) {
var e = document.getElementById("i2");
var doc = e.contentDocument;
if (asHTML) {
doc.body.innerHTML = s;
@ -56,12 +56,12 @@ function runTest() {
return e;
}
copyToClipBoard('<span>Hello</span><span>Kitty</span>', true);
pasteInto('');
verifyContent('<span>Hello</span><span>Kitty</span>');
copyToClipBoard("<span>Hello</span><span>Kitty</span>", true);
pasteInto("");
verifyContent("<span>Hello</span><span>Kitty</span>");
copyToClipBoard("<dl><dd>Hello Kitty</dd></dl><span>Hello</span><span>Kitty</span>", true);
pasteInto('<ol><li id="paste_here">X</li></ol>',"paste_here");
pasteInto('<ol><li id="paste_here">X</li></ol>', "paste_here");
verifyContent('<ol><li id="paste_here">X<dl><dd>Hello Kitty</dd></dl><span>Hello</span><span>Kitty</span></li></ol>');
// The following test doesn't do what I expected, because the special handling
@ -72,7 +72,7 @@ function runTest() {
// verifyContent('<ol><li id="paste_here">X</li><li>Hello Kitty</li><span>Hello</span></ol>');
copyToClipBoard("<pre>Kitty</pre><span>Hello</span>", true);
pasteInto('<pre id="paste_here">Hello </pre>',"paste_here");
pasteInto('<pre id="paste_here">Hello </pre>', "paste_here");
verifyContent('<pre id="paste_here">Hello Kitty<span>Hello</span></pre>');
SimpleTest.finish();

View file

@ -40,7 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=483651
// Was the trailing br removed?
is(editor.documentIsEmpty, true, "trailing <br> correctly removed");
} catch (e) {
ok(false, "test failed with error "+e);
ok(false, "test failed with error " + e);
}
SimpleTest.finish();
}

View file

@ -49,12 +49,12 @@ function runTest() {
SpecialPowers.Cu.import(
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
onSpellCheck(edit, function () {
onSpellCheck(edit, function() {
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
"All misspellings before editing are accounted for.");
append(" becaz I'm a lulcat!");
onSpellCheck(edit, function () {
onSpellCheck(edit, function() {
gMisspeltWords.push("becaz");
gMisspeltWords.push("lulcat");
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),

View file

@ -8,7 +8,7 @@
<script class="testbody" type="application/javascript">
function runTest() {
function setupIframe(e,html,focus_id) {
function setupIframe(e, html, focus_id) {
var doc = e.contentDocument;
doc.body.innerHTML = html;
doc.designMode = "on";
@ -18,32 +18,32 @@ function runTest() {
return e;
}
var i1 = document.getElementById('i1')
var li1 = setupIframe(i1,'<ul><li id="li1">one</li><li>two</li><ul><li>a</li></ul></ul>','li1')
var i1 = document.getElementById("i1");
var li1 = setupIframe(i1, '<ul><li id="li1">one</li><li>two</li><ul><li>a</li></ul></ul>', "li1");
var doc = li1.ownerDocument;
var selection = doc.defaultView.getSelection();
selection.removeAllRanges();
var range = doc.createRange();
range.setStart(li1,0);
range.setEnd(li1.nextSibling,0);
range.setStart(li1, 0);
range.setEnd(li1.nextSibling, 0);
selection.addRange(range);
sendKey('delete');
is(doc.body.innerHTML,'<ul><li>two</li><ul><li>a</li></ul></ul>','delete 1st LI');
sendKey("delete");
is(doc.body.innerHTML, "<ul><li>two</li><ul><li>a</li></ul></ul>", "delete 1st LI");
var li2 = setupIframe(i1,'<ul><li id="li2">two</li><ul><li>a</li></ul></ul>','li2')
var li2 = setupIframe(i1, '<ul><li id="li2">two</li><ul><li>a</li></ul></ul>', "li2");
selection = doc.defaultView.getSelection();
selection.removeAllRanges();
range = doc.createRange();
range.setStart(li2,0);
range.setEnd(li2.nextSibling.firstChild,0);
range.setStart(li2, 0);
range.setEnd(li2.nextSibling.firstChild, 0);
selection.addRange(range);
sendKey('delete');
is(doc.body.innerHTML,'<ul><ul><li>a</li></ul></ul>','delete 2nd LI');
sendKey("delete");
is(doc.body.innerHTML, "<ul><ul><li>a</li></ul></ul>", "delete 2nd LI");
SimpleTest.finish();
}

View file

@ -10,14 +10,14 @@
function runTest() {
function verifyContent() {
const kExpectedImgSpec = "data:image/png;base64,";
var e = document.getElementById('i1');
var e = document.getElementById("i1");
var doc = e.contentDocument;
is(doc.getElementsByTagName("img")[0].src.substring(0, kExpectedImgSpec.length),
kExpectedImgSpec, "The pasted image is a base64-encoded data: URI");
}
function pasteInto() {
var e = document.getElementById('i1');
var e = document.getElementById("i1");
var doc = e.contentDocument;
doc.designMode = "on";
doc.defaultView.focus();

View file

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502673
<script type="application/javascript">
/** Test for Bug 502673 **/
SimpleTest.waitForExplicitFinish();
function listener() {
@ -32,18 +32,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502673
listener.prototype =
{
NotifyDocumentWillBeDestroyed: function () {
var editor = SpecialPowers.wrap(this.input).editor;
editor.removeDocumentStateListener(this);
},
NotifyDocumentWillBeDestroyed() {
var editor = SpecialPowers.wrap(this.input).editor;
editor.removeDocumentStateListener(this);
},
NotifyDocumentCreated: function () {
},
NotifyDocumentCreated() {
},
NotifyDocumentStateChanged: function (aNowDirty) {
var editor = SpecialPowers.wrap(this.input).editor;
editor.removeDocumentStateListener(this);
},
NotifyDocumentStateChanged(aNowDirty) {
var editor = SpecialPowers.wrap(this.input).editor;
editor.removeDocumentStateListener(this);
},
QueryInterface: SpecialPowers.wrapCallback(function(iid) {
if (iid.equals(SpecialPowers.Ci.nsIDocumentStateListener) ||
@ -81,7 +81,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502673
editor.addDocumentStateListener(listener1);
editor.addDocumentStateListener(listener2);
editor.addDocumentStateListener(listener3);
// Test 2. Fire NotifyDocumentWillBeDestroyed notifications where the
// listeners remove themselves (though in the real world, listeners
// shouldn't do this as nsEditor::PreDestroy removes them as

View file

@ -84,7 +84,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=520182
const dataPayload = "foo<iframe src=\"data:text/html,bar\"></iframe>baz";
const jsPayload = "foo<iframe src=\"javascript:void('bar');\"></iframe>baz";
const httpPayload = "foo<iframe src=\"http://mochi.test:8888/\"></iframe>baz";
const scriptPayload ="foo<script>document.write(\"<iframe></iframe>\");</sc" + "ript>baz";
const scriptPayload = "foo<script>document.write(\"<iframe></iframe>\");</sc" + "ript>baz";
const scriptExternalPayload = "foo<script src=\"data:text/javascript,document.write('<iframe></iframe>');\"></sc" + "ript>baz";
const validStyle1Payload = "foo<style>#bar{color:red;}</style>baz";
const validStyle2Payload = "foo<span style=\"color:red\">bar</span>baz";
@ -140,14 +140,14 @@ var tests = [
isIFrame: true,
payload: scriptPayload,
rootElement() { return document.getElementById("g").contentDocument.documentElement; },
iframeCount: 0
iframeCount: 0,
},
{
id: "h",
isIFrame: true,
payload: scriptExternalPayload,
rootElement() { return document.getElementById("h").contentDocument.documentElement; },
iframeCount: 0
iframeCount: 0,
},
{
id: "d",
@ -171,13 +171,13 @@ var tests = [
id: "i",
payload: scriptPayload,
rootElement() { return document.getElementById("i"); },
iframeCount: 0
iframeCount: 0,
},
{
id: "j",
payload: scriptExternalPayload,
rootElement() { return document.getElementById("j"); },
iframeCount: 0
iframeCount: 0,
},
{
id: "k",
@ -288,21 +288,21 @@ var tests = [
isIFrame: true,
payload: nestedStylePayload,
rootElement() { return document.getElementById("aa").contentDocument.documentElement; },
checkResult: function(html, text) {
checkResult(html, text) {
is(html.indexOf("binding-1"), -1, "Should not have retained the binding-1 style");
isnot(text.indexOf("#bar2"), -1, "Should have retained binding-2 as text content");
is(text.indexOf("binding-2"), -1, "Should not have retained binding-2 as a tag");
}
},
},
{
id: "bb",
payload: nestedStylePayload,
rootElement() { return document.getElementById("bb"); },
checkResult: function(html, text) {
checkResult(html, text) {
is(html.indexOf("binding-1"), -1, "Should not have retained the binding-1 style");
isnot(text.indexOf("#bar2"), -1, "Should have retained binding-2 as text content");
is(text.indexOf("binding-2"), -1, "Should not have retained binding-2 as a tag");
}
},
},
{
id: "cc",
@ -375,20 +375,20 @@ var tests = [
indirectPaste: true,
payload: invalidStyle7Payload,
rootElement() { return document.getElementById("mm").contentDocument.documentElement; },
checkResult: function(html) {
checkResult(html) {
is(html.indexOf("xxx"), -1, "Should not have retained the title text");
isnot(html.indexOf("foo"), -1, "Should have retained the body text");
}
},
},
{
id: "nn",
indirectPaste: true,
payload: invalidStyle7Payload,
rootElement() { return document.getElementById("nn"); },
checkResult: function(html) {
checkResult(html) {
is(html.indexOf("xxx"), -1, "Should not have retained the title text");
isnot(html.indexOf("foo"), -1, "Should have retained the body text");
}
},
},
{
id: "oo",
@ -524,15 +524,15 @@ var tests = [
id: "yyy",
payload: microdataPayload,
rootElement() { return document.getElementById("yyy"); },
checkResult: function(html) { is(html.indexOf("name"), -1, "Should have dropped name."); is(html.indexOf("rel"), -1, "Should have dropped rel."); isnot(html.indexOf("itemprop"), -1, "Should not have dropped itemprop."); }
checkResult(html) { is(html.indexOf("name"), -1, "Should have dropped name."); is(html.indexOf("rel"), -1, "Should have dropped rel."); isnot(html.indexOf("itemprop"), -1, "Should not have dropped itemprop."); },
},
{
id: "yyyy",
isIFrame: true,
payload: microdataPayload,
rootElement() { return document.getElementById("yyyy").contentDocument.documentElement; },
checkResult: function(html) { is(html.indexOf("name"), -1, "Should have dropped name."); is(html.indexOf("rel"), -1, "Should have dropped rel."); isnot(html.indexOf("itemprop"), -1, "Should not have dropped itemprop."); }
}
checkResult(html) { is(html.indexOf("name"), -1, "Should have dropped name."); is(html.indexOf("rel"), -1, "Should have dropped rel."); isnot(html.indexOf("itemprop"), -1, "Should not have dropped itemprop."); },
},
];
function doNextTest() {
@ -611,7 +611,7 @@ SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
SpecialPowers.pushPrefEnv(
{ "set": [["layout.css.moz-document.content.enabled", true]]},
doNextTest)
doNextTest);
});
</script>
</pre>

View file

@ -18,10 +18,10 @@ function getLoadContext() {
async function runTest() {
var pasteCount = 0;
var pasteFunc = function (event) { pasteCount++; };
var pasteFunc = function(event) { pasteCount++; };
function verifyContent(s) {
var e = document.getElementById('i1');
var e = document.getElementById("i1");
var doc = e.contentDocument;
if (navigator.platform.includes("Win")) {
// On Windows ignore \n which got left over from the removal of the fragment tags
@ -33,7 +33,7 @@ async function runTest() {
}
function pasteInto(trans, html, target_id) {
var e = document.getElementById('i1');
var e = document.getElementById("i1");
var doc = e.contentDocument;
doc.designMode = "on";
doc.body.innerHTML = html;
@ -62,14 +62,14 @@ async function runTest() {
trans.addDataFlavor("text/html");
} else {
trans.addDataFlavor("text/unicode");
}
}
var clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
clip.getData(trans, Ci.nsIClipboard.kGlobalClipboard);
return trans;
}
function makeTransferable(s,asHTML,target_id) {
var e = document.getElementById('i2');
function makeTransferable(s, asHTML, target_id) {
var e = document.getElementById("i2");
var doc = e.contentDocument;
if (asHTML) {
doc.body.innerHTML = s;
@ -94,7 +94,7 @@ async function runTest() {
var ssData = supportsStringClass.createInstance(Ci.nsISupportsString);
// Create the transferable.
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
trans.init(getLoadContext());
// Add the data to the transferable.
@ -111,8 +111,8 @@ async function runTest() {
return trans;
}
async function copyToClipBoard(s,asHTML,target_id) {
var e = document.getElementById('i2');
async function copyToClipBoard(s, asHTML, target_id) {
var e = document.getElementById("i2");
var doc = e.contentDocument;
if (asHTML) {
doc.body.innerHTML = s;
@ -138,21 +138,21 @@ async function runTest() {
return e;
}
await copyToClipBoard('<span>Hello</span><span>Kitty</span>', true);
await copyToClipBoard("<span>Hello</span><span>Kitty</span>", true);
var trans = getTransferableFromClipboard(true);
pasteInto(trans, '');
verifyContent('<span>Hello</span><span>Kitty</span>');
pasteInto(trans, "");
verifyContent("<span>Hello</span><span>Kitty</span>");
is(pasteCount, 1, "paste event was not triggered");
// this test is not working out exactly like the clipboard test
// has to do with generating the nsITransferable above
//trans = makeTransferable('<span>Hello</span><span>Kitty</span>', true);
//pasteInto(trans, '');
//verifyContent('<span>Hello</span><span>Kitty</span>');
// trans = makeTransferable('<span>Hello</span><span>Kitty</span>', true);
// pasteInto(trans, '');
// verifyContent('<span>Hello</span><span>Kitty</span>');
await copyToClipBoard("<dl><dd>Hello Kitty</dd></dl><span>Hello</span><span>Kitty</span>", true);
trans = getTransferableFromClipboard(true);
pasteInto(trans, '<ol><li id="paste_here">X</li></ol>',"paste_here");
pasteInto(trans, '<ol><li id="paste_here">X</li></ol>', "paste_here");
verifyContent('<ol><li id="paste_here">X<dl><dd>Hello Kitty</dd></dl><span>Hello</span><span>Kitty</span></li></ol>');
is(pasteCount, 1, "paste event was not triggered");
@ -165,21 +165,21 @@ async function runTest() {
await copyToClipBoard("<pre>Kitty</pre><span>Hello</span>", true);
trans = getTransferableFromClipboard(true);
pasteInto(trans, '<pre id="paste_here">Hello </pre>',"paste_here");
pasteInto(trans, '<pre id="paste_here">Hello </pre>', "paste_here");
verifyContent('<pre id="paste_here">Hello Kitty<span>Hello</span></pre>');
is(pasteCount, 1, "paste event was not triggered");
await copyToClipBoard('1<span style="display: contents">2</span>3', true);
trans = getTransferableFromClipboard(true);
pasteInto(trans, '<div id="paste_here"></div>',"paste_here");
pasteInto(trans, '<div id="paste_here"></div>', "paste_here");
verifyContent('<div id="paste_here">1<span style="display: contents">2</span>3</div>');
is(pasteCount, 1, "paste event was not triggered");
// test that we can preventDefault pastes
pasteFunc = function (event) { event.preventDefault(); return false; };
pasteFunc = function(event) { event.preventDefault(); return false; };
await copyToClipBoard("<pre>Kitty</pre><span>Hello</span>", true);
trans = getTransferableFromClipboard(true);
pasteInto(trans, '<pre id="paste_here">Hello </pre>',"paste_here");
pasteInto(trans, '<pre id="paste_here">Hello </pre>', "paste_here");
verifyContent('<pre id="paste_here">Hello </pre>');
is(pasteCount, 0, "paste event was triggered");
}

View file

@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549262
var smoothScrollPref = "general.smoothScroll";
SimpleTest.waitForExplicitFinish();
var win = window.open("file_bug549262.html", "_blank",
var win = window.open("file_bug549262.html", "_blank",
"width=600,height=600,scrollbars=yes");
// grab the timer right at the start
@ -30,7 +30,7 @@ function step() {
cwu.advanceTimeAndRefresh(100);
}
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set":[[smoothScrollPref, false]]}, startTest);
SpecialPowers.pushPrefEnv({"set": [[smoothScrollPref, false]]}, startTest);
}, win);
function startTest() {
// Make sure that pressing Space when a contenteditable element is not focused

View file

@ -26,8 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=551704
<pre id="test">
<script type="application/javascript">
function testLineBreak(div, type, expectedText, expectedHTML, callback)
{
function testLineBreak(div, type, expectedText, expectedHTML, callback) {
div.focus();
getSelection().collapse(div, 0);
type();
@ -98,7 +97,7 @@ SimpleTest.waitForFocus(function() {
function continueTest() {
var divs = [];
for (var i = 0; i < 8; ++i) {
divs[i] = document.getElementById("test" + (i+1));
divs[i] = document.getElementById("test" + (i + 1));
}
var current = 0;
function doNextTest() {

View file

@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=552782
/** Test for Bug 552782 **/
SimpleTest.waitForExplicitFinish();
var original = '<ol><li>Item 1</li><ol><li>Item 2</li><li>Item 3</li><li>Item 4</li></ol></ol>';
var original = "<ol><li>Item 1</li><ol><li>Item 2</li><li>Item 3</li><li>Item 4</li></ol></ol>";
var editor = document.getElementById("editor");
editor.innerHTML = original;
editor.focus();
@ -32,7 +32,7 @@ addLoadEvent(function() {
var lis = document.getElementsByTagName("li");
sel.selectAllChildren(lis[2]);
document.execCommand("outdent", false, false);
var expected = '<ol><li>Item 1</li><ol><li>Item 2</li></ol><li>Item 3</li><ol><li>Item 4</li></ol></ol>';
var expected = "<ol><li>Item 1</li><ol><li>Item 2</li></ol><li>Item 3</li><ol><li>Item 4</li></ol></ol>";
is(editor.innerHTML, expected, "outdenting third item in a partially indented numbered list");
document.execCommand("indent", false, false);
todo_is(editor.innerHTML, original, "re-indenting third item in a partially indented numbered list");

View file

@ -24,8 +24,7 @@ SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTest);
function runTest()
{
function runTest() {
var script = SpecialPowers.loadChromeScript(function() {
var gPromptInput = null;
var os = Cc["@mozilla.org/observer-service;1"]
@ -58,7 +57,7 @@ function runTest()
"ESC key event is prevented by editor"]);
listenerService.removeSystemEventListener(gPromptInput, "keypress",
listener, false);
}
},
};
listenerService.addSystemEventListener(gPromptInput, "keypress",
listener, false);
@ -68,7 +67,7 @@ function runTest()
EventUtils.window = {};
EventUtils._EU_Ci = Ci;
EventUtils._EU_Cc = Cc;
Cc['@mozilla.org/moz/jssubscript-loader;1']
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
EventUtils);

View file

@ -78,13 +78,13 @@ function try2split(list) {
function testSection(element, context, shouldCreateLI, shouldCreateP) {
var nbLI = shouldCreateLI ? 2 : 1; // number of expected list items
var nbP = shouldCreateP ? 2 : 1; // number of expected paragraphs
var nbP = shouldCreateP ? 2 : 1; // number of expected paragraphs
function message(nodeName, dup) {
return context + ":[Return] should " + (dup ? "" : "not ")
+ "create another <" + nodeName + ">."
+ "create another <" + nodeName + ">.";
}
var msgP = message("p", shouldCreateP);
var msgP = message("p", shouldCreateP);
var msgLI = message("li", shouldCreateLI);
var msgDT = message("dt", shouldCreateLI);
var msgDD = message("dd", false);
@ -109,7 +109,7 @@ function testSection(element, context, shouldCreateLI, shouldCreateP) {
function runTests() {
testSection(document.getElementById("test1"), "editable paragraph in list item", false, false);
testSection(document.getElementById("test2"), "paragraph in editable list item", false, true);
testSection(document.getElementById("test3"), "paragraph in editable list", true, false);
testSection(document.getElementById("test3"), "paragraph in editable list", true, false);
/* Note: concerning #test3, it would be preferrable that [Return] creates
* another paragraph in another list item (i.e. last argument = 'true').
* Currently it just creates an empty list item, which is acceptable.

View file

@ -30,18 +30,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=578771
var ce = document.getElementById("ce");
ce.focus();
synthesizeMouse(elem, 5, 5, {clickCount: 2 });
synthesizeMouse(elem, 5, 5, {clickCount: 2 });
ok(elem.selectionStart == 0 && elem.selectionEnd == 7,
" Double-clicking on another " + elemTag + " works correctly");
ce.focus();
synthesizeMouse(elem, 5, 5, {clickCount: 3 });
synthesizeMouse(elem, 5, 5, {clickCount: 3 });
ok(elem.selectionStart == 0 && elem.selectionEnd == 14,
"Triple-clicking on another " + elemTag + " works correctly");
}
// Avoid platform selection differences
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set":[["layout.word_select.eat_space_to_next_word", false]]}, startTest);
SpecialPowers.pushPrefEnv({"set": [["layout.word_select.eat_space_to_next_word", false]]}, startTest);
});
function startTest() {

View file

@ -62,7 +62,7 @@ function runOnFocus() {
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
"All misspellings before editing are accounted for.");
append(" becaz I'm a lulcat!");
onSpellCheck(edit, function () {
onSpellCheck(edit, function() {
gMisspeltWords.push("becaz");
gMisspeltWords.push("lulcat");
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
@ -72,7 +72,7 @@ function runOnFocus() {
// the textarea and see if the spell check after the blur event catches it.
append(" workd");
edit.blur();
onSpellCheck(edit, function () {
onSpellCheck(edit, function() {
gMisspeltWords.push("workd");
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
"All misspellings after blur are accounted for.");
@ -81,7 +81,7 @@ function runOnFocus() {
gMisspeltWords = ["workd"];
edit.value = "";
append("workd ");
onSpellCheck(edit, function () {
onSpellCheck(edit, function() {
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
"Misspelling in the first entered word is accounted for.");
@ -90,7 +90,7 @@ function runOnFocus() {
edit.value = "";
append("workd");
paste(" x");
onSpellCheck(edit, function () {
onSpellCheck(edit, function() {
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
"Misspelling is accounted for after pasting.");
@ -101,8 +101,7 @@ function runOnFocus() {
});
}
function runTest()
{
function runTest() {
var edit = document.getElementById("edit");
edit.focus();

View file

@ -38,9 +38,9 @@ addLoadEvent(function() {
t.selectionEnd = 5;
t.addEventListener("keydown", function() {
SimpleTest.executeSoon(function() {
t.style.display = 'block';
t.style.display = "block";
document.body.offsetWidth;
t.style.display = '';
t.style.display = "";
document.body.offsetWidth;
is(t.selectionStart, 4, "Cursor should be moved correctly");

View file

@ -75,7 +75,7 @@ SimpleTest.waitForFocus(function() {
}, {once: true});
iframe.src = src;
}
var totalTests = 0;
var currentTest = 0;
function runAllTests() {
@ -83,7 +83,7 @@ SimpleTest.waitForFocus(function() {
SimpleTest.finish();
return;
}
testBackspace("file_bug611182.sjs?" + currentTest, runAllTests)
testBackspace("file_bug611182.sjs?" + currentTest, runAllTests);
currentTest++;
}
@ -94,7 +94,7 @@ SimpleTest.waitForFocus(function() {
myXHR.onload = function(e) {
totalTests = myXHR.responseText;
runAllTests();
}
};
myXHR.send();
});

View file

@ -34,11 +34,11 @@ addLoadEvent(function() {
is(iframe.contentWindow.scrollY, 0, "Sanity check");
var rect = iframe.getBoundingClientRect();
setTimeout(function() {
var onscroll = function () {
var onscroll = function() {
iframe.contentWindow.removeEventListener("scroll", onscroll);
isnot(iframe.contentWindow.scrollY, 0, "The scrollbar should work");
SimpleTest.finish();
}
};
iframe.contentWindow.addEventListener("scroll", onscroll);
synthesizeMouse(iframe, rect.width - 5, rect.height / 2, {});
}, 0);

View file

@ -14,17 +14,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=629845
<p id="display"></p>
<script>
function initFrame(frame)
{
frame.contentWindow.document.designMode="on";
function initFrame(frame) {
frame.contentWindow.document.designMode = "on";
frame.contentWindow.document.writeln("<body></body>");
document.getElementsByTagName('button')[0].click();
document.getElementsByTagName("button")[0].click();
}
function command(aName)
{
var frame = document.getElementsByTagName('iframe')[0];
function command(aName) {
var frame = document.getElementsByTagName("iframe")[0];
is(frame.contentDocument.designMode, "on", "design mode should be on!");
var caught = false;
@ -38,7 +36,7 @@ function command(aName)
ok(!caught, "No exception should have been thrown.");
// Stop the document load before finishing, just to be clean.
document.getElementsByTagName('iframe')[0].contentWindow.document.close();
document.getElementsByTagName("iframe")[0].contentWindow.document.close();
SimpleTest.finish();
}
</script>

View file

@ -20,8 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=635636
/** Test for Bug 635636 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(async function() {
function openNewWindow(aURL)
{
function openNewWindow(aURL) {
return new Promise(resolve => {
let contentWindow = window.open(aURL);
contentWindow.addEventListener("load", () => {
@ -31,8 +30,7 @@ addLoadEvent(async function() {
});
}
function unloadWindow(aWindow)
{
function unloadWindow(aWindow) {
return new Promise(resolve => {
aWindow.addEventListener("unload", () => {
ok(true, "The window has been unloaded");
@ -48,7 +46,7 @@ addLoadEvent(async function() {
contentWindow.addEventListener("pageshow", () => { ok(true, "pageshow"); });
let div = contentWindow.document.getElementsByTagName("div")[0];
contentWindow.document.designMode = 'on';
contentWindow.document.designMode = "on";
await unloadWindow(contentWindow);

View file

@ -15,14 +15,14 @@ function runTest() {
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
var x = document.getElementById("x");
x.focus();
onSpellCheck(x, function () {
onSpellCheck(x, function() {
x.blur();
var spellCheckTrue = snapshotWindow(window);
x.setAttribute("spellcheck", "false");
var spellCheckFalse = snapshotWindow(window);
x.setAttribute("spellcheck", "true");
x.focus();
onSpellCheck(x, function () {
onSpellCheck(x, function() {
x.blur();
var spellCheckTrueAgain = snapshotWindow(window);
x.removeAttribute("spellcheck");

View file

@ -22,7 +22,7 @@ bar</textarea>
/** Test for Bug 645914 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set":[["layout.word_select.eat_space_to_next_word", true],
SpecialPowers.pushPrefEnv({"set": [["layout.word_select.eat_space_to_next_word", true],
["browser.triple_click_selects_paragraph", false]]}, startTest);
});
function startTest() {

View file

@ -33,12 +33,12 @@ SimpleTest.waitForFocus(runTests);
function select(element) {
// select the element text content
var userSelection = window.getSelection();
window.getSelection().removeAllRanges();
window.getSelection().removeAllRanges();
var range = document.createRange();
range.setStart(element.firstChild, 0);
range.setEnd(element.firstChild, element.textContent.length);
userSelection.addRange(range);
};
}
function runTests() {
var span = document.querySelector("#test1 span");

View file

@ -23,16 +23,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=674770
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set":[["middlemouse.paste", true]]}, startTests);
SpecialPowers.pushPrefEnv({"set": [["middlemouse.paste", true]]}, startTests);
});
function startTests() {
var tests = [
{ description: "Testing link in <div>: ",
target: function () { return document.querySelector("#link1"); },
target() { return document.querySelector("#link1"); },
linkShouldWork: true },
{ description: "Testing link in <div contenteditable>: ",
target: function () { return document.querySelector("#link2"); },
target() { return document.querySelector("#link2"); },
linkShouldWork: false },
];
var currentTest;
@ -55,7 +55,7 @@ function startTests() {
SimpleTest.executeSoon(runNextTest);
}, false);
SpecialPowers.addSystemEventListener(window, "click", function (aEvent) {
SpecialPowers.addSystemEventListener(window, "click", function(aEvent) {
// When the click event should cause default action, e.g., opening the link,
// the event shouldn't have been consumed except the link handler.
// However, in e10s mode, it's not consumed during propagating the event but

View file

@ -30,8 +30,7 @@ var gClicking = null;
var gDoPreventDefault1 = null;
var gDoPreventDefault2 = null;
function clickEventHandler(aEvent)
{
function clickEventHandler(aEvent) {
if (aEvent.button == 1 && aEvent.target == gClicking) {
gClicked = true;
}
@ -47,7 +46,7 @@ function clickEventHandler(aEvent)
// modified. Sometimes, the modification is delayed. Therefore, there
// are a lot of functions and SimpleTest.executeSoon()s.
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set":[["middlemouse.contentLoadURL", false],
SpecialPowers.pushPrefEnv({"set": [["middlemouse.contentLoadURL", false],
["middlemouse.paste", true]]}, startTest);
});
function startTest() {
@ -71,7 +70,7 @@ function startTest() {
if (!SpecialPowers.supportsSelectionClipboard()) {
SimpleTest.waitForClipboard("pasted",
function() { synthesizeKey("c", { accelKey: true }, frameWindow); },
function() { SimpleTest.executeSoon(runInputTests1) },
function() { SimpleTest.executeSoon(runInputTests1); },
cleanup);
} else {
// Otherwise, don't call waitForClipboard since it breaks primary
@ -80,8 +79,7 @@ function startTest() {
}
}
function runInputTests1()
{
function runInputTests1() {
var input = frameDocument.getElementById("input");
// first, copy text.
@ -107,8 +105,7 @@ function runInputTests1()
});
}
function runInputTests2()
{
function runInputTests2() {
var input = frameDocument.getElementById("input");
// even if the input element hasn't had focus, middle click should set focus
@ -134,8 +131,7 @@ function runInputTests2()
});
}
function runInputTests3()
{
function runInputTests3() {
var input = frameDocument.getElementById("input");
var editor1 = frameDocument.getElementById("editor1");
@ -162,8 +158,7 @@ function runInputTests3()
});
}
function runInputTests4()
{
function runInputTests4() {
var input = frameDocument.getElementById("input");
var editor1 = frameDocument.getElementById("editor1");
@ -190,8 +185,7 @@ function runInputTests4()
});
}
function runContentEditableTests1()
{
function runContentEditableTests1() {
var editor1 = frameDocument.getElementById("editor1");
// when middle clicked in focused contentediable editor, text should be
@ -216,8 +210,7 @@ function runContentEditableTests1()
});
}
function runContentEditableTests2()
{
function runContentEditableTests2() {
var editor1 = frameDocument.getElementById("editor1");
// even if the contenteditable editor hasn't had focus, middle click should
@ -242,8 +235,7 @@ function runContentEditableTests2()
});
}
function runContentEditableTests3()
{
function runContentEditableTests3() {
var editor1 = frameDocument.getElementById("editor1");
var editor2 = frameDocument.getElementById("editor2");
@ -272,8 +264,7 @@ function runContentEditableTests3()
});
}
function runContentEditableTests4()
{
function runContentEditableTests4() {
var editor1 = frameDocument.getElementById("editor1");
// preventDefault() of editor1's click event handler should prevent
@ -298,8 +289,7 @@ function runContentEditableTests4()
});
}
function runContentEditableTests5()
{
function runContentEditableTests5() {
var editor1 = frameDocument.getElementById("editor1");
var editor2 = frameDocument.getElementById("editor2");
@ -329,19 +319,17 @@ function runContentEditableTests5()
});
}
function initForBodyEditableDocumentTests()
{
function initForBodyEditableDocumentTests() {
frameDocument.getElementById("input").removeEventListener("click", clickEventHandler);
frameDocument.getElementById("editor1").removeEventListener("click", clickEventHandler);
frameDocument.getElementById("editor2").removeEventListener("click", clickEventHandler);
iframe.onload =
function (aEvent) { SimpleTest.executeSoon(runBodyEditableDocumentTests1); };
function(aEvent) { SimpleTest.executeSoon(runBodyEditableDocumentTests1); };
iframe.srcdoc = "<body contenteditable>body:</body>";
}
function runBodyEditableDocumentTests1()
{
function runBodyEditableDocumentTests1() {
frameWindow = iframe.contentWindow;
frameDocument = iframe.contentDocument;
@ -362,8 +350,7 @@ function runBodyEditableDocumentTests1()
});
}
function runBodyEditableDocumentTests2()
{
function runBodyEditableDocumentTests2() {
frameDocument.body.innerHTML = "body:<span id='span' contenteditable='false'>non-editable</span>";
var body = frameDocument.body;
@ -382,8 +369,7 @@ function runBodyEditableDocumentTests2()
});
}
function cleanup()
{
function cleanup() {
SimpleTest.finish();
}

View file

@ -86,7 +86,7 @@ function try2split(element, caretPos) {
pos = 0;
break;
case CARET_MIDDLE:
pos = Math.floor(len/2);
pos = Math.floor(len / 2);
break;
case CARET_END:
pos = len;
@ -103,7 +103,7 @@ function try2split(element, caretPos) {
range.setStart(element.firstChild, pos);
range.setEnd(element.firstChild, pos);
sel.addRange(range);
// simulates two [Return] keypresses
synthesizeKey("KEY_Enter");
synthesizeKey("KEY_Enter");

View file

@ -42,8 +42,7 @@ var alwaysEnabledCommands = [
"styleWithCSS",
];
function ensureNobodyHasFocus()
{
function ensureNobodyHasFocus() {
document.activeElement.blur();
}
@ -81,7 +80,7 @@ function runTests() {
"contentReadOnly", "createLink",
"decreaseFontSize", "increaseFontSize",
"insertHTML", "insertHorizontalRule", "insertImage",
"removeFormat", "selectAll", "styleWithCSS"
"removeFormat", "selectAll", "styleWithCSS",
];
document.execCommand("styleWithCSS", false, false);
for (i = 0; i < commands.length; i++)

View file

@ -34,7 +34,7 @@ function selectEditor(aEditor) {
function runTests() {
var editor, node, initialHTML;
document.execCommand('styleWithCSS', false, true);
document.execCommand("styleWithCSS", false, true);
// editable <section>
editor = document.querySelector("section[contenteditable]");
@ -44,13 +44,13 @@ function runTests() {
document.execCommand("justifyright", false, null);
node = editor.querySelector("*");
is(node.nodeName.toLowerCase(), "div", "'justifyright' should create a <div> in the editable <section>.");
is(node.style.textAlign, "right", "'justifyright' should create a 'text-align: right' CSS rule.");
is(node.style.textAlign, "right", "'justifyright' should create a 'text-align: right' CSS rule.");
document.execCommand("undo", false, null);
// editable <section>: indent
document.execCommand("indent", false, null);
node = editor.querySelector("*");
is(node.nodeName.toLowerCase(), "div", "'indent' should create a <div> in the editable <section>.");
is(node.style.marginLeft, "40px", "'indent' should create a 'margin-left: 40px' CSS rule.");
is(node.style.marginLeft, "40px", "'indent' should create a 'margin-left: 40px' CSS rule.");
// editable <section>: undo with outdent
// this should remove the whole <div> but only removing the CSS rule would be acceptable, too
document.execCommand("outdent", false, null);
@ -67,13 +67,13 @@ function runTests() {
document.execCommand("justifyright", false, null);
node = editor.querySelector("*");
is(node.nodeName.toLowerCase(), "div", "'justifyright' should create a <div> in the editable <div>.");
is(node.style.textAlign, "right", "'justifyright' should create a 'text-align: right' CSS rule.");
is(node.style.textAlign, "right", "'justifyright' should create a 'text-align: right' CSS rule.");
document.execCommand("undo", false, null);
// editable <div>: indent
document.execCommand("indent", false, null);
node = editor.querySelector("*");
is(node.nodeName.toLowerCase(), "div", "'indent' should create a <div> in the editable <div>.");
is(node.style.marginLeft, "40px", "'indent' should create a 'margin-left: 40px' CSS rule.");
is(node.style.marginLeft, "40px", "'indent' should create a 'margin-left: 40px' CSS rule.");
// editable <div>: undo with outdent
// this should remove the whole <div> but only removing the CSS rule would be acceptable, too
document.execCommand("outdent", false, null);

View file

@ -30,14 +30,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=686203
var input = document.getElementById("input");
ce.focus();
var eventDetails = { button : 2 };
var eventDetails = { button: 2 };
synthesizeMouseAtCenter(input, eventDetails);
sendString("Z");
/* check values */
is(input.value, "Z", "input correctly focused after right-click");
is(ce.textContent, "abc", "contenteditable correctly blurred after right-click on input");
is(ce.textContent, "abc", "contenteditable correctly blurred after right-click on input");
SimpleTest.finish();
});

View file

@ -26,8 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=697842
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests);
function runTests()
{
function runTests() {
var editor = document.getElementById("editor");
editor.focus();
@ -63,10 +62,10 @@ function runTests()
{ "string": composingString,
"clauses":
[
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
]
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE },
],
},
"caret": { "start": 1, "length": 0 }
"caret": { "start": 1, "length": 0 },
});
// input second character
@ -76,10 +75,10 @@ function runTests()
{ "string": composingString,
"clauses":
[
{ "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
]
{ "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE },
],
},
"caret": { "start": 2, "length": 0 }
"caret": { "start": 2, "length": 0 },
});
// convert them
@ -89,10 +88,10 @@ function runTests()
"clauses":
[
{ "length": 2,
"attr": COMPOSITION_ATTR_SELECTED_CLAUSE }
]
"attr": COMPOSITION_ATTR_SELECTED_CLAUSE },
],
},
"caret": { "start": 2, "length": 0 }
"caret": { "start": 2, "length": 0 },
});
synthesizeComposition({ type: "compositioncommitasis" });

View file

@ -23,90 +23,90 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=772796
<script type="application/javascript">
var tests = [
/*00*/[ "<div>test</div><pre>foobar\nbaz</pre>", "<div>testfoobar\n</div><pre>baz</pre>" ],
/*01*/[ "<div>test</div><pre><b>foobar\nbaz</b></pre>", "<div>test<b>foobar\n</b></div><pre><b>baz</b></pre>" ],
/*02*/[ "<div>test</div><pre><b>foo</b>bar\nbaz</pre>", "<div>test<b>foo</b>bar\n</div><pre>baz</pre>" ],
/*03*/[ "<div>test</div><pre><b>foo</b>\nbar</pre>", "<div>test<b>foo</b>\n</div><pre>bar</pre>" ],
/*04*/[ "<div>test</div><pre><b>foo\n</b>bar\nbaz</pre>", "<div>test<b>foo\n</b></div><pre>bar\nbaz</pre>" ],
/* 00*/[ "<div>test</div><pre>foobar\nbaz</pre>", "<div>testfoobar\n</div><pre>baz</pre>" ],
/* 01*/[ "<div>test</div><pre><b>foobar\nbaz</b></pre>", "<div>test<b>foobar\n</b></div><pre><b>baz</b></pre>" ],
/* 02*/[ "<div>test</div><pre><b>foo</b>bar\nbaz</pre>", "<div>test<b>foo</b>bar\n</div><pre>baz</pre>" ],
/* 03*/[ "<div>test</div><pre><b>foo</b>\nbar</pre>", "<div>test<b>foo</b>\n</div><pre>bar</pre>" ],
/* 04*/[ "<div>test</div><pre><b>foo\n</b>bar\nbaz</pre>", "<div>test<b>foo\n</b></div><pre>bar\nbaz</pre>" ],
/* The <br> after the foobar is unfortunate but is behaviour that hasn't changed in bug 772796. */
/*05*/[ "<div>test</div><pre>foobar<br>baz</pre>", "<div>testfoobar<br></div><pre>baz</pre>" ],
/*06*/[ "<div>test</div><pre><b>foobar<br>baz</b></pre>", "<div>test<b>foobar</b><br></div><pre><b>baz</b></pre>" ],
/* 05*/[ "<div>test</div><pre>foobar<br>baz</pre>", "<div>testfoobar<br></div><pre>baz</pre>" ],
/* 06*/[ "<div>test</div><pre><b>foobar<br>baz</b></pre>", "<div>test<b>foobar</b><br></div><pre><b>baz</b></pre>" ],
/*
* Some tests with block elements.
* Tests 07, 09 and 11 don't use "MoveBlock", they use "JoinNodesSmart".
* Test 11 is a pain: <div>foo\bar</div> is be joined to "test", losing the visible line break.
*/
/*07*/[ "<div>test</div><pre><div>foobar</div>baz</pre>", "<div>testfoobar</div><pre>baz</pre>" ],
/*08*/[ "<div>test</div><pre>foobar<div>baz</div></pre>", "<div>testfoobar</div><pre><div>baz</div></pre>" ],
/*09*/[ "<div>test</div><pre><div>foobar</div>baz\nfred</pre>", "<div>testfoobar</div><pre>baz\nfred</pre>" ],
/*10*/[ "<div>test</div><pre>foobar<div>baz</div>\nfred</pre>", "<div>testfoobar</div><pre><div>baz</div>\nfred</pre>" ],
/*11*/[ "<div>test</div><pre><div>foo\nbar</div>baz\nfred</pre>", "<div>testfoo\nbar</div><pre>baz\nfred</pre>" ], // BAD
/*12*/[ "<div>test</div><pre>foo<div>bar</div>baz\nfred</pre>", "<div>testfoo</div><pre><div>bar</div>baz\nfred</pre>" ],
/* 07*/[ "<div>test</div><pre><div>foobar</div>baz</pre>", "<div>testfoobar</div><pre>baz</pre>" ],
/* 08*/[ "<div>test</div><pre>foobar<div>baz</div></pre>", "<div>testfoobar</div><pre><div>baz</div></pre>" ],
/* 09*/[ "<div>test</div><pre><div>foobar</div>baz\nfred</pre>", "<div>testfoobar</div><pre>baz\nfred</pre>" ],
/* 10*/[ "<div>test</div><pre>foobar<div>baz</div>\nfred</pre>", "<div>testfoobar</div><pre><div>baz</div>\nfred</pre>" ],
/* 11*/[ "<div>test</div><pre><div>foo\nbar</div>baz\nfred</pre>", "<div>testfoo\nbar</div><pre>baz\nfred</pre>" ], // BAD
/* 12*/[ "<div>test</div><pre>foo<div>bar</div>baz\nfred</pre>", "<div>testfoo</div><pre><div>bar</div>baz\nfred</pre>" ],
/*
* Repeating all tests above with the <pre> on a new line.
* We know that backspace doesn't work (bug 1190161). Third argument shows the current outcome.
*/
/*13-00*/[ "<div>test</div>\n<pre>foobar\nbaz</pre>", "<div>testfoobar\n</div><pre>baz</pre>",
/* 13-00*/[ "<div>test</div>\n<pre>foobar\nbaz</pre>", "<div>testfoobar\n</div><pre>baz</pre>",
"<div>test</div>foobar\n<pre>baz</pre>" ],
/*14-01*/[ "<div>test</div>\n<pre><b>foobar\nbaz</b></pre>", "<div>test<b>foobar\n</b></div><pre><b>baz</b></pre>",
/* 14-01*/[ "<div>test</div>\n<pre><b>foobar\nbaz</b></pre>", "<div>test<b>foobar\n</b></div><pre><b>baz</b></pre>",
"<div>test</div><b>foobar\n</b><pre><b>baz</b></pre>" ],
/*15-02*/[ "<div>test</div>\n<pre><b>foo</b>bar\nbaz</pre>", "<div>test<b>foo</b>bar\n</div><pre>baz</pre>",
/* 15-02*/[ "<div>test</div>\n<pre><b>foo</b>bar\nbaz</pre>", "<div>test<b>foo</b>bar\n</div><pre>baz</pre>",
"<div>test</div><b>foo</b>bar\n<pre>baz</pre>" ],
/*16-03*/[ "<div>test</div>\n<pre><b>foo</b>\nbar</pre>", "<div>test<b>foo</b>\n</div><pre>bar</pre>",
/* 16-03*/[ "<div>test</div>\n<pre><b>foo</b>\nbar</pre>", "<div>test<b>foo</b>\n</div><pre>bar</pre>",
"<div>test</div><b>foo</b>\n<pre>bar</pre>" ],
/*17-04*/[ "<div>test</div>\n<pre><b>foo\n</b>bar\nbaz</pre>", "<div>test<b>foo\n</b></div><pre>bar\nbaz</pre>",
/* 17-04*/[ "<div>test</div>\n<pre><b>foo\n</b>bar\nbaz</pre>", "<div>test<b>foo\n</b></div><pre>bar\nbaz</pre>",
"<div>test</div><b>foo\n</b><pre>bar\nbaz</pre>" ],
/*18-05*/[ "<div>test</div>\n<pre>foobar<br>baz</pre>", "<div>testfoobar<br></div><pre>baz</pre>",
/* 18-05*/[ "<div>test</div>\n<pre>foobar<br>baz</pre>", "<div>testfoobar<br></div><pre>baz</pre>",
"<div>test</div>foobar<br><pre>baz</pre>" ],
/*19-06*/[ "<div>test</div>\n<pre><b>foobar<br>baz</b></pre>", "<div>test<b>foobar</b><br></div><pre><b>baz</b></pre>",
/* 19-06*/[ "<div>test</div>\n<pre><b>foobar<br>baz</b></pre>", "<div>test<b>foobar</b><br></div><pre><b>baz</b></pre>",
"<div>test</div><b>foobar</b><br><pre><b>baz</b></pre>" ],
/*20-07*/[ "<div>test</div>\n<pre><div>foobar</div>baz</pre>", "<div>testfoobar</div><pre>baz</pre>",
/* 20-07*/[ "<div>test</div>\n<pre><div>foobar</div>baz</pre>", "<div>testfoobar</div><pre>baz</pre>",
"<div>test</div>foobar<pre>baz</pre>" ],
/*21-08*/[ "<div>test</div>\n<pre>foobar<div>baz</div></pre>", "<div>testfoobar</div><pre><div>baz</div></pre>",
/* 21-08*/[ "<div>test</div>\n<pre>foobar<div>baz</div></pre>", "<div>testfoobar</div><pre><div>baz</div></pre>",
"<div>test</div>foobar<pre><div>baz</div></pre>" ],
/*22-09*/[ "<div>test</div>\n<pre><div>foobar</div>baz\nfred</pre>", "<div>testfoobar</div><pre>baz\nfred</pre>",
/* 22-09*/[ "<div>test</div>\n<pre><div>foobar</div>baz\nfred</pre>", "<div>testfoobar</div><pre>baz\nfred</pre>",
"<div>test</div>foobar<pre>baz\nfred</pre>" ],
/*23-10*/[ "<div>test</div>\n<pre>foobar<div>baz</div>\nfred</pre>", "<div>testfoobar</div><pre><div>baz</div>\nfred</pre>",
/* 23-10*/[ "<div>test</div>\n<pre>foobar<div>baz</div>\nfred</pre>", "<div>testfoobar</div><pre><div>baz</div>\nfred</pre>",
"<div>test</div>foobar<pre><div>baz</div>\nfred</pre>" ],
/*24-11*/[ "<div>test</div>\n<pre><div>foo\nbar</div>baz\nfred</pre>", "<div>testfoo\nbar</div><pre>baz\nfred</pre>", // BAD
/* 24-11*/[ "<div>test</div>\n<pre><div>foo\nbar</div>baz\nfred</pre>", "<div>testfoo\nbar</div><pre>baz\nfred</pre>", // BAD
"<div>test</div>foo\n<pre><div>bar</div>baz\nfred</pre>" ],
/*25-12*/[ "<div>test</div>\n<pre>foo<div>bar</div>baz\nfred</pre>", "<div>testfoo</div><pre><div>bar</div>baz\nfred</pre>",
/* 25-12*/[ "<div>test</div>\n<pre>foo<div>bar</div>baz\nfred</pre>", "<div>testfoo</div><pre><div>bar</div>baz\nfred</pre>",
"<div>test</div>foo<pre><div>bar</div>baz\nfred</pre>" ],
/* Some tests without <div>. These exercise the MoveBlock "right in left" */
/*26-00*/[ "test<pre>foobar\nbaz</pre>", "testfoobar\n<pre>baz</pre>" ],
/*27-01*/[ "test<pre><b>foobar\nbaz</b></pre>", "test<b>foobar\n</b><pre><b>baz</b></pre>" ],
/*28-02*/[ "test<pre><b>foo</b>bar\nbaz</pre>", "test<b>foo</b>bar\n<pre>baz</pre>" ],
/*29-03*/[ "test<pre><b>foo</b>\nbar</pre>", "test<b>foo</b>\n<pre>bar</pre>" ],
/*30-04*/[ "test<pre><b>foo\n</b>bar\nbaz</pre>", "test<b>foo\n</b><pre>bar\nbaz</pre>" ],
/*31-05*/[ "test<pre>foobar<br>baz</pre>", "testfoobar<br><pre>baz</pre>" ],
/*32-06*/[ "test<pre><b>foobar<br>baz</b></pre>", "test<b>foobar</b><br><pre><b>baz</b></pre>" ],
/*33-07*/[ "test<pre><div>foobar</div>baz</pre>", "testfoobar<pre>baz</pre>" ],
/*34-08*/[ "test<pre>foobar<div>baz</div></pre>", "testfoobar<pre><div>baz</div></pre>" ],
/*35-09*/[ "test<pre><div>foobar</div>baz\nfred</pre>", "testfoobar<pre>baz\nfred</pre>" ],
/*36-10*/[ "test<pre>foobar<div>baz</div>\nfred</pre>", "testfoobar<pre><div>baz</div>\nfred</pre>" ],
/*37-11*/[ "test<pre><div>foo\nbar</div>baz\nfred</pre>", "testfoo\n<pre><div>bar</div>baz\nfred</pre>" ],
/*38-12*/[ "test<pre>foo<div>bar</div>baz\nfred</pre>", "testfoo<pre><div>bar</div>baz\nfred</pre>" ],
/* 26-00*/[ "test<pre>foobar\nbaz</pre>", "testfoobar\n<pre>baz</pre>" ],
/* 27-01*/[ "test<pre><b>foobar\nbaz</b></pre>", "test<b>foobar\n</b><pre><b>baz</b></pre>" ],
/* 28-02*/[ "test<pre><b>foo</b>bar\nbaz</pre>", "test<b>foo</b>bar\n<pre>baz</pre>" ],
/* 29-03*/[ "test<pre><b>foo</b>\nbar</pre>", "test<b>foo</b>\n<pre>bar</pre>" ],
/* 30-04*/[ "test<pre><b>foo\n</b>bar\nbaz</pre>", "test<b>foo\n</b><pre>bar\nbaz</pre>" ],
/* 31-05*/[ "test<pre>foobar<br>baz</pre>", "testfoobar<br><pre>baz</pre>" ],
/* 32-06*/[ "test<pre><b>foobar<br>baz</b></pre>", "test<b>foobar</b><br><pre><b>baz</b></pre>" ],
/* 33-07*/[ "test<pre><div>foobar</div>baz</pre>", "testfoobar<pre>baz</pre>" ],
/* 34-08*/[ "test<pre>foobar<div>baz</div></pre>", "testfoobar<pre><div>baz</div></pre>" ],
/* 35-09*/[ "test<pre><div>foobar</div>baz\nfred</pre>", "testfoobar<pre>baz\nfred</pre>" ],
/* 36-10*/[ "test<pre>foobar<div>baz</div>\nfred</pre>", "testfoobar<pre><div>baz</div>\nfred</pre>" ],
/* 37-11*/[ "test<pre><div>foo\nbar</div>baz\nfred</pre>", "testfoo\n<pre><div>bar</div>baz\nfred</pre>" ],
/* 38-12*/[ "test<pre>foo<div>bar</div>baz\nfred</pre>", "testfoo<pre><div>bar</div>baz\nfred</pre>" ],
/*
* Some tests with <span class="pre">. Again 07, 09 and 11 use "JoinNodesSmart".
* All these exercise MoveBlock "left in right". The "right" is the surrounding "contenteditable" div.
*/
/*39-00*/[ "<div>test</div><span class=\"pre\">foobar\nbaz</span>", "<div>test<span class=\"pre\">foobar\n</span></div><span class=\"pre\">baz</span>" ],
/*40-01*/[ "<div>test</div><span class=\"pre\"><b>foobar\nbaz</b></span>", "<div>test<span class=\"pre\"><b>foobar\n</b></span></div><span class=\"pre\"><b>baz</b></span>" ],
/*41-02*/[ "<div>test</div><span class=\"pre\"><b>foo</b>bar\nbaz</span>", "<div>test<span class=\"pre\"><b>foo</b>bar\n</span></div><span class=\"pre\">baz</span>" ],
/*42-03*/[ "<div>test</div><span class=\"pre\"><b>foo</b>\nbar</span>", "<div>test<span class=\"pre\"><b>foo</b>\n</span></div><span class=\"pre\">bar</span>" ],
/*43-04*/[ "<div>test</div><span class=\"pre\"><b>foo\n</b>bar\nbaz</span>", "<div>test<span class=\"pre\"><b>foo\n</b></span></div><span class=\"pre\">bar\nbaz</span>" ],
/*44-05*/[ "<div>test</div><span class=\"pre\">foobar<br>baz</span>", "<div>test<span class=\"pre\">foobar</span><br><span class=\"pre\"></span></div><span class=\"pre\">baz</span>" ],
/*45-06*/[ "<div>test</div><span class=\"pre\"><b>foobar<br>baz</b></span>", "<div>test<span class=\"pre\"><b>foobar</b></span><br><span class=\"pre\"></span></div><span class=\"pre\"><b>baz</b></span>" ],
/*46-07*/[ "<div>test</div><span class=\"pre\"><div>foobar</div>baz</span>", "<div>testfoobar</div><span class=\"pre\">baz</span>" ],
/*47-08*/[ "<div>test</div><span class=\"pre\">foobar<div>baz</div></span>", "<div>test<span class=\"pre\">foobar</span></div><span class=\"pre\"><div>baz</div></span>" ],
/*48-09*/[ "<div>test</div><span class=\"pre\"><div>foobar</div>baz\nfred</span>", "<div>testfoobar</div><span class=\"pre\">baz\nfred</span>" ],
/*49-10*/[ "<div>test</div><span class=\"pre\">foobar<div>baz</div>\nfred</span>", "<div>test<span class=\"pre\">foobar</span></div><span class=\"pre\"><div>baz</div>\nfred</span>" ],
/*50-11*/[ "<div>test</div><span class=\"pre\"><div>foo\nbar</div>baz\nfred</span>", "<div>testfoo\nbar</div><span class=\"pre\">baz\nfred</span>" ], // BAD
/*51-12*/[ "<div>test</div><span class=\"pre\">foo<div>bar</div>baz\nfred</span>", "<div>test<span class=\"pre\">foo</span></div><span class=\"pre\"><div>bar</div>baz\nfred</span>" ],
/* 39-00*/[ "<div>test</div><span class=\"pre\">foobar\nbaz</span>", "<div>test<span class=\"pre\">foobar\n</span></div><span class=\"pre\">baz</span>" ],
/* 40-01*/[ "<div>test</div><span class=\"pre\"><b>foobar\nbaz</b></span>", "<div>test<span class=\"pre\"><b>foobar\n</b></span></div><span class=\"pre\"><b>baz</b></span>" ],
/* 41-02*/[ "<div>test</div><span class=\"pre\"><b>foo</b>bar\nbaz</span>", "<div>test<span class=\"pre\"><b>foo</b>bar\n</span></div><span class=\"pre\">baz</span>" ],
/* 42-03*/[ "<div>test</div><span class=\"pre\"><b>foo</b>\nbar</span>", "<div>test<span class=\"pre\"><b>foo</b>\n</span></div><span class=\"pre\">bar</span>" ],
/* 43-04*/[ "<div>test</div><span class=\"pre\"><b>foo\n</b>bar\nbaz</span>", "<div>test<span class=\"pre\"><b>foo\n</b></span></div><span class=\"pre\">bar\nbaz</span>" ],
/* 44-05*/[ "<div>test</div><span class=\"pre\">foobar<br>baz</span>", "<div>test<span class=\"pre\">foobar</span><br><span class=\"pre\"></span></div><span class=\"pre\">baz</span>" ],
/* 45-06*/[ "<div>test</div><span class=\"pre\"><b>foobar<br>baz</b></span>", "<div>test<span class=\"pre\"><b>foobar</b></span><br><span class=\"pre\"></span></div><span class=\"pre\"><b>baz</b></span>" ],
/* 46-07*/[ "<div>test</div><span class=\"pre\"><div>foobar</div>baz</span>", "<div>testfoobar</div><span class=\"pre\">baz</span>" ],
/* 47-08*/[ "<div>test</div><span class=\"pre\">foobar<div>baz</div></span>", "<div>test<span class=\"pre\">foobar</span></div><span class=\"pre\"><div>baz</div></span>" ],
/* 48-09*/[ "<div>test</div><span class=\"pre\"><div>foobar</div>baz\nfred</span>", "<div>testfoobar</div><span class=\"pre\">baz\nfred</span>" ],
/* 49-10*/[ "<div>test</div><span class=\"pre\">foobar<div>baz</div>\nfred</span>", "<div>test<span class=\"pre\">foobar</span></div><span class=\"pre\"><div>baz</div>\nfred</span>" ],
/* 50-11*/[ "<div>test</div><span class=\"pre\"><div>foo\nbar</div>baz\nfred</span>", "<div>testfoo\nbar</div><span class=\"pre\">baz\nfred</span>" ], // BAD
/* 51-12*/[ "<div>test</div><span class=\"pre\">foo<div>bar</div>baz\nfred</span>", "<div>test<span class=\"pre\">foo</span></div><span class=\"pre\"><div>bar</div>baz\nfred</span>" ],
/* Some tests with <div class="pre">. */
/*
@ -114,31 +114,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=772796
* but not in all cases: 07, 09, 11 are actually right. All cases use "JoinNodesSmart".
* Here we merely document the ugly behaviour. See bug 1191875 for more information.
*/
/*52-00*/[ "<div>test</div><div class=\"pre\">foobar\nbaz</div>", "<div class=\"pre\">testfoobar\nbaz</div>" ],
/*53-01*/[ "<div>test</div><div class=\"pre\"><b>foobar\nbaz</b></div>", "<div class=\"pre\">test<b>foobar\nbaz</b></div>" ],
/*54-02*/[ "<div>test</div><div class=\"pre\"><b>foo</b>bar\nbaz</div>", "<div class=\"pre\">test<b>foo</b>bar\nbaz</div>" ],
/*55-03*/[ "<div>test</div><div class=\"pre\"><b>foo</b>\nbar</div>", "<div class=\"pre\">test<b>foo</b>\nbar</div>" ],
/*56-04*/[ "<div>test</div><div class=\"pre\"><b>foo\n</b>bar\nbaz</div>", "<div class=\"pre\">test<b>foo\n</b>bar\nbaz</div>" ],
/*57-05*/[ "<div>test</div><div class=\"pre\">foobar<br>baz</div>", "<div class=\"pre\">testfoobar<br>baz</div>" ],
/*58-06*/[ "<div>test</div><div class=\"pre\"><b>foobar<br>baz</b></div>", "<div class=\"pre\">test<b>foobar<br>baz</b></div>" ],
/*59-07*/[ "<div>test</div><div class=\"pre\"><div>foobar</div>baz</div>", "<div>testfoobar</div><div class=\"pre\">baz</div>" ],
/*60-08*/[ "<div>test</div><div class=\"pre\">foobar<div>baz</div></div>", "<div class=\"pre\">testfoobar<div>baz</div></div>" ],
/*61-09*/[ "<div>test</div><div class=\"pre\"><div>foobar</div>baz\nfred</div>", "<div>testfoobar</div><div class=\"pre\">baz\nfred</div>" ],
/*62-10*/[ "<div>test</div><div class=\"pre\">foobar<div>baz</div>\nfred</div>", "<div class=\"pre\">testfoobar<div>baz</div>\nfred</div>" ],
/*63-11*/[ "<div>test</div><div class=\"pre\"><div>foo\nbar</div>baz\nfred</div>", "<div>testfoo\nbar</div><div class=\"pre\">baz\nfred</div>" ], // BAD
/*64-12*/[ "<div>test</div><div class=\"pre\">foo<div>bar</div>baz\nfred</div>", "<div class=\"pre\">testfoo<div>bar</div>baz\nfred</div>" ],
/* 52-00*/[ "<div>test</div><div class=\"pre\">foobar\nbaz</div>", "<div class=\"pre\">testfoobar\nbaz</div>" ],
/* 53-01*/[ "<div>test</div><div class=\"pre\"><b>foobar\nbaz</b></div>", "<div class=\"pre\">test<b>foobar\nbaz</b></div>" ],
/* 54-02*/[ "<div>test</div><div class=\"pre\"><b>foo</b>bar\nbaz</div>", "<div class=\"pre\">test<b>foo</b>bar\nbaz</div>" ],
/* 55-03*/[ "<div>test</div><div class=\"pre\"><b>foo</b>\nbar</div>", "<div class=\"pre\">test<b>foo</b>\nbar</div>" ],
/* 56-04*/[ "<div>test</div><div class=\"pre\"><b>foo\n</b>bar\nbaz</div>", "<div class=\"pre\">test<b>foo\n</b>bar\nbaz</div>" ],
/* 57-05*/[ "<div>test</div><div class=\"pre\">foobar<br>baz</div>", "<div class=\"pre\">testfoobar<br>baz</div>" ],
/* 58-06*/[ "<div>test</div><div class=\"pre\"><b>foobar<br>baz</b></div>", "<div class=\"pre\">test<b>foobar<br>baz</b></div>" ],
/* 59-07*/[ "<div>test</div><div class=\"pre\"><div>foobar</div>baz</div>", "<div>testfoobar</div><div class=\"pre\">baz</div>" ],
/* 60-08*/[ "<div>test</div><div class=\"pre\">foobar<div>baz</div></div>", "<div class=\"pre\">testfoobar<div>baz</div></div>" ],
/* 61-09*/[ "<div>test</div><div class=\"pre\"><div>foobar</div>baz\nfred</div>", "<div>testfoobar</div><div class=\"pre\">baz\nfred</div>" ],
/* 62-10*/[ "<div>test</div><div class=\"pre\">foobar<div>baz</div>\nfred</div>", "<div class=\"pre\">testfoobar<div>baz</div>\nfred</div>" ],
/* 63-11*/[ "<div>test</div><div class=\"pre\"><div>foo\nbar</div>baz\nfred</div>", "<div>testfoo\nbar</div><div class=\"pre\">baz\nfred</div>" ], // BAD
/* 64-12*/[ "<div>test</div><div class=\"pre\">foo<div>bar</div>baz\nfred</div>", "<div class=\"pre\">testfoo<div>bar</div>baz\nfred</div>" ],
/* Some tests with lists. These exercise the MoveBlock "left in right". */
/*65*/[ "<ul><pre><li>test</li>foobar\nbaz</pre></ul>", "<ul><pre><li>testfoobar\n</li>baz</pre></ul>" ],
/*66*/[ "<ul><pre><li>test</li><b>foobar\nbaz</b></pre></ul>", "<ul><pre><li>test<b>foobar\n</b></li><b>baz</b></pre></ul>" ],
/*67*/[ "<ul><pre><li>test</li><b>foo</b>bar\nbaz</pre></ul>", "<ul><pre><li>test<b>foo</b>bar\n</li>baz</pre></ul>" ],
/*68*/[ "<ul><pre><li>test</li><b>foo</b>\nbar</pre></ul>", "<ul><pre><li>test<b>foo</b>\n</li>bar</pre></ul>" ],
/*69*/[ "<ul><pre><li>test</li><b>foo\n</b>bar\nbaz</pre></ul>", "<ul><pre><li>test<b>foo\n</b></li>bar\nbaz</pre></ul>" ],
/* 65*/[ "<ul><pre><li>test</li>foobar\nbaz</pre></ul>", "<ul><pre><li>testfoobar\n</li>baz</pre></ul>" ],
/* 66*/[ "<ul><pre><li>test</li><b>foobar\nbaz</b></pre></ul>", "<ul><pre><li>test<b>foobar\n</b></li><b>baz</b></pre></ul>" ],
/* 67*/[ "<ul><pre><li>test</li><b>foo</b>bar\nbaz</pre></ul>", "<ul><pre><li>test<b>foo</b>bar\n</li>baz</pre></ul>" ],
/* 68*/[ "<ul><pre><li>test</li><b>foo</b>\nbar</pre></ul>", "<ul><pre><li>test<b>foo</b>\n</li>bar</pre></ul>" ],
/* 69*/[ "<ul><pre><li>test</li><b>foo\n</b>bar\nbaz</pre></ul>", "<ul><pre><li>test<b>foo\n</b></li>bar\nbaz</pre></ul>" ],
/* Last not least, some simple edge case tests. */
/*70*/[ "<div>test</div><pre>foobar\n</pre>baz", "<div>testfoobar\n</div>baz" ],
/*71*/[ "<div>test</div><pre>\nfoo\nbar</pre>", "<div>testfoo\n</div><pre>bar</pre>" ],
/*72*/[ "<div>test</div><pre>\n\nfoo\nbar</pre>", "<div>test</div><pre>foo\nbar</pre>", "<div>test\n</div><pre>foo\nbar</pre>" ],
/* 70*/[ "<div>test</div><pre>foobar\n</pre>baz", "<div>testfoobar\n</div>baz" ],
/* 71*/[ "<div>test</div><pre>\nfoo\nbar</pre>", "<div>testfoo\n</div><pre>bar</pre>" ],
/* 72*/[ "<div>test</div><pre>\n\nfoo\nbar</pre>", "<div>test</div><pre>foo\nbar</pre>", "<div>test\n</div><pre>foo\nbar</pre>" ],
];
/** Test for Bug 772796 **/
@ -197,9 +197,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=772796
}
synthesizeKey("KEY_ArrowLeft");
/* Strangely enough we need to hit "right arrow" three times to select two characters. */
synthesizeKey("KEY_ArrowRight", {shiftKey:true});
synthesizeKey("KEY_ArrowRight", {shiftKey:true});
synthesizeKey("KEY_ArrowRight", {shiftKey:true});
synthesizeKey("KEY_ArrowRight", {shiftKey: true});
synthesizeKey("KEY_ArrowRight", {shiftKey: true});
synthesizeKey("KEY_ArrowRight", {shiftKey: true});
synthesizeKey("KEY_Delete");
/* We always expect to the delete the "tf" in "testfoo". */

View file

@ -75,7 +75,7 @@ function isSpellingCheckOk() {
for (var i = 0; i < numWords; i++) {
var word = sel.getRangeAt(i);
is (word, gMisspeltWords[i], "Misspelling is what we think it is.");
is(word, gMisspeltWords[i], "Misspelling is what we think it is.");
if (word != gMisspeltWords[i])
return false;
}

View file

@ -57,7 +57,7 @@ SimpleTest.waitForFocus(function() {
SimpleTest.waitForFocus(function() {
var iframeSel = iframeWindow.getSelection();
iframeSel.removeAllRanges();
let span = iframe.contentDocument.querySelector('span');
let span = iframe.contentDocument.querySelector("span");
iframeSel.collapse(span, 1);
SpecialPowers.doCommand(iframeWindow, "cmd_pasteQuote");

View file

@ -51,7 +51,7 @@ SimpleTest.waitForFocus(function() {
var iframe = document.querySelector("iframe");
var iframeWindow = iframe.contentWindow;
var theEdit = iframe.contentDocument.body;
iframe.contentDocument.designMode='on';
iframe.contentDocument.designMode = "on";
iframe.contentDocument.body.offsetHeight;
iframeWindow.focus();
SimpleTest.waitForFocus(function() {

View file

@ -30,13 +30,12 @@ SimpleTest.requestFlakyTimeout("This test uses setTimeouts in order to fix an in
// Turn off spatial navigation because it hijacks arrow key events and VK_RETURN
// events.
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set":[["snav.enabled", false]]}, runTests);
SpecialPowers.pushPrefEnv({"set": [["snav.enabled", false]]}, runTests);
});
var textarea = document.getElementById("textarea");
var div = document.getElementById("div");
function hitEventLoop(aFunc, aTimes)
{
function hitEventLoop(aFunc, aTimes) {
if (--aTimes) {
setTimeout(hitEventLoop, 0, aFunc, aTimes);
} else {
@ -44,39 +43,38 @@ function hitEventLoop(aFunc, aTimes)
}
}
function doKeyEventTest(aElement, aElementDescription, aCallback)
{
function doKeyEventTest(aElement, aElementDescription, aCallback) {
aElement.focus();
aElement.scrollTop = 0;
hitEventLoop(function () {
hitEventLoop(function() {
is(aElement.scrollTop, 0,
aElementDescription + "'s scrollTop isn't 0");
synthesizeKey("KEY_Enter", {shiftKey: true, repeat: 6});
hitEventLoop(function () {
hitEventLoop(function() {
isnot(aElement.scrollTop, 0,
aElementDescription + " was not scrolled by inserting line breaks");
var scrollTop = aElement.scrollTop;
synthesizeKey("KEY_ArrowUp", {repeat: 5});
hitEventLoop(function () {
hitEventLoop(function() {
isnot(aElement.scrollTop, scrollTop,
aElementDescription + " was not scrolled by up key events");
synthesizeKey("KEY_ArrowDown", {repeat: 5});
hitEventLoop(function () {
hitEventLoop(function() {
is(aElement.scrollTop, scrollTop,
aElementDescription + " was not scrolled by down key events");
var longWord = "aaaaaaaaaaaaaaaaaaaa";
sendString(longWord);
hitEventLoop(function () {
hitEventLoop(function() {
isnot(aElement.scrollLeft, 0,
aElementDescription + " was not scrolled by typing long word");
var scrollLeft = aElement.scrollLeft;
var i;
synthesizeKey("KEY_ArrowLeft", {repeat: longWord.length});
hitEventLoop(function () {
synthesizeKey("KEY_ArrowLeft", {repeat: longWord.length});
hitEventLoop(function() {
isnot(aElement.scrollLeft, scrollLeft,
aElementDescription + " was not scrolled by left key events");
synthesizeKey("KEY_ArrowRight", {repeat: longWord.length});
hitEventLoop(function () {
synthesizeKey("KEY_ArrowRight", {repeat: longWord.length});
hitEventLoop(function() {
is(aElement.scrollLeft, scrollLeft,
aElementDescription + " was not scrolled by right key events");
aCallback();
@ -89,11 +87,10 @@ function doKeyEventTest(aElement, aElementDescription, aCallback)
}, 20);
}
function doCompositionTest(aElement, aElementDescription, aCallback)
{
function doCompositionTest(aElement, aElementDescription, aCallback) {
aElement.focus();
aElement.scrollTop = 0;
hitEventLoop(function () {
hitEventLoop(function() {
is(aElement.scrollTop, 0,
aElementDescription + "'s scrollTop isn't 0");
var str = "Web \u958b\u767a\u8005\u306e\u7686\u3055\u3093\u306f\u3001" +
@ -108,16 +105,16 @@ function doCompositionTest(aElement, aElementDescription, aCallback)
composition: {
string: str,
clauses: [
{ length: str.length, attr: COMPOSITION_ATTR_RAW_CLAUSE }
]
{ length: str.length, attr: COMPOSITION_ATTR_RAW_CLAUSE },
],
},
caret: { start: str.length, length: 0 }
caret: { start: str.length, length: 0 },
});
hitEventLoop(function () {
hitEventLoop(function() {
isnot(aElement.scrollTop, 0,
aElementDescription + " was not scrolled by composition");
synthesizeComposition({ type: "compositioncommit", data: "" });
hitEventLoop(function () {
hitEventLoop(function() {
is(aElement.scrollTop, 0,
aElementDescription + " was not scrolled back to the top by canceling composition");
aCallback();
@ -126,18 +123,17 @@ function doCompositionTest(aElement, aElementDescription, aCallback)
}, 20);
}
function runTests()
{
function runTests() {
doKeyEventTest(textarea, "textarea",
function () {
function() {
textarea.value = "";
doKeyEventTest(div, "div (contenteditable)",
function () {
function() {
div.innerHTML = "";
doCompositionTest(textarea, "textarea",
function () {
function() {
doCompositionTest(div, "div (contenteditable)",
function () {
function() {
SimpleTest.finish();
});
});

View file

@ -13,5 +13,5 @@ var text = document.createTextNode("");
div.insertBefore(text, div.firstChild);
getSelection().collapse(text, 0);
document.execCommand("inserthtml", false, "x");
is(div.textContent, 'x', "Empty textnodes should be editable");
is(div.textContent, "x", "Empty textnodes should be editable");
</script>

View file

@ -33,7 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=830600
var editor = SpecialPowers.wrap(t).editor;
editor.QueryInterface(Ci.nsIPlaintextEditor);
var origNewlineHandling = editor.newlineHandling;
editor.newlineHandling = Ci.nsIPlaintextEditor.eNewlinesStripSurroundingWhitespace
editor.newlineHandling = Ci.nsIPlaintextEditor.eNewlinesStripSurroundingWhitespace;
SimpleTest.waitForClipboard(str,
function() {
SpecialPowers.Cc["@mozilla.org/widget/clipboardhelper;1"]

View file

@ -35,7 +35,7 @@ sendKey("return");
// insert some text
document.execCommand("insertText", false, "abc");
is(test.innerHTML, '<h1>header1</h1><div>abc<br></div>',
is(test.innerHTML, "<h1>header1</h1><div>abc<br></div>",
"A paragraph automatically created after a CR at the end of an H1 should not be bold");
</script>

View file

@ -38,7 +38,7 @@ SimpleTest.waitForFocus(() => {
is(element.value, "b\u{9080}\u{e010f}\u{8fba}\u{e0101}a", "a isn't last character");
synthesizeKey("KEY_Backspace", {repeat: 3});
is(element.value, 'b', "cannot remove all IVS characters");
is(element.value, "b", "cannot remove all IVS characters");
element = document.getElementById("edit");
element.focus();
@ -51,7 +51,7 @@ SimpleTest.waitForFocus(() => {
is(element.textContent, "b\u{9080}\u{e010f}\u{8fba}\u{e0101}a", "a isn't last character");
synthesizeKey("KEY_Backspace", {repeat: 3});
is(element.textContent, 'b', "cannot remove all IVS characters");
is(element.textContent, "b", "cannot remove all IVS characters");
SimpleTest.finish();
});

View file

@ -30,7 +30,7 @@ function step() {
cwu.advanceTimeAndRefresh(100);
}
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set":[[smoothScrollPref, false]]}, startTest);
SpecialPowers.pushPrefEnv({"set": [[smoothScrollPref, false]]}, startTest);
}, win);
function startTest() {
// Make sure that pressing Space when a tabindex=-1 element is focused
@ -70,7 +70,7 @@ function startTest() {
oldY = win.scrollY;
synthesizeKey(" ", {}, win);
step()
step();
ok(win.scrollY >= oldY, "Page is scrolled down");

View file

@ -23,8 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=565392
SimpleTest.waitForExplicitFinish();
function runTests()
{
function runTests() {
var editor = document.getElementById("editor");
editor.focus();

View file

@ -20,8 +20,7 @@ SimpleTest.waitForExplicitFinish();
var gInputElement = document.getElementById("input");
function getEditor(aInputElement)
{
function getEditor(aInputElement) {
var editableElement = SpecialPowers.wrap(aInputElement);
ok(editableElement.editor, "There is no editor for the input element");
return editableElement.editor;
@ -29,8 +28,7 @@ function getEditor(aInputElement)
var gEditor;
function testNotGenerateCompositionByCreatedEvents(aEventInterface)
{
function testNotGenerateCompositionByCreatedEvents(aEventInterface) {
var compositionEvent = document.createEvent(aEventInterface);
if (compositionEvent.initCompositionEvent) {
compositionEvent.initCompositionEvent("compositionstart", true, true, window, "", "");
@ -61,8 +59,7 @@ function testNotGenerateCompositionByCreatedEvents(aEventInterface)
is(gInputElement.value, "", "Input element shouldn't be committed with a created compositionend event (" + aEventInterface + ")");
}
function doTests()
{
function doTests() {
gInputElement.focus();
gEditor = getEditor(gInputElement);

Some files were not shown because too many files have changed in this diff Show more