mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1489980 - Enable ESLint for editor/ - Manual fixes. r=masayuki
This enables the editor directory to be linted, and fixes the remaining issues raised by ESLint. Various rules were fixed here including, no-shadow, no-undef, no-unused-vars and others. I've generally gone conservative, disabling rules where it doesn't make sense to fix them (e.g. sometimes suggests use-services for tests, but it is only used once, or within a Chrome script). Depends on D5585 Differential Revision: https://phabricator.services.mozilla.com/D5587 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d5e3a6a9e5
commit
e824d800fb
@ -6,6 +6,7 @@
|
||||
**/crashtests/**
|
||||
# Also ignore reftest - specially crafted to produce expected output.
|
||||
**/reftest/**
|
||||
**/reftests/**
|
||||
|
||||
# Exclude expected objdirs.
|
||||
obj*/**
|
||||
@ -14,7 +15,6 @@ obj*/**
|
||||
# If you are enabling a directory, please add directory specific exclusions
|
||||
# below.
|
||||
docshell/**
|
||||
editor/**
|
||||
extensions/cookie/**
|
||||
extensions/spellcheck/**
|
||||
extensions/universalchardet/**
|
||||
@ -258,6 +258,9 @@ dom/xul/**
|
||||
# Third-party
|
||||
dom/media/webvtt/**
|
||||
|
||||
# Third-party
|
||||
editor/libeditor/tests/browserscope/**
|
||||
|
||||
# Third-party
|
||||
gfx/ots/**
|
||||
gfx/skia/**
|
||||
|
@ -60,6 +60,7 @@ function onSpellCheck(editableElement, callback) {
|
||||
waitingForEnded = !waitingForEnded;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
os.addObserver(observe, SPELL_CHECK_STARTED_TOPIC);
|
||||
|
@ -5,14 +5,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=519928
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 519928</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=519928">Mozilla Bug 519928</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe id="load-frame"></iframe>
|
||||
<iframe id="load-frame"></iframe>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
@ -38,11 +38,13 @@ function expectJSAllowed(allowed, testCondition, callback) {
|
||||
is(self_.ICanRunMyJS, allowed, msg);
|
||||
callback();
|
||||
}, {once: true});
|
||||
// eslint-disable-next-line no-useless-concat
|
||||
var iframeSrc = "<script>parent.parent.ICanRunMyJS = true;</scr" + "ipt>";
|
||||
innerFrame.srcdoc = iframeSrc;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
addLoadEvent(function() {
|
||||
var enterDesignMode = function() { document.designMode = "on"; };
|
||||
var leaveDesignMode = function() { document.designMode = "off"; };
|
||||
@ -82,6 +84,7 @@ addLoadEvent(function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
/* eslint-enable max-nested-callbacks */
|
||||
|
||||
function testDocumentDisabledJS() {
|
||||
window.ICanRunMyJS = false;
|
||||
@ -105,6 +108,7 @@ function testDocumentDisabledJS() {
|
||||
is(self_.ICanRunMyJS, false, msg);
|
||||
SimpleTest.finish();
|
||||
}, {once: true});
|
||||
// eslint-disable-next-line no-useless-concat
|
||||
var iframeSrc = "<script>parent.parent.ICanRunMyJS = true;</scr" + "ipt>";
|
||||
innerFrame.srcdoc = iframeSrc;
|
||||
}
|
||||
|
@ -4,5 +4,13 @@ module.exports = {
|
||||
"extends": [
|
||||
"plugin:mozilla/browser-test",
|
||||
"plugin:mozilla/mochitest-test",
|
||||
]
|
||||
],
|
||||
|
||||
"plugins": [
|
||||
"no-unsanitized",
|
||||
],
|
||||
|
||||
"rules": {
|
||||
"no-unsanitized/property": "off",
|
||||
},
|
||||
};
|
||||
|
@ -5,8 +5,8 @@ add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: kPageURL,
|
||||
}, async function(aBrowser) {
|
||||
await ContentTask.spawn(aBrowser, {}, async function() {
|
||||
}, async function(browser) {
|
||||
await ContentTask.spawn(browser, {}, async function() {
|
||||
var window = content.window.wrappedJSObject;
|
||||
var document = window.document;
|
||||
|
||||
@ -50,8 +50,8 @@ add_task(async function() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
async function testDirection(initialDir, aBrowser) {
|
||||
await ContentTask.spawn(aBrowser, {initialDir}, function({initialDir}) {
|
||||
async function testDirection(initDir, aBrowser) {
|
||||
await ContentTask.spawn(aBrowser, {initialDir: initDir}, function({initialDir}) {
|
||||
var window = content.window.wrappedJSObject;
|
||||
var document = window.document;
|
||||
|
||||
@ -74,7 +74,7 @@ add_task(async function() {
|
||||
is(window.inputEventCount, 0, "input event count must be 0 before");
|
||||
});
|
||||
await simulateCtrlShiftX(aBrowser);
|
||||
await ContentTask.spawn(aBrowser, {initialDir}, function({initialDir}) {
|
||||
await ContentTask.spawn(aBrowser, {initialDir: initDir}, function({initialDir}) {
|
||||
var window = content.window.wrappedJSObject;
|
||||
var expectedDir = initialDir == "ltr" ? "rtl" : "ltr";
|
||||
is(window.t.getAttribute("dir"), expectedDir,
|
||||
@ -93,7 +93,7 @@ add_task(async function() {
|
||||
is(window.inputEventCount, 1, "input event count must be 1 before");
|
||||
});
|
||||
await simulateCtrlShiftX(aBrowser);
|
||||
await ContentTask.spawn(aBrowser, {initialDir}, function({initialDir}) {
|
||||
await ContentTask.spawn(aBrowser, {initialDir: initDir}, function({initialDir}) {
|
||||
var window = content.window.wrappedJSObject;
|
||||
|
||||
is(window.inputEventCount, 2, "input event count must be 2 after");
|
||||
@ -111,7 +111,7 @@ add_task(async function() {
|
||||
});
|
||||
}
|
||||
|
||||
await testDirection("ltr", aBrowser);
|
||||
await testDirection("rtl", aBrowser);
|
||||
await testDirection("ltr", browser);
|
||||
await testDirection("rtl", browser);
|
||||
});
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ function boom() {
|
||||
}
|
||||
root.appendChild(document.createTextNode("Mozilla"));
|
||||
root.focus();
|
||||
cespan = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
|
||||
let cespan = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
|
||||
cespan.setAttributeNS(null, "contenteditable", "true");
|
||||
root.appendChild(cespan);
|
||||
try {
|
||||
|
@ -32,11 +32,10 @@ function copyCF_HTML(cfhtml, success, failure) {
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
}
|
||||
|
||||
var cb = Cc["@mozilla.org/widget/clipboard;1"].
|
||||
getService(Ci.nsIClipboard);
|
||||
var cb = SpecialPowers.Services.clipboard;
|
||||
|
||||
var counter = 0;
|
||||
function copyCF_HTML_worker(success, failure) {
|
||||
function copyCF_HTML_worker(successFn, failureFn) {
|
||||
if (++counter > 50) {
|
||||
ok(false, "Timed out while polling clipboard for pasted data");
|
||||
failure();
|
||||
@ -45,7 +44,7 @@ function copyCF_HTML(cfhtml, success, failure) {
|
||||
|
||||
var flavors = [CF_HTML];
|
||||
if (!cb.hasDataMatchingFlavors(flavors, flavors.length, cb.kGlobalClipboard)) {
|
||||
setTimeout(function() { copyCF_HTML_worker(success, failure); }, 100);
|
||||
setTimeout(function() { copyCF_HTML_worker(successFn, failureFn); }, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -59,7 +58,7 @@ function copyCF_HTML(cfhtml, success, failure) {
|
||||
trans.getTransferData(CF_HTML, data, {});
|
||||
data = SpecialPowers.wrap(data).value.QueryInterface(Ci.nsISupportsCString).data;
|
||||
} catch (e) {
|
||||
setTimeout(function() { copyCF_HTML_worker(success, failure); }, 100);
|
||||
setTimeout(function() { copyCF_HTML_worker(successFn, failureFn); }, 100);
|
||||
return;
|
||||
}
|
||||
success();
|
||||
|
@ -51,7 +51,7 @@ function test(edit, bsCount) {
|
||||
edit.focus();
|
||||
var sel = window.getSelection();
|
||||
sel.collapse(edit.childNodes[0], edit.textContent.length - 1);
|
||||
for (i = 0; i < bsCount; ++i) {
|
||||
for (let i = 0; i < bsCount; ++i) {
|
||||
synthesizeKey("KEY_Backspace");
|
||||
}
|
||||
is(edit.textContent, "ab", "The backspace key should delete the characters correctly");
|
||||
@ -92,7 +92,7 @@ function runTest() {
|
||||
* Once the Firefox Emoji font is ready, we can load that via @font-face
|
||||
* and expect these tests to work across all platforms.
|
||||
*/
|
||||
hasEmojiFont =
|
||||
let hasEmojiFont =
|
||||
(navigator.platform.indexOf("Mac") == 0 &&
|
||||
/10\.([7-9]|[1-9][0-9])/.test(navigator.oscpu));
|
||||
|
||||
|
@ -27,10 +27,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1053048
|
||||
var selectionListener = {
|
||||
count: 0,
|
||||
notifySelectionChanged(aDocument, aSelection, aReason) {
|
||||
ok(true, "selectionStart: " + textarea.selectionStart);
|
||||
ok(true, "selectionEnd: " + textarea.selectionEnd);
|
||||
this.count++;
|
||||
},
|
||||
ok(true, "selectionStart: " + textarea.selectionStart);
|
||||
ok(true, "selectionEnd: " + textarea.selectionEnd);
|
||||
this.count++;
|
||||
},
|
||||
};
|
||||
|
||||
// Move caret to the end of the textarea
|
||||
|
@ -34,9 +34,9 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
getSpellChecker().UpdateCurrentDictionary(() => {
|
||||
sendString(" ");
|
||||
setTimeout(function() {
|
||||
SimpleTest.executeSoon(function() {
|
||||
sendString("a");
|
||||
setTimeout(function() {
|
||||
SimpleTest.executeSoon(function() {
|
||||
synthesizeKey("KEY_Backspace");
|
||||
|
||||
onSpellCheck(div, function() {
|
||||
@ -47,13 +47,12 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}, 0);
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getEditor() {
|
||||
var Ci = SpecialPowers.Ci;
|
||||
var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
|
||||
return editingSession.getEditorForWindow(window);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1102906
|
||||
SimpleTest.waitForFocus( () => {
|
||||
let content = document.getElementById("content");
|
||||
let drag = document.getElementById("drag");
|
||||
let selection = window.getSelection();
|
||||
let selection = window.getSelection();
|
||||
|
||||
/* Perform drag-and-drop for an arbitrary content. The caret should be at
|
||||
the end of the contenteditable. */
|
||||
|
@ -34,9 +34,9 @@ SimpleTest.waitForFocus(function() {
|
||||
synthesizeKey("KEY_ArrowLeft");
|
||||
synthesizeKey("KEY_ArrowLeft");
|
||||
|
||||
setTimeout(function() {
|
||||
SimpleTest.executeSoon(function() {
|
||||
synthesizeKey("KEY_Backspace");
|
||||
setTimeout(function() {
|
||||
SimpleTest.executeSoon(function() {
|
||||
sendString(" ");
|
||||
|
||||
onSpellCheck(div, function() {
|
||||
@ -47,13 +47,12 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}, 0);
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getEditor() {
|
||||
var Ci = SpecialPowers.Ci;
|
||||
var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
|
||||
return editingSession.getEditorForWindow(window);
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ SimpleTest.waitForFocus(() => {
|
||||
}
|
||||
function isComposing() {
|
||||
return isNSEditableElement() ? SpecialPowers.wrap(aEditor)
|
||||
.editor
|
||||
.composing :
|
||||
SpecialPowers.wrap(window)
|
||||
.docShell
|
||||
.editor
|
||||
.composing;
|
||||
.editor
|
||||
.composing :
|
||||
SpecialPowers.wrap(window)
|
||||
.docShell
|
||||
.editor
|
||||
.composing;
|
||||
}
|
||||
function clear() {
|
||||
if (isNSEditableElement()) {
|
||||
|
@ -96,8 +96,8 @@ SimpleTest.waitForFocus(function() {
|
||||
div.focus();
|
||||
synthesizeMouse(div, 100, 2, {}); /* click behind and down */
|
||||
|
||||
var sel = window.getSelection();
|
||||
var selRange = sel.getRangeAt(0);
|
||||
sel = window.getSelection();
|
||||
selRange = sel.getRangeAt(0);
|
||||
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
|
||||
is(selRange.endOffset, 1, "offset should be 1");
|
||||
|
||||
@ -136,8 +136,8 @@ SimpleTest.waitForFocus(function() {
|
||||
div.focus();
|
||||
synthesizeMouse(div, 100, 2, {}); /* click behind and down */
|
||||
|
||||
var sel = window.getSelection();
|
||||
var selRange = sel.getRangeAt(0);
|
||||
sel = window.getSelection();
|
||||
selRange = sel.getRangeAt(0);
|
||||
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
|
||||
is(selRange.endOffset, 1, "offset should be 1");
|
||||
|
||||
|
@ -55,7 +55,7 @@ SimpleTest.waitForFocus(function() {
|
||||
synthesizeKey("KEY_ArrowRight");
|
||||
synthesizeKey("KEY_ArrowRight");
|
||||
synthesizeKey("KEY_Backspace");
|
||||
if (div.innerHTML, "x<br> ", "pre-wrap: Don't delete uncollapsed space");
|
||||
is(div.innerHTML, "x<br> ", "pre-wrap: Don't delete uncollapsed space");
|
||||
ok(getSelection().isCollapsed, "pre-wrap: Selection must be collapsed");
|
||||
is(getSelection().focusNode, div.lastChild,
|
||||
"pre-wrap: Focus must be in final text node");
|
||||
|
@ -23,7 +23,7 @@ SimpleTest.waitForFocus(() => {
|
||||
element.focus();
|
||||
let textNode = element.firstChild.firstChild;
|
||||
let node = textNode.splitText(0);
|
||||
node.parentNode.removeChild(node);
|
||||
node.remove();
|
||||
|
||||
ok(!node.parentNode, "parent must be null");
|
||||
|
||||
|
@ -8,6 +8,10 @@
|
||||
<script class="testbody" type="application/javascript">
|
||||
|
||||
function runTest() {
|
||||
const headingone = document.getElementById("headingone");
|
||||
const celltwo = document.getElementById("celltwo");
|
||||
const pasteframe = document.getElementById("pasteframe");
|
||||
|
||||
// Copy content from table.
|
||||
var selection = getSelection();
|
||||
var startRange = document.createRange();
|
||||
|
@ -55,13 +55,13 @@ SimpleTest.waitForFocus(() => {
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < 4; i++) {
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const kDescription = i == 0 ? "Backspace from immediately after the last character" :
|
||||
"Backspace from " + i + "th empty text node";
|
||||
editor.focus();
|
||||
initForBackspace(i);
|
||||
synthesizeKey("KEY_Backspace");
|
||||
var p = document.getElementById("p");
|
||||
let p = document.getElementById("p");
|
||||
ok(p, kDescription + ": <p> element shouldn't be removed by Backspace key press");
|
||||
is(p.tagName.toLowerCase(), "p", kDescription + ": <p> element shouldn't be removed by Backspace key press");
|
||||
// When Backspace key is pressed even in empty text nodes, Gecko should not remove empty text nodes for now
|
||||
@ -112,7 +112,7 @@ SimpleTest.waitForFocus(() => {
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < 4; i++) {
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const kDescription = i == 0 ? "Delete from immediately before the first character" :
|
||||
"Delete from " + i + "th empty text node";
|
||||
editor.focus();
|
||||
|
@ -16,6 +16,7 @@
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var outerEditor = document.getElementById("outerEditor");
|
||||
var innerEditor = document.getElementById("innerEditor");
|
||||
|
||||
function runTests() {
|
||||
outerEditor.focus();
|
||||
|
@ -68,7 +68,7 @@ SimpleTest.waitForFocus(function() {
|
||||
var theEdit = document.getElementById("editable");
|
||||
makeMailEditor();
|
||||
|
||||
for (i = 0; i < tests.length; i++) {
|
||||
for (let i = 0; i < tests.length; i++) {
|
||||
theEdit.innerHTML = tests[i][0];
|
||||
theEdit.focus();
|
||||
var theText = theEdit.firstChild.firstChild;
|
||||
|
@ -30,7 +30,6 @@ SimpleTest.expectAssertions(3, 3);
|
||||
SimpleTest.waitForFocus(function() {
|
||||
let selection = window.getSelection();
|
||||
let editor = document.getElementById("editor");
|
||||
let originalContent = editor.innerHTML;
|
||||
function onCharacterDataModified() {
|
||||
// Until removing all NBSPs which were inserted by the editor,
|
||||
// emulates Backspace key with "delete" command.
|
||||
|
@ -34,7 +34,6 @@ function editDoc() {
|
||||
}
|
||||
|
||||
function getEditor() {
|
||||
var Ci = SpecialPowers.Ci;
|
||||
var win = editDoc().defaultView;
|
||||
var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
|
||||
return editingSession.getEditorForWindow(win);
|
||||
|
@ -24,7 +24,6 @@ addLoadEvent(function() {
|
||||
var iframe = document.querySelector("iframe");
|
||||
var doc = iframe.contentDocument;
|
||||
var content = doc.body;
|
||||
var link = content.querySelector("a");
|
||||
function testCursor(post) {
|
||||
setTimeout(function() {
|
||||
var link = document.createElement("a");
|
||||
|
@ -44,7 +44,6 @@ function runTests() {
|
||||
var html = "<p>Content</p>";
|
||||
for (var i = 0; i < tags.length; ++i) {
|
||||
var tag = tags[i];
|
||||
var resultTag = tag.toUpperCase();
|
||||
|
||||
doc.body.innerHTML = html;
|
||||
testFormatBlock(tag, false, shouldSucceed);
|
||||
|
@ -12,7 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408231">Mozilla Bug 408231</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
@ -183,8 +183,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
||||
function callQueryCommandEnabled(cmdName) {
|
||||
var result;
|
||||
try {
|
||||
result = "" + document.queryCommandEnabled( cmdName );
|
||||
} catch ( error ) {
|
||||
result = "" + document.queryCommandEnabled(cmdName);
|
||||
} catch (error) {
|
||||
result = "name" in error ? error.name : "exception";
|
||||
}
|
||||
return result;
|
||||
@ -193,8 +193,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
||||
function callQueryCommandIndeterm(cmdName) {
|
||||
var result;
|
||||
try {
|
||||
result = "" + document.queryCommandIndeterm( cmdName );
|
||||
} catch ( error ) {
|
||||
result = "" + document.queryCommandIndeterm(cmdName);
|
||||
} catch (error) {
|
||||
result = "name" in error ? error.name : "exception";
|
||||
}
|
||||
return result;
|
||||
@ -203,8 +203,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
||||
function callQueryCommandState(cmdName) {
|
||||
var result;
|
||||
try {
|
||||
result = "" + document.queryCommandState( cmdName );
|
||||
} catch ( error ) {
|
||||
result = "" + document.queryCommandState(cmdName);
|
||||
} catch (error) {
|
||||
result = "name" in error ? error.name : "exception";
|
||||
}
|
||||
return result;
|
||||
@ -213,15 +213,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
||||
function callQueryCommandValue(cmdName) {
|
||||
var result;
|
||||
try {
|
||||
result = "" + document.queryCommandValue( cmdName );
|
||||
} catch ( error ) {
|
||||
result = "" + document.queryCommandValue(cmdName);
|
||||
} catch (error) {
|
||||
result = "name" in error ? error.name : "exception";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function testQueryCommand(expectedResults, fun, funName) {
|
||||
for (i = 0; i < expectedResults.length; i++) {
|
||||
for (let i = 0; i < expectedResults.length; i++) {
|
||||
var commandName = expectedResults[i][0];
|
||||
var expectedResult = expectedResults[i][1];
|
||||
var result = fun(commandName);
|
||||
@ -247,4 +247,3 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -52,10 +52,10 @@ SimpleTest.waitForFocus(function() {
|
||||
synthesizeKey("C", {accelKey: true});
|
||||
},
|
||||
function() {
|
||||
var ed = document.getElementById("editor");
|
||||
ed.focus();
|
||||
var ed1 = document.getElementById("editor");
|
||||
ed1.focus();
|
||||
synthesizeKey("V", {accelKey: true});
|
||||
isnot(ed.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1,
|
||||
isnot(ed1.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1,
|
||||
"Content should be pasted in HTML format");
|
||||
is(gPasteEvents, 2, "Two paste events must be fired");
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
<body>
|
||||
<div id="display"></div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
@ -7,14 +7,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=432225
|
||||
<title>Test for Bug 432225</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script src="spellcheck.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=432225">Mozilla Bug 432225</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
@ -37,7 +37,6 @@ function editDoc() {
|
||||
}
|
||||
|
||||
function getEditor() {
|
||||
var Ci = SpecialPowers.Ci;
|
||||
var win = editDoc().defaultView;
|
||||
var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
|
||||
return editingSession.getEditorForWindow(win);
|
||||
|
@ -28,11 +28,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471319
|
||||
|
||||
function doTest() {
|
||||
let t1 = SpecialPowers.wrap($("t1"));
|
||||
let editor = null;
|
||||
|
||||
// Test 1: Undo on an empty editor - the editor should not forget about
|
||||
// the bogus node
|
||||
t1Editor = t1.editor;
|
||||
let t1Editor = t1.editor;
|
||||
|
||||
// Did the editor recognize the new bogus node?
|
||||
t1Editor.undo(1);
|
||||
@ -42,7 +41,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471319
|
||||
// Test 2: Redo on an empty editor - the editor should not forget about
|
||||
// the bogus node
|
||||
let t2 = SpecialPowers.wrap($("t2"));
|
||||
t2Editor = t2.editor;
|
||||
let t2Editor = t2.editor;
|
||||
|
||||
// Did the editor recognize the new bogus node?
|
||||
t2Editor.redo(1);
|
||||
|
@ -128,4 +128,3 @@ addLoadEvent(runTest);
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -95,4 +95,3 @@ addLoadEvent(runTest);
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -27,7 +27,6 @@ addLoadEvent(runTest);
|
||||
var gMisspeltWords;
|
||||
|
||||
function getEditor() {
|
||||
var Ci = SpecialPowers.Ci;
|
||||
var win = window;
|
||||
var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
|
||||
return editingSession.getEditorForWindow(win);
|
||||
@ -47,8 +46,8 @@ function runTest() {
|
||||
var edit = document.getElementById("edit");
|
||||
edit.focus();
|
||||
|
||||
SpecialPowers.Cu.import(
|
||||
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
|
||||
const {onSpellCheck} = SpecialPowers.Cu.import(
|
||||
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", null);
|
||||
onSpellCheck(edit, function() {
|
||||
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
|
||||
"All misspellings before editing are accounted for.");
|
||||
|
@ -11,7 +11,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502673
|
||||
<title>Test for Bug 502673</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
|
||||
<body onload="doTest();">
|
||||
@ -33,17 +33,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502673
|
||||
listener.prototype =
|
||||
{
|
||||
NotifyDocumentWillBeDestroyed() {
|
||||
var editor = SpecialPowers.wrap(this.input).editor;
|
||||
editor.removeDocumentStateListener(this);
|
||||
},
|
||||
var editor = SpecialPowers.wrap(this.input).editor;
|
||||
editor.removeDocumentStateListener(this);
|
||||
},
|
||||
|
||||
NotifyDocumentCreated() {
|
||||
},
|
||||
},
|
||||
|
||||
NotifyDocumentStateChanged(aNowDirty) {
|
||||
var editor = SpecialPowers.wrap(this.input).editor;
|
||||
editor.removeDocumentStateListener(this);
|
||||
},
|
||||
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
|
||||
|
@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=520182
|
||||
<title>Test for Bug 520182</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=520182">Mozilla Bug 520182</a>
|
||||
@ -79,6 +79,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=520182
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/* eslint-disable no-useless-concat */
|
||||
|
||||
/** Test for Bug 520182 **/
|
||||
|
||||
const dataPayload = "foo<iframe src=\"data:text/html,bar\"></iframe>baz";
|
||||
@ -536,6 +538,7 @@ var tests = [
|
||||
];
|
||||
|
||||
function doNextTest() {
|
||||
/* global testCounter:true */
|
||||
if (typeof testCounter == "undefined")
|
||||
testCounter = 0;
|
||||
else if (++testCounter == tests.length) {
|
||||
@ -581,8 +584,7 @@ function runTest(test) {
|
||||
editor = SpecialPowers.wrap(win).docShell.editor;
|
||||
editor.pasteTransferable(trans);
|
||||
} else {
|
||||
var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(SpecialPowers.Ci.nsIClipboard);
|
||||
var clipboard = SpecialPowers.Services.clipboard;
|
||||
|
||||
clipboard.setData(trans, null, SpecialPowers.Ci.nsIClipboard.kGlobalClipboard);
|
||||
|
||||
|
@ -63,53 +63,54 @@ async function runTest() {
|
||||
} else {
|
||||
trans.addDataFlavor("text/unicode");
|
||||
}
|
||||
var clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
|
||||
var clip = SpecialPowers.Services.clipboard;
|
||||
clip.getData(trans, Ci.nsIClipboard.kGlobalClipboard);
|
||||
return trans;
|
||||
}
|
||||
|
||||
function makeTransferable(s, asHTML, target_id) {
|
||||
var e = document.getElementById("i2");
|
||||
var doc = e.contentDocument;
|
||||
if (asHTML) {
|
||||
doc.body.innerHTML = s;
|
||||
} else {
|
||||
var text = doc.createTextNode(s);
|
||||
doc.body.appendChild(text);
|
||||
}
|
||||
doc.designMode = "on";
|
||||
doc.defaultView.focus();
|
||||
var selection = doc.defaultView.getSelection();
|
||||
selection.removeAllRanges();
|
||||
if (!target_id) {
|
||||
selection.selectAllChildren(doc.body);
|
||||
} else {
|
||||
var range = document.createRange();
|
||||
range.selectNode(doc.getElementById(target_id));
|
||||
selection.addRange(range);
|
||||
}
|
||||
|
||||
// We cannot use plain strings, we have to use nsSupportsString.
|
||||
var supportsStringClass = SpecialPowers.Components.classes["@mozilla.org/supports-string;1"];
|
||||
var ssData = supportsStringClass.createInstance(Ci.nsISupportsString);
|
||||
|
||||
// Create the transferable.
|
||||
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
|
||||
trans.init(getLoadContext());
|
||||
|
||||
// Add the data to the transferable.
|
||||
if (asHTML) {
|
||||
trans.addDataFlavor("text/html");
|
||||
ssData.data = doc.body.innerHTML;
|
||||
trans.setTransferData("text/html", ssData, ssData.length * 2);
|
||||
} else {
|
||||
trans.addDataFlavor("text/unicode");
|
||||
ssData.data = doc.body.innerHTML;
|
||||
trans.setTransferData("text/unicode", ssData, ssData.length * 2);
|
||||
}
|
||||
|
||||
return trans;
|
||||
}
|
||||
// Commented out as the test for it below is also commented out.
|
||||
// function makeTransferable(s, asHTML, target_id) {
|
||||
// var e = document.getElementById("i2");
|
||||
// var doc = e.contentDocument;
|
||||
// if (asHTML) {
|
||||
// doc.body.innerHTML = s;
|
||||
// } else {
|
||||
// var text = doc.createTextNode(s);
|
||||
// doc.body.appendChild(text);
|
||||
// }
|
||||
// doc.designMode = "on";
|
||||
// doc.defaultView.focus();
|
||||
// var selection = doc.defaultView.getSelection();
|
||||
// selection.removeAllRanges();
|
||||
// if (!target_id) {
|
||||
// selection.selectAllChildren(doc.body);
|
||||
// } else {
|
||||
// var range = document.createRange();
|
||||
// range.selectNode(doc.getElementById(target_id));
|
||||
// selection.addRange(range);
|
||||
// }
|
||||
//
|
||||
// // We cannot use plain strings, we have to use nsSupportsString.
|
||||
// var supportsStringClass = SpecialPowers.Components.classes["@mozilla.org/supports-string;1"];
|
||||
// var ssData = supportsStringClass.createInstance(Ci.nsISupportsString);
|
||||
//
|
||||
// // Create the transferable.
|
||||
// var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
|
||||
// trans.init(getLoadContext());
|
||||
//
|
||||
// // Add the data to the transferable.
|
||||
// if (asHTML) {
|
||||
// trans.addDataFlavor("text/html");
|
||||
// ssData.data = doc.body.innerHTML;
|
||||
// trans.setTransferData("text/html", ssData, ssData.length * 2);
|
||||
// } else {
|
||||
// trans.addDataFlavor("text/unicode");
|
||||
// ssData.data = doc.body.innerHTML;
|
||||
// trans.setTransferData("text/unicode", ssData, ssData.length * 2);
|
||||
// }
|
||||
//
|
||||
// return trans;
|
||||
// }
|
||||
|
||||
async function copyToClipBoard(s, asHTML, target_id) {
|
||||
var e = document.getElementById("i2");
|
||||
|
@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=537046
|
||||
<title>Test for Bug 537046</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=537046">Mozilla Bug 537046</a>
|
||||
|
@ -106,10 +106,11 @@ function continueTest() {
|
||||
return;
|
||||
}
|
||||
var div = divs[current++];
|
||||
let type;
|
||||
if (div.textContent == "a") {
|
||||
var type = typeBCDEF;
|
||||
type = typeBCDEF;
|
||||
} else {
|
||||
var type = typeABCDEF;
|
||||
type = typeABCDEF;
|
||||
}
|
||||
var expectedHTML = "<div>abc</div><div>def<br></div>";
|
||||
var expectedText = "abc\ndef";
|
||||
|
@ -13,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=569988
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=569988">Mozilla Bug 569988</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
@ -25,10 +25,11 @@ SimpleTest.waitForFocus(runTest);
|
||||
|
||||
|
||||
function runTest() {
|
||||
/* eslint-env mozilla/frame-script */
|
||||
var script = SpecialPowers.loadChromeScript(function() {
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm", null);
|
||||
var gPromptInput = null;
|
||||
var os = Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService);
|
||||
var os = Services.obs;
|
||||
|
||||
os.addObserver(onPromptLoad, "common-dialog-loaded");
|
||||
os.addObserver(onPromptLoad, "tabmodal-dialog-loaded");
|
||||
@ -46,9 +47,7 @@ function runTest() {
|
||||
sendAsyncMessage("ok", [true, "onPromptFocus is called"]);
|
||||
gPromptInput.removeEventListener("focus", onPromptFocus);
|
||||
|
||||
var listenerService =
|
||||
Cc["@mozilla.org/eventlistenerservice;1"]
|
||||
.getService(Ci.nsIEventListenerService);
|
||||
var listenerService = Services.els;
|
||||
|
||||
var listener = {
|
||||
handleEvent: function _hv(aEvent) {
|
||||
@ -67,12 +66,11 @@ function runTest() {
|
||||
EventUtils.window = {};
|
||||
EventUtils._EU_Ci = Ci;
|
||||
EventUtils._EU_Cc = Cc;
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
Services.scriptloader
|
||||
.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
|
||||
EventUtils);
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {},
|
||||
gPromptInput.ownerDocument.defaultView);
|
||||
gPromptInput.ownerGlobal);
|
||||
}
|
||||
|
||||
addMessageListener("destroy", function() {
|
||||
|
@ -26,6 +26,7 @@ SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(runTest);
|
||||
|
||||
var gMisspeltWords;
|
||||
var onSpellCheck;
|
||||
|
||||
function getEditor() {
|
||||
return SpecialPowers.wrap(document.getElementById("edit")).editor;
|
||||
@ -35,7 +36,6 @@ function append(str) {
|
||||
var edit = document.getElementById("edit");
|
||||
edit.focus();
|
||||
edit.selectionStart = edit.selectionEnd = edit.value.length;
|
||||
var editor = getEditor();
|
||||
sendString(str);
|
||||
}
|
||||
|
||||
@ -44,8 +44,7 @@ function getLoadContext() {
|
||||
}
|
||||
|
||||
function paste(str) {
|
||||
var edit = document.getElementById("edit");
|
||||
var Cc = SpecialPowers.Cc, Ci = SpecialPowers.Ci;
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
|
||||
trans.init(getLoadContext());
|
||||
var s = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
|
||||
@ -105,8 +104,8 @@ function runTest() {
|
||||
var edit = document.getElementById("edit");
|
||||
edit.focus();
|
||||
|
||||
SpecialPowers.Cu.import(
|
||||
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
|
||||
onSpellCheck = SpecialPowers.Cu.import(
|
||||
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", null).onSpellCheck;
|
||||
onSpellCheck(edit, runOnFocus);
|
||||
}
|
||||
</script>
|
||||
|
@ -19,11 +19,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=612128
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/* eslint-disable no-useless-concat */
|
||||
|
||||
/** Test for Bug 612128 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
document.querySelector("input").focus();
|
||||
var threw = false;
|
||||
try {
|
||||
is(document.execCommand("inserthtml", null, "<span>f" + "oo</span>"),
|
||||
false, "The insertHTML command should return false");
|
||||
|
@ -11,8 +11,8 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
SpecialPowers.Cu.import(
|
||||
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
|
||||
const {onSpellCheck} = SpecialPowers.Cu.import(
|
||||
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", {});
|
||||
var x = document.getElementById("x");
|
||||
x.focus();
|
||||
onSpellCheck(x, function() {
|
||||
@ -27,7 +27,6 @@ function runTest() {
|
||||
var spellCheckTrueAgain = snapshotWindow(window);
|
||||
x.removeAttribute("spellcheck");
|
||||
var spellCheckNone = snapshotWindow(window);
|
||||
var after = snapshotWindow(window);
|
||||
var ret = compareSnapshots(spellCheckTrue, spellCheckFalse, false)[0];
|
||||
ok(ret,
|
||||
"Setting the spellcheck attribute to false should work");
|
||||
|
@ -23,7 +23,7 @@ bar</textarea>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["layout.word_select.eat_space_to_next_word", true],
|
||||
["browser.triple_click_selects_paragraph", false]]}, startTest);
|
||||
["browser.triple_click_selects_paragraph", false]]}, startTest);
|
||||
});
|
||||
function startTest() {
|
||||
var textarea = document.querySelector("textarea");
|
||||
|
@ -47,7 +47,7 @@ function clickEventHandler(aEvent) {
|
||||
// are a lot of functions and SimpleTest.executeSoon()s.
|
||||
SimpleTest.waitForFocus(function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["middlemouse.contentLoadURL", false],
|
||||
["middlemouse.paste", true]]}, startTest);
|
||||
["middlemouse.paste", true]]}, startTest);
|
||||
});
|
||||
function startTest() {
|
||||
frameWindow = iframe.contentWindow;
|
||||
@ -160,7 +160,6 @@ function runInputTests3() {
|
||||
|
||||
function runInputTests4() {
|
||||
var input = frameDocument.getElementById("input");
|
||||
var editor1 = frameDocument.getElementById("editor1");
|
||||
|
||||
// preventDefault() of input element's click event handler should prevent
|
||||
// middle click pasting in it.
|
||||
|
@ -152,7 +152,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=772796
|
||||
var testName;
|
||||
var theDiv;
|
||||
|
||||
for (i = 0; i < tests.length; i++) {
|
||||
for (let i = 0; i < tests.length; i++) {
|
||||
testName = "test" + i.toString();
|
||||
|
||||
/* Set up the selection. */
|
||||
|
@ -28,7 +28,6 @@ addLoadEvent(runTest);
|
||||
var gMisspeltWords;
|
||||
|
||||
function getEditor() {
|
||||
const Ci = SpecialPowers.Ci;
|
||||
var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
|
||||
return editingSession.getEditorForWindow(window);
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
function checkResult() {
|
||||
var iframe = document.querySelector("iframe");
|
||||
var iframeWindow = iframe.contentWindow;
|
||||
var theEdit = iframe.contentDocument.firstChild;
|
||||
theEdit.offsetHeight;
|
||||
is(theEdit.innerHTML,
|
||||
|
@ -38,7 +38,6 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
function checkResult() {
|
||||
var iframe = document.querySelector("iframe");
|
||||
var iframeWindow = iframe.contentWindow;
|
||||
var theEdit = iframe.contentDocument.body;
|
||||
theEdit.offsetHeight;
|
||||
is(theEdit.innerHTML,
|
||||
|
@ -16,7 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=795785
|
||||
<div id="div" contenteditable style="overflow: hidden; height: 3em; width: 5em;"></div>
|
||||
</div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
@ -68,7 +68,6 @@ function doKeyEventTest(aElement, aElementDescription, aCallback) {
|
||||
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() {
|
||||
isnot(aElement.scrollLeft, scrollLeft,
|
||||
|
@ -32,7 +32,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=830600
|
||||
t.value = "";
|
||||
var editor = SpecialPowers.wrap(t).editor;
|
||||
editor.QueryInterface(Ci.nsIPlaintextEditor);
|
||||
var origNewlineHandling = editor.newlineHandling;
|
||||
editor.newlineHandling = Ci.nsIPlaintextEditor.eNewlinesStripSurroundingWhitespace;
|
||||
SimpleTest.waitForClipboard(str,
|
||||
function() {
|
||||
|
@ -25,8 +25,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850043
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(() => {
|
||||
let fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
|
||||
getService(SpecialPowers.Ci.nsIFocusManager);
|
||||
let fm = SpecialPowers.Services.focus;
|
||||
|
||||
let element = document.getElementById("textarea");
|
||||
element.setSelectionRange(element.value.length, element.value.length);
|
||||
|
@ -18,9 +18,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=966155
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var win = window.open("file_bug966155.html", "", "test-966155");
|
||||
win.addEventListener("load", function() {
|
||||
runTest(win);
|
||||
var testWindow = window.open("file_bug966155.html", "", "test-966155");
|
||||
testWindow.addEventListener("load", function() {
|
||||
runTest(testWindow);
|
||||
}, {once: true});
|
||||
|
||||
function runTest(win) {
|
||||
|
@ -18,9 +18,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=966552
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var win = window.open("file_bug966552.html", "", "test-966552");
|
||||
win.addEventListener("load", function() {
|
||||
runTest(win);
|
||||
var testWindow = window.open("file_bug966552.html", "", "test-966552");
|
||||
testWindow.addEventListener("load", function() {
|
||||
runTest(testWindow);
|
||||
}, {once: true});
|
||||
|
||||
function runTest(win) {
|
||||
|
@ -33,7 +33,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
@ -49,8 +49,7 @@ function runTests() {
|
||||
}
|
||||
|
||||
function runTestsInternal() {
|
||||
var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
|
||||
getService(SpecialPowers.Ci.nsIFocusManager);
|
||||
var fm = SpecialPowers.Services.focus;
|
||||
// XXX using selCon for checking the visibility of the caret, however,
|
||||
// selCon is shared in document, cannot get the element of owner of the
|
||||
// caret from javascript?
|
||||
@ -60,20 +59,8 @@ function runTestsInternal() {
|
||||
QueryInterface(SpecialPowers.Ci.nsISelectionController);
|
||||
var selection = window.getSelection();
|
||||
|
||||
var inputText = document.getElementById("inputText");
|
||||
var inputTextReadonly = document.getElementById("inputTextReadonly");
|
||||
var inputButton = document.getElementById("inputButton");
|
||||
var button = document.getElementById("button");
|
||||
var editor = document.getElementById("editor");
|
||||
var inputTextInEditor = document.getElementById("inputTextInEditor");
|
||||
var inputTextReadonlyInEditor = document.getElementById("inputTextReadonlyInEditor");
|
||||
var inputButtonInEditor = document.getElementById("inputButtonInEditor");
|
||||
var noeditableInEditor = document.getElementById("noeditableInEditor");
|
||||
var spanInNoneditableInEditor = document.getElementById("spanInNoneditableInEditor");
|
||||
var inputTextInNoneditableInEditor = document.getElementById("inputTextInNoneditableInEditor");
|
||||
var inputTextReadonlyInNoneditableInEditor = document.getElementById("inputTextReadonlyInNoneditableInEditor");
|
||||
var inputButtonInNoneditableInEditor = document.getElementById("inputButtonInNoneditableInEditor");
|
||||
var buttonInNoneditableInEditor = document.getElementById("buttonInNoneditableInEditor");
|
||||
var spanInEditor = document.getElementById("spanInEditor");
|
||||
var otherEditor = document.getElementById("otherEditor");
|
||||
|
||||
@ -108,7 +95,7 @@ function runTestsInternal() {
|
||||
"there is no selection range when the other editor has focus");
|
||||
range = selection.getRangeAt(0);
|
||||
ok(range.collapsed, "the selection range isn't collapsed");
|
||||
var startNode = range.startContainer;
|
||||
startNode = range.startContainer;
|
||||
is(startNode.nodeType, Node.TEXT_NODE, "the caret isn't set to the text node");
|
||||
is(startNode, otherEditor.firstChild, "the caret isn't set to the other editor");
|
||||
ok(selCon.caretVisible, "caret isn't visible in the other editor");
|
||||
@ -119,7 +106,7 @@ function runTestsInternal() {
|
||||
is(selection.rangeCount, 1, "selection range is lost from the document");
|
||||
range = selection.getRangeAt(0);
|
||||
ok(range.collapsed, "the selection range isn't collapsed");
|
||||
var startNode = range.startContainer;
|
||||
startNode = range.startContainer;
|
||||
is(startNode.nodeType, Node.TEXT_NODE, "the caret isn't set to the first text node");
|
||||
// XXX maybe, the caret can stay on the other editor if it's better.
|
||||
is(startNode, editor.firstChild,
|
||||
@ -148,7 +135,7 @@ function runTestsInternal() {
|
||||
ok(range.collapsed, "the selection range isn't collapsed");
|
||||
is(range.startOffset, 5,
|
||||
"the caret is moved when the editor was focused (offset)");
|
||||
var startNode = range.startContainer;
|
||||
startNode = range.startContainer;
|
||||
is(startNode.nodeType, 3, "the caret isn't in text node");
|
||||
is(startNode.parentNode, spanInEditor,
|
||||
"the caret is moved when the editor was focused (node)");
|
||||
|
@ -14,7 +14,7 @@
|
||||
<p id="editor"contenteditable="true">content editable<input id="inputInEditor"><textarea id="textareaInEditor"></textarea></p>
|
||||
</div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
@ -27,16 +27,15 @@ SimpleTest.waitForFocus(runTests);
|
||||
const kLF = !navigator.platform.indexOf("Win") ? "\r\n" : "\n";
|
||||
|
||||
function runTests() {
|
||||
var fm = Cc["@mozilla.org/focus-manager;1"].
|
||||
getService(Ci.nsIFocusManager);
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm", null);
|
||||
var fm = Services.focus;
|
||||
|
||||
var listener = {
|
||||
handleEvent: function _hv(aEvent) {
|
||||
aEvent.preventDefault(); // prevent the browser default behavior
|
||||
},
|
||||
};
|
||||
var els = Cc["@mozilla.org/eventlistenerservice;1"].
|
||||
getService(Ci.nsIEventListenerService);
|
||||
var els = Services.els;
|
||||
els.addSystemEventListener(window, "keypress", listener, false);
|
||||
|
||||
var staticContent = document.getElementById("static");
|
||||
@ -153,12 +152,12 @@ function runTests() {
|
||||
// When key events are fired on unfocused editor.
|
||||
function testDispatchedKeyEvent(aTarget) {
|
||||
var targetDescription = " (dispatched to " + aTarget._description + ")";
|
||||
function dispatchKeyEvent(aKeyCode, aChar, aTarget) {
|
||||
function dispatchKeyEvent(aKeyCode, aChar, aDispatchTarget) {
|
||||
var keyEvent = document.createEvent("KeyboardEvent");
|
||||
keyEvent.initKeyEvent("keypress", true, true, null, false, false,
|
||||
false, false, aKeyCode,
|
||||
aChar ? aChar.charCodeAt(0) : 0);
|
||||
aTarget.dispatchEvent(keyEvent);
|
||||
aDispatchTarget.dispatchEvent(keyEvent);
|
||||
}
|
||||
|
||||
function checkValueForDispatchedKeyEvent(aElement, aInsertedText) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
function getEditor() {
|
||||
const Ci = SpecialPowers.Ci;
|
||||
let editframe = window.frames[0];
|
||||
return SpecialPowers.wrap(editframe).docShell.editingSession
|
||||
.getEditorForWindow(editframe);
|
||||
|
@ -17,7 +17,7 @@
|
||||
<iframe id="editor5" srcdoc="<html><body id='eventTarget'></body><script>document.designMode='on';</script></html>"></iframe>
|
||||
</div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
@ -66,14 +66,14 @@ function runTests() {
|
||||
ok(!aEvent.cancelable, "input event must not be cancelable");
|
||||
ok(aEvent.bubbles, "input event must be bubbles");
|
||||
if (SpecialPowers.getBoolPref("dom.event.highrestimestamp.enabled")) {
|
||||
var duration = Math.abs(window.performance.now() - aEvent.timeStamp);
|
||||
let duration = Math.abs(window.performance.now() - aEvent.timeStamp);
|
||||
ok(duration < 30 * 1000,
|
||||
"perhaps, timestamp wasn't set correctly :" + aEvent.timeStamp +
|
||||
" (expected it to be within 30s of the current time but it " +
|
||||
"differed by " + duration + "ms)");
|
||||
} else {
|
||||
var eventTime = new Date(aEvent.timeStamp);
|
||||
var duration = Math.abs(Date.now() - aEvent.timeStamp);
|
||||
let duration = Math.abs(Date.now() - aEvent.timeStamp);
|
||||
ok(duration < 30 * 1000,
|
||||
"perhaps, timestamp wasn't set correctly :" +
|
||||
eventTime.toLocaleString() +
|
||||
|
@ -14,7 +14,7 @@
|
||||
<textarea id="textarea"></textarea>
|
||||
</div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
@ -40,14 +40,14 @@ function runTests() {
|
||||
ok(!aEvent.cancelable, "input event must not be cancelable");
|
||||
ok(aEvent.bubbles, "input event must be bubbles");
|
||||
if (SpecialPowers.getBoolPref("dom.event.highrestimestamp.enabled")) {
|
||||
var duration = Math.abs(window.performance.now() - aEvent.timeStamp);
|
||||
let duration = Math.abs(window.performance.now() - aEvent.timeStamp);
|
||||
ok(duration < 30 * 1000,
|
||||
"perhaps, timestamp wasn't set correctly :" + aEvent.timeStamp +
|
||||
" (expected it to be within 30s of the current time but it " +
|
||||
"differed by " + duration + "ms)");
|
||||
} else {
|
||||
var eventTime = new Date(aEvent.timeStamp);
|
||||
var duration = Math.abs(Date.now() - aEvent.timeStamp);
|
||||
let duration = Math.abs(Date.now() - aEvent.timeStamp);
|
||||
ok(duration < 30 * 1000,
|
||||
"perhaps, timestamp wasn't set correctly :" +
|
||||
eventTime.toLocaleString() +
|
||||
|
@ -34,6 +34,8 @@ function doTest() {
|
||||
data: '<html><body><p id="contenteditable" contenteditable="true"></p></body></html>' };
|
||||
|
||||
var text = document.getElementById("text");
|
||||
var textarea = document.getElementById("textarea");
|
||||
var bold = document.getElementById("bold");
|
||||
var input = document.getElementById("input");
|
||||
var contenteditable = document.getElementById("contenteditable");
|
||||
|
||||
|
@ -13,18 +13,16 @@
|
||||
let seenPaste = false;
|
||||
let seenCopy = false;
|
||||
document.addEventListener("copy", function oncpy(e) {
|
||||
document.removeEventListener("copy", oncpy);
|
||||
e.clipboardData.setData("text/plain", "my text");
|
||||
e.preventDefault();
|
||||
seenCopy = true;
|
||||
});
|
||||
}, {once: true});
|
||||
document.addEventListener("paste", function onpst(e) {
|
||||
document.removeEventListener("paste", onpst);
|
||||
is(e.clipboardData.getData("text/plain"), "my text",
|
||||
"The correct text was read from the clipboard");
|
||||
e.preventDefault();
|
||||
seenPaste = true;
|
||||
});
|
||||
}, {once: true});
|
||||
|
||||
ok(SpecialPowers.wrap(document).execCommand("copy"),
|
||||
"Call should succeed");
|
||||
|
@ -13,13 +13,15 @@
|
||||
<div id="htmlEditor" contenteditable="true"><br></div>
|
||||
</div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
|
||||
/* eslint-disable no-nested-ternary */
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(runTests, window);
|
||||
|
||||
@ -33,8 +35,7 @@ function runTests() {
|
||||
document.execCommand("stylewithcss", false, "true");
|
||||
document.execCommand("defaultParagraphSeparator", false, "div");
|
||||
|
||||
var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
|
||||
getService(SpecialPowers.Ci.nsIFocusManager);
|
||||
var fm = SpecialPowers.Services.focus;
|
||||
|
||||
var capturingPhase = { fired: false, prevented: false };
|
||||
var bubblingPhase = { fired: false, prevented: false };
|
||||
@ -83,6 +84,7 @@ function runTests() {
|
||||
SpecialPowers.addSystemEventListener(window, "keypress", listener, true);
|
||||
SpecialPowers.addSystemEventListener(window, "keypress", listener, false);
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
function doTest(aElement, aDescription,
|
||||
aIsReadonly, aIsTabbable, aIsPlaintext) {
|
||||
function reset(aText) {
|
||||
|
@ -31,7 +31,8 @@ SimpleTest.waitForFocus(function() {
|
||||
isnot(tableNode.getAttribute("_moz_resizing"), "true",
|
||||
"_moz_resizing attribute shouldn't be true without object resizing");
|
||||
|
||||
ok(document.getElementById("tr2"), "id=tr2 should exist");
|
||||
let tr2 = document.getElementById("tr2");
|
||||
ok(tr2, "id=tr2 should exist");
|
||||
synthesizeMouse(tr2, 0, tr2.clientHeight / 2, {});
|
||||
ok(!document.getElementById("tr2"),
|
||||
"id=tr2 should be removed by a click in the row");
|
||||
|
@ -20,14 +20,14 @@ SimpleTest.waitForFocus(function() {
|
||||
let selection = document.getSelection();
|
||||
|
||||
try {
|
||||
let cell = SpecialPowers.unwrap(getTableEditor().getCellAt(undefined, 0, 0));
|
||||
SpecialPowers.unwrap(getTableEditor().getCellAt(undefined, 0, 0));
|
||||
ok(false, "nsITableEditor.getCellAt(undefined) should cause throwing an exception when editor does not have Selection");
|
||||
} catch (e) {
|
||||
ok(true, "nsITableEditor.getCellAt(undefined) should cause throwing an exception when editor does not have Selection");
|
||||
}
|
||||
|
||||
try {
|
||||
let cell = SpecialPowers.unwrap(getTableEditor().getTableSize(null, 0, 0));
|
||||
SpecialPowers.unwrap(getTableEditor().getTableSize(null, 0, 0));
|
||||
ok(false, "nsITableEditor.getCellAt(null) should cause throwing an exception when editor does not have Selection");
|
||||
} catch (e) {
|
||||
ok(true, "nsITableEditor.getCellAt(null) should cause throwing an exception when editor does not have Selection");
|
||||
|
@ -43,7 +43,7 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
// Set id to "test" for the argument for getCellIndexes().
|
||||
// Set data-row and data-col to expected indexes.
|
||||
kTests = [
|
||||
const kTests = [
|
||||
'<table><tr><td id="test" data-row="0" data-col="0">cell1-1</td><td>cell1-2</td><td>cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
|
||||
'<table><tr><td>cell1-1</td><td id="test" data-row="0" data-col="1">cell1-2</td><td>cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
|
||||
'<table><tr><td>cell1-1</td><td>cell1-2</td><td id="test" data-row="0" data-col="2">cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
|
||||
|
@ -19,21 +19,21 @@ SimpleTest.waitForFocus(function() {
|
||||
let editor = document.getElementById("content");
|
||||
|
||||
try {
|
||||
let ret = SpecialPowers.unwrap(getTableEditor().getFirstRow(undefined));
|
||||
SpecialPowers.unwrap(getTableEditor().getFirstRow(undefined));
|
||||
ok(false, "nsITableEditor.getFirstRow(undefined) should cause throwing an exception");
|
||||
} catch (e) {
|
||||
ok(true, "nsITableEditor.getFirstRow(undefined) should cause throwing an exception");
|
||||
}
|
||||
|
||||
try {
|
||||
let ret = SpecialPowers.unwrap(getTableEditor().getFirstRow(null));
|
||||
SpecialPowers.unwrap(getTableEditor().getFirstRow(null));
|
||||
ok(false, "nsITableEditor.getFirstRow(null) should cause throwing an exception");
|
||||
} catch (e) {
|
||||
ok(true, "nsITableEditor.getFirstRow(null) should cause throwing an exception");
|
||||
}
|
||||
|
||||
try {
|
||||
let ret = SpecialPowers.unwrap(getTableEditor().getFirstRow(editor));
|
||||
SpecialPowers.unwrap(getTableEditor().getFirstRow(editor));
|
||||
ok(false, "nsITableEditor.getFirstRow() should cause throwing an exception if given node is not in <table>");
|
||||
} catch (e) {
|
||||
ok(true, "nsITableEditor.getFirstRow() should cause throwing an exception if given node is not in <table>");
|
||||
@ -42,7 +42,7 @@ SimpleTest.waitForFocus(function() {
|
||||
// Set id to "test" for the argument for getFirstRow().
|
||||
// Set id to "expected" for the expected <tr> element result (if there is).
|
||||
// Set class of <table> to "hasAnonymousRow" if it does not has <tr> but will be anonymous <tr> element is created.
|
||||
kTests = [
|
||||
const kTests = [
|
||||
'<table id="test"><tr id="expected"><td>cell1-1</td><td>cell1-2</td></tr><tr><td>cell2-1</td><td>cell2-2</td></tr></table>',
|
||||
'<table><tr id="expected"><td id="test">cell1-1</td><td>cell1-2</td></tr><tr><td>cell2-1</td><td>cell2-2</td></tr></table>',
|
||||
'<table><tr id="expected"><td id="test">cell1-1</td><td>cell1-2</td></tr><tr><td>cell2-1</td><td>cell2-2</td></tr></table>',
|
||||
|
@ -35,7 +35,7 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
let tr = document.getElementById("r1");
|
||||
selection.setBaseAndExtent(tr, 0, tr, 1);
|
||||
cell = SpecialPowers.unwrap(getTableEditor().getFirstSelectedCell(rangeWrapper));
|
||||
let cell = SpecialPowers.unwrap(getTableEditor().getFirstSelectedCell(rangeWrapper));
|
||||
is(cell.getAttribute("id"), "c1-1",
|
||||
"#1-1 nsITableEditor.getFirstSelectedCell() should return the first cell element in the first row");
|
||||
|
||||
|
@ -43,7 +43,7 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
// Set id to "test" for the argument for getTableSize().
|
||||
// Set data-rows and data-cols to expected count of them.
|
||||
kTests = [
|
||||
const kTests = [
|
||||
'<table><tr><td id="test" data-rows="2" data-cols="3">cell1-1</td><td>cell1-2</td><td>cell1-3</td></tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr></table>',
|
||||
'<table><tr id="test" data-rows="2" data-cols="3"><td>cell1-1</td><td>cell1-2</td><td>cell1-3</td></tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr></table>',
|
||||
'<table id="test" data-rows="2" data-cols="3"><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</td></tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr></table>',
|
||||
|
@ -56,9 +56,9 @@ function* runTests() {
|
||||
is(sel.anchorOffset, expectOffset, "offset after " + cmd);
|
||||
}
|
||||
|
||||
function findChildNum(e, child) {
|
||||
function findChildNum(element, child) {
|
||||
var i = 0;
|
||||
var n = e.firstChild;
|
||||
var n = element.firstChild;
|
||||
while (n && n != child) {
|
||||
n = n.nextSibling;
|
||||
++i;
|
||||
|
@ -15,7 +15,7 @@
|
||||
<textarea id="textarea"></textarea>
|
||||
</div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
@ -34,8 +34,7 @@ const kIsWin = navigator.platform.indexOf("Win") == 0;
|
||||
const kIsLinux = navigator.platform.indexOf("Linux") == 0;
|
||||
|
||||
function runTests() {
|
||||
var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
|
||||
getService(SpecialPowers.Ci.nsIFocusManager);
|
||||
var fm = SpecialPowers.Services.focus;
|
||||
|
||||
var capturingPhase = { fired: false, prevented: false };
|
||||
var bubblingPhase = { fired: false, prevented: false };
|
||||
|
@ -52,7 +52,9 @@ var script;
|
||||
|
||||
var loadListener = function(evt) {
|
||||
if (loadCount == 0) {
|
||||
/* eslint-env mozilla/frame-script */
|
||||
script = SpecialPowers.loadChromeScript(function() {
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
var dir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("CurWorkD", Ci.nsIFile);
|
||||
|
@ -31,7 +31,9 @@ var script;
|
||||
|
||||
var loadListener = function(evt) {
|
||||
if (firstLoad) {
|
||||
/* eslint-env mozilla/frame-script */
|
||||
script = SpecialPowers.loadChromeScript(function() {
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
var dir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("CurWorkD", Ci.nsIFile);
|
||||
@ -44,7 +46,7 @@ var loadListener = function(evt) {
|
||||
.getService(Ci.mozISpellCheckingEngine);
|
||||
|
||||
// Install en-GB dictionary.
|
||||
en_GB = dir.clone();
|
||||
let en_GB = dir.clone();
|
||||
en_GB.append("en-GB");
|
||||
hunspell.addDirectory(en_GB);
|
||||
|
||||
|
@ -35,7 +35,9 @@ var onSpellCheck =
|
||||
/** Test for Bug 1205983 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(function() {
|
||||
/* eslint-env mozilla/frame-script */
|
||||
script = SpecialPowers.loadChromeScript(function() {
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
var dir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("CurWorkD", Ci.nsIFile);
|
||||
@ -65,7 +67,6 @@ function deFocus() {
|
||||
elem_de = document.getElementById("de-DE");
|
||||
|
||||
onSpellCheck(elem_de, function() {
|
||||
var Ci = SpecialPowers.Ci;
|
||||
var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
|
||||
editor_de = editingSession.getEditorForWindow(window);
|
||||
selcon_de = editor_de.selectionController;
|
||||
@ -89,6 +90,7 @@ function enFocus() {
|
||||
|
||||
onSpellCheck(elem_en, function() {
|
||||
var spellchecker = inlineSpellChecker.spellChecker;
|
||||
let currentDictonary;
|
||||
try {
|
||||
currentDictonary = spellchecker.GetCurrentDictionary();
|
||||
} catch (e) {}
|
||||
@ -113,8 +115,9 @@ function enFocus() {
|
||||
|
||||
// After removal, the de_DE editor should refresh the spelling with en-US.
|
||||
onSpellCheck(elem_de, function() {
|
||||
var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
|
||||
is(sel.toString(), "heute" + "ist" + "ein" + "guter",
|
||||
var endSel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
|
||||
// eslint-disable-next-line no-useless-concat
|
||||
is(endSel.toString(), "heute" + "ist" + "ein" + "guter",
|
||||
"some misspelled words expected: heute ist ein guter");
|
||||
|
||||
// If we don't reset this, we cause massive leaks.
|
||||
|
@ -42,6 +42,8 @@ var onSpellCheck =
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(function() {
|
||||
/* global browserElement */
|
||||
/* eslint-env mozilla/frame-script */
|
||||
script = SpecialPowers.loadChromeScript(function() {
|
||||
var chromeWin = browserElement.ownerGlobal.docShell
|
||||
.rootTreeItem.domWindow
|
||||
@ -50,6 +52,7 @@ SimpleTest.waitForFocus(function() {
|
||||
contextMenu.addEventListener("popupshown",
|
||||
() => sendAsyncMessage("popupshown"));
|
||||
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
var dir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("CurWorkD", Ci.nsIFile);
|
||||
@ -62,7 +65,7 @@ SimpleTest.waitForFocus(function() {
|
||||
.getService(Ci.mozISpellCheckingEngine);
|
||||
|
||||
// Install de-DE dictionary.
|
||||
de_DE = dir.clone();
|
||||
let de_DE = dir.clone();
|
||||
de_DE.append("de-DE");
|
||||
hunspell.addDirectory(de_DE);
|
||||
|
||||
@ -101,6 +104,7 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
// Check that the German dictionary is loaded and that the spell check has worked.
|
||||
is(currentDictonary, "de-DE", "expected de-DE");
|
||||
// eslint-disable-next-line no-useless-concat
|
||||
is(getMisspelledWords(editor_de), "today" + "is" + "a" + "good" + "day", "some misspelled words expected: today is a good day");
|
||||
|
||||
// Focus again, just to be sure that the context-click won't trigger another spell check.
|
||||
@ -120,12 +124,14 @@ function handlePopup() {
|
||||
onSpellCheck(elem_de, function() {
|
||||
var inlineSpellChecker = editor_de.getInlineSpellChecker(true);
|
||||
var spellchecker = inlineSpellChecker.spellChecker;
|
||||
let currentDictonary;
|
||||
try {
|
||||
currentDictonary = spellchecker.GetCurrentDictionary();
|
||||
} catch (e) {}
|
||||
|
||||
// Check that the English dictionary is loaded and that the spell check has worked.
|
||||
is(currentDictonary, "en-US", "expected en-US");
|
||||
// eslint-disable-next-line no-useless-concat
|
||||
is(getMisspelledWords(editor_de), "heute" + "ist" + "ein" + "guter", "some misspelled words expected: heute ist ein guter");
|
||||
|
||||
// Remove the fake de_DE dictionary again.
|
||||
|
@ -29,8 +29,9 @@ var spellchecker;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(function() {
|
||||
SpecialPowers.Cu.import(
|
||||
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
|
||||
var onSpellCheck =
|
||||
SpecialPowers.Cu.import(
|
||||
"resource://testing-common/AsyncSpellCheckTestHelper.jsm", null).onSpellCheck;
|
||||
|
||||
var elem = document.getElementById("en-US");
|
||||
elem.focus();
|
||||
|
@ -12,7 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=678842
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=678842">Mozilla Bug 678842</a>
|
||||
<p id="display"></p>
|
||||
<iframe id="content"></iframe>
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
@ -30,7 +30,9 @@ var script;
|
||||
|
||||
var loadListener = function(evt) {
|
||||
if (firstLoad) {
|
||||
/* eslint-env mozilla/frame-script */
|
||||
script = SpecialPowers.loadChromeScript(function() {
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
var dir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("CurWorkD", Ci.nsIFile);
|
||||
@ -43,7 +45,7 @@ var loadListener = function(evt) {
|
||||
.getService(Ci.mozISpellCheckingEngine);
|
||||
|
||||
// Install en-GB dictionary.
|
||||
en_GB = dir.clone();
|
||||
let en_GB = dir.clone();
|
||||
en_GB.append("en-GB");
|
||||
hunspell.addDirectory(en_GB);
|
||||
|
||||
|
@ -35,7 +35,9 @@ var onSpellCheck =
|
||||
/** Test for Bug 697981 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(function() {
|
||||
/* eslint-env mozilla/frame-script */
|
||||
script = SpecialPowers.loadChromeScript(function() {
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
var dir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("CurWorkD", Ci.nsIFile);
|
||||
@ -90,6 +92,7 @@ function enFocus() {
|
||||
|
||||
onSpellCheck(elem_en, function() {
|
||||
var spellchecker = inlineSpellChecker.spellChecker;
|
||||
let currentDictonary;
|
||||
try {
|
||||
currentDictonary = spellchecker.GetCurrentDictionary();
|
||||
} catch (e) {}
|
||||
@ -120,6 +123,7 @@ function enFocus() {
|
||||
|
||||
// Check that the default English dictionary is loaded and that the spell check has worked.
|
||||
is(currentDictonary, "en-US", "expected en-US");
|
||||
// eslint-disable-next-line no-useless-concat
|
||||
is(getMisspelledWords(editor_de), "heute" + "ist" + "ein" + "guter",
|
||||
"some misspelled words expected: heute ist ein guter");
|
||||
|
||||
|
@ -32,7 +32,9 @@ var script;
|
||||
var loadListener = function(evt) {
|
||||
|
||||
if (firstLoad) {
|
||||
/* eslint-env mozilla/frame-script */
|
||||
script = SpecialPowers.loadChromeScript(function() {
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
var dir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("CurWorkD", Ci.nsIFile);
|
||||
|
Loading…
Reference in New Issue
Block a user