зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1806756 - part 2: Make split IME state tests to running part and checking part r=m_kato
For testing it in e10s mode, we need to run focus moving in remote process, but checking in the parent process. Therefore, we need to split the test code. Unfortunately, with this, we cannot check DOM `focus` event, but it's not required here since it depends on the DOM implementation and this test is not intended to check it. Finally, we can run same tests from mochitest-browser-chrome. Note that the new browser-chrome test fails the first check of the case `designMode == "off"` because of existing bug. Differential Revision: https://phabricator.services.mozilla.com/D171194
This commit is contained in:
Родитель
6a6ef2c8b4
Коммит
2d577e4f51
|
@ -1,12 +1,28 @@
|
|||
[DEFAULT]
|
||||
skip-if = os == 'andriod'
|
||||
|
||||
[browser_test_clipboardcache.js]
|
||||
skip-if =
|
||||
os == 'android' || (os == 'linux' && ccov) || tsan # Bug 1613516, the test consistently timeouts on Linux coverage builds.
|
||||
(os == 'linux' && ccov) || tsan # Bug 1613516, the test consistently timeouts on Linux coverage builds.
|
||||
os == "win" && bits == 32 && !debug # Bug 1759422
|
||||
os == "linux" # Bug 1792749
|
||||
[browser_test_ContentCache.js]
|
||||
skip-if = os == 'android'
|
||||
[browser_test_ime_state_on_focus_move_in_remote_content.js]
|
||||
support-files =
|
||||
file_ime_state_tests.html
|
||||
../file_ime_state_test_helper.js
|
||||
../file_test_ime_state_on_focus_move.js
|
||||
[browser_test_ime_state_in_contenteditable_on_focus_move_in_remote_content.js]
|
||||
support-files =
|
||||
file_ime_state_tests.html
|
||||
../file_ime_state_test_helper.js
|
||||
../file_test_ime_state_on_focus_move.js
|
||||
[browser_test_ime_state_in_designMode_on_focus_move_in_remote_content.js]
|
||||
support-files =
|
||||
file_ime_state_tests.html
|
||||
../file_ime_state_test_helper.js
|
||||
../file_test_ime_state_on_focus_move.js
|
||||
[browser_test_InputContextURI.js]
|
||||
skip-if = os == 'android'
|
||||
[browser_test_swipe_gesture.js]
|
||||
run-if = (os == 'mac' || os == 'win' || os == 'linux')
|
||||
skip-if =
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../file_ime_state_test_helper.js */
|
||||
/* import-globals-from ../file_test_ime_state_on_focus_move.js */
|
||||
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/widget/tests/browser/file_ime_state_test_helper.js",
|
||||
this
|
||||
);
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/widget/tests/browser/file_test_ime_state_on_focus_move.js",
|
||||
this
|
||||
);
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
"https://example.com/browser/widget/tests/browser/file_ime_state_tests.html",
|
||||
async function(browser) {
|
||||
const tipWrapper = new TIPWrapper(window);
|
||||
ok(
|
||||
tipWrapper.isAvailable(),
|
||||
"TextInputProcessor should've been initialized"
|
||||
);
|
||||
|
||||
// isnot is used in file_test_ime_state_on_focus_move.js, but it's not
|
||||
// defined as the alias of Assert.notEqual in browser-chrome tests.
|
||||
// Therefore, we need to define it here.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const isnot = Assert.notEqual;
|
||||
|
||||
async function runIMEStateOnFocusMoveTests(aDescription) {
|
||||
await (async function test_IMEState_without_focused_element() {
|
||||
const checker = new IMEStateWhenNoActiveElementTester(aDescription);
|
||||
const expectedData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[aDescription],
|
||||
description => {
|
||||
const runner = content.wrappedJSObject.createIMEStateWhenNoActiveElementTester(
|
||||
description
|
||||
);
|
||||
return runner.run(content.document, content.window);
|
||||
}
|
||||
);
|
||||
checker.check(expectedData);
|
||||
})();
|
||||
for (
|
||||
let index = 0;
|
||||
index < IMEStateOnFocusMoveTester.numberOfTests;
|
||||
++index
|
||||
) {
|
||||
const checker = new IMEStateOnFocusMoveTester(aDescription, index);
|
||||
const expectedData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[aDescription, index],
|
||||
(description, aIndex) => {
|
||||
content.wrappedJSObject.runner = content.wrappedJSObject.createIMEStateOnFocusMoveTester(
|
||||
description,
|
||||
aIndex,
|
||||
content.window
|
||||
);
|
||||
return content.wrappedJSObject.runner.prepareToRun(
|
||||
content.document.querySelector("div")
|
||||
);
|
||||
}
|
||||
);
|
||||
checker.prepareToCheck(expectedData, tipWrapper);
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
return content.wrappedJSObject.runner.run();
|
||||
});
|
||||
checker.check(expectedData);
|
||||
|
||||
if (checker.canTestOpenCloseState(expectedData)) {
|
||||
for (const defaultOpenState of [false, true]) {
|
||||
const expectedOpenStateData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[],
|
||||
() => {
|
||||
return content.wrappedJSObject.runner.prepareToRunOpenCloseTest(
|
||||
content.document.querySelector("div")
|
||||
);
|
||||
}
|
||||
);
|
||||
checker.prepareToCheckOpenCloseTest(
|
||||
defaultOpenState,
|
||||
expectedOpenStateData
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
return content.wrappedJSObject.runner.runOpenCloseTest();
|
||||
});
|
||||
checker.checkOpenCloseTest(expectedOpenStateData);
|
||||
}
|
||||
}
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.wrappedJSObject.runner.destroy();
|
||||
content.wrappedJSObject.runner = undefined;
|
||||
});
|
||||
checker.destroy();
|
||||
} // for loop iterating test of IMEStateOnFocusMoveTester
|
||||
} // definition of runIMEStateOnFocusMoveTests
|
||||
|
||||
// test for contentEditable="true"
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
content.document
|
||||
.querySelector("div")
|
||||
.setAttribute("contenteditable", "true");
|
||||
});
|
||||
await runIMEStateOnFocusMoveTests("in div[contenteditable]");
|
||||
|
||||
// test for contentEditable="false"
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
content.document
|
||||
.querySelector("div")
|
||||
.setAttribute("contenteditable", "false");
|
||||
});
|
||||
await runIMEStateOnFocusMoveTests('in div[contenteditable="false"]');
|
||||
}
|
||||
);
|
||||
});
|
|
@ -0,0 +1,119 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../file_ime_state_test_helper.js */
|
||||
/* import-globals-from ../file_test_ime_state_on_focus_move.js */
|
||||
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/widget/tests/browser/file_ime_state_test_helper.js",
|
||||
this
|
||||
);
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/widget/tests/browser/file_test_ime_state_on_focus_move.js",
|
||||
this
|
||||
);
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
"https://example.com/browser/widget/tests/browser/file_ime_state_tests.html",
|
||||
async function(browser) {
|
||||
const tipWrapper = new TIPWrapper(window);
|
||||
ok(
|
||||
tipWrapper.isAvailable(),
|
||||
"TextInputProcessor should've been initialized"
|
||||
);
|
||||
|
||||
// isnot is used in file_test_ime_state_on_focus_move.js, but it's not
|
||||
// defined as the alias of Assert.notEqual in browser-chrome tests.
|
||||
// Therefore, we need to define it here.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const isnot = Assert.notEqual;
|
||||
|
||||
async function runIMEStateOnFocusMoveTests(aDescription) {
|
||||
await (async function test_IMEState_without_focused_element() {
|
||||
const checker = new IMEStateWhenNoActiveElementTester(aDescription);
|
||||
const expectedData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[aDescription],
|
||||
description => {
|
||||
const runner = content.wrappedJSObject.createIMEStateWhenNoActiveElementTester(
|
||||
description
|
||||
);
|
||||
return runner.run(content.document, content.window);
|
||||
}
|
||||
);
|
||||
checker.check(expectedData);
|
||||
})();
|
||||
for (
|
||||
let index = 0;
|
||||
index < IMEStateOnFocusMoveTester.numberOfTests;
|
||||
++index
|
||||
) {
|
||||
const checker = new IMEStateOnFocusMoveTester(aDescription, index);
|
||||
const expectedData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[aDescription, index],
|
||||
(description, aIndex) => {
|
||||
content.wrappedJSObject.runner = content.wrappedJSObject.createIMEStateOnFocusMoveTester(
|
||||
description,
|
||||
aIndex,
|
||||
content.window
|
||||
);
|
||||
return content.wrappedJSObject.runner.prepareToRun(
|
||||
content.document.querySelector("div")
|
||||
);
|
||||
}
|
||||
);
|
||||
checker.prepareToCheck(expectedData, tipWrapper);
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
return content.wrappedJSObject.runner.run();
|
||||
});
|
||||
checker.check(expectedData);
|
||||
|
||||
if (checker.canTestOpenCloseState(expectedData)) {
|
||||
for (const defaultOpenState of [false, true]) {
|
||||
const expectedOpenStateData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[],
|
||||
() => {
|
||||
return content.wrappedJSObject.runner.prepareToRunOpenCloseTest(
|
||||
content.document.querySelector("div")
|
||||
);
|
||||
}
|
||||
);
|
||||
checker.prepareToCheckOpenCloseTest(
|
||||
defaultOpenState,
|
||||
expectedOpenStateData
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
return content.wrappedJSObject.runner.runOpenCloseTest();
|
||||
});
|
||||
checker.checkOpenCloseTest(expectedOpenStateData);
|
||||
}
|
||||
}
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.wrappedJSObject.runner.destroy();
|
||||
content.wrappedJSObject.runner = undefined;
|
||||
});
|
||||
checker.destroy();
|
||||
} // for loop iterating test of IMEStateOnFocusMoveTester
|
||||
} // definition of runIMEStateOnFocusMoveTests
|
||||
|
||||
// test designMode
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
content.document.designMode = "on";
|
||||
});
|
||||
await runIMEStateOnFocusMoveTests('in designMode="on"');
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
content.document.designMode = "off";
|
||||
// Hack for passing the first test.
|
||||
const input = content.document.createElement("input");
|
||||
content.document.body.appendChild(input);
|
||||
input.focus();
|
||||
input.remove();
|
||||
});
|
||||
await runIMEStateOnFocusMoveTests('in designMode="off"');
|
||||
}
|
||||
);
|
||||
});
|
|
@ -0,0 +1,126 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../file_ime_state_test_helper.js */
|
||||
/* import-globals-from ../file_test_ime_state_on_focus_move.js */
|
||||
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/widget/tests/browser/file_ime_state_test_helper.js",
|
||||
this
|
||||
);
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/widget/tests/browser/file_test_ime_state_on_focus_move.js",
|
||||
this
|
||||
);
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
"https://example.com/browser/widget/tests/browser/file_ime_state_tests.html",
|
||||
async function(browser) {
|
||||
const tipWrapper = new TIPWrapper(window);
|
||||
ok(
|
||||
tipWrapper.isAvailable(),
|
||||
"TextInputProcessor should've been initialized"
|
||||
);
|
||||
|
||||
// isnot is used in file_test_ime_state_on_focus_move.js, but it's not
|
||||
// defined as the alias of Assert.notEqual in browser-chrome tests.
|
||||
// Therefore, we need to define it here.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const isnot = Assert.notEqual;
|
||||
|
||||
async function runIMEStateOnFocusMoveTests(aDescription) {
|
||||
await (async function test_IMEState_without_focused_element() {
|
||||
const checker = new IMEStateWhenNoActiveElementTester(aDescription);
|
||||
const expectedData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[aDescription],
|
||||
description => {
|
||||
const runner = content.wrappedJSObject.createIMEStateWhenNoActiveElementTester(
|
||||
description
|
||||
);
|
||||
return runner.run(content.document, content.window);
|
||||
}
|
||||
);
|
||||
checker.check(expectedData);
|
||||
})();
|
||||
for (
|
||||
let index = 0;
|
||||
index < IMEStateOnFocusMoveTester.numberOfTests;
|
||||
++index
|
||||
) {
|
||||
const checker = new IMEStateOnFocusMoveTester(aDescription, index);
|
||||
const expectedData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[aDescription, index],
|
||||
(description, aIndex) => {
|
||||
content.wrappedJSObject.runner = content.wrappedJSObject.createIMEStateOnFocusMoveTester(
|
||||
description,
|
||||
aIndex,
|
||||
content.window
|
||||
);
|
||||
return content.wrappedJSObject.runner.prepareToRun(
|
||||
content.document.querySelector("div")
|
||||
);
|
||||
}
|
||||
);
|
||||
checker.prepareToCheck(expectedData, tipWrapper);
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
return content.wrappedJSObject.runner.run();
|
||||
});
|
||||
checker.check(expectedData);
|
||||
|
||||
if (checker.canTestOpenCloseState(expectedData)) {
|
||||
for (const defaultOpenState of [false, true]) {
|
||||
const expectedOpenStateData = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[],
|
||||
() => {
|
||||
return content.wrappedJSObject.runner.prepareToRunOpenCloseTest(
|
||||
content.document.querySelector("div")
|
||||
);
|
||||
}
|
||||
);
|
||||
checker.prepareToCheckOpenCloseTest(
|
||||
defaultOpenState,
|
||||
expectedOpenStateData
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
return content.wrappedJSObject.runner.runOpenCloseTest();
|
||||
});
|
||||
checker.checkOpenCloseTest(expectedOpenStateData);
|
||||
}
|
||||
}
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.wrappedJSObject.runner.destroy();
|
||||
content.wrappedJSObject.runner = undefined;
|
||||
});
|
||||
checker.destroy();
|
||||
} // for loop iterating test of IMEStateOnFocusMoveTester
|
||||
} // definition of runIMEStateOnFocusMoveTests
|
||||
|
||||
// test for normal contents.
|
||||
await runIMEStateOnFocusMoveTests("in non-editable container");
|
||||
|
||||
// test for removing contentEditable
|
||||
await SpecialPowers.spawn(browser, [], async () => {
|
||||
content.document
|
||||
.querySelector("div")
|
||||
.setAttribute("contenteditable", "true");
|
||||
content.document.querySelector("div").focus();
|
||||
await new Promise(resolve =>
|
||||
content.window.requestAnimationFrame(() =>
|
||||
content.window.requestAnimationFrame(resolve)
|
||||
)
|
||||
);
|
||||
content.document
|
||||
.querySelector("div")
|
||||
.removeAttribute("contenteditable");
|
||||
});
|
||||
await runIMEStateOnFocusMoveTests(
|
||||
"after removing contenteditable from the container"
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
|
@ -0,0 +1,22 @@
|
|||
<!doctype html>
|
||||
<html style="ime-mode: disabled;">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="file_ime_state_test_helper.js"></script>
|
||||
<script src="file_test_ime_state_on_focus_move.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../file_ime_state_test_helper.js */
|
||||
/* import-globals-from ../file_test_ime_state_on_focus_move.js */
|
||||
|
||||
function createIMEStateWhenNoActiveElementTester(aDescription) {
|
||||
return new IMEStateWhenNoActiveElementTester(aDescription);
|
||||
}
|
||||
function createIMEStateOnFocusMoveTester(aDescription, aIndex, aWindow = window) {
|
||||
return new IMEStateOnFocusMoveTester(aDescription, aIndex, aWindow);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body style="ime-mode: disabled;"><div style="ime-mode: disabled;"></div></body>
|
||||
</html>
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,56 +13,71 @@
|
|||
<div style="ime-mode: disabled;"></div>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from file_ime_state_test_helper.js */
|
||||
/* import-globals-from file_test_ime_state_on_focus_move.js */
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(async () => {
|
||||
const tipWrapper = new TIPWrapper(window);
|
||||
ok(tipWrapper.isAvailable(), "TextInputProcessor should've been initialized");
|
||||
// test for normal contents.
|
||||
|
||||
const container = document.querySelector("div");
|
||||
await runIMEStateOnFocusMoveTests(
|
||||
"in non-editable container",
|
||||
container,
|
||||
tipWrapper
|
||||
async function runIMEStateOnFocusMoveTests(aDescription) {
|
||||
{
|
||||
const runnerAndChecker = new IMEStateWhenNoActiveElementTester(aDescription);
|
||||
const expectedData = await runnerAndChecker.run(document);
|
||||
runnerAndChecker.check(expectedData);
|
||||
}
|
||||
for (let index = 0; index < IMEStateOnFocusMoveTester.numberOfTests; ++index) {
|
||||
const runnerAndChecker = new IMEStateOnFocusMoveTester(aDescription, index);
|
||||
const expectedData = await runnerAndChecker.prepareToRun(container);
|
||||
runnerAndChecker.prepareToCheck(expectedData, tipWrapper);
|
||||
await runnerAndChecker.run();
|
||||
runnerAndChecker.check(expectedData);
|
||||
if (runnerAndChecker.canTestOpenCloseState(expectedData)) {
|
||||
for (const defaultOpenState of [false, true]) {
|
||||
const expectedOpenStateData =
|
||||
await runnerAndChecker.prepareToRunOpenCloseTest(container);
|
||||
runnerAndChecker.prepareToCheckOpenCloseTest(
|
||||
defaultOpenState,
|
||||
expectedOpenStateData
|
||||
);
|
||||
await runnerAndChecker.runOpenCloseTest();
|
||||
runnerAndChecker.checkOpenCloseTest(expectedOpenStateData);
|
||||
}
|
||||
}
|
||||
runnerAndChecker.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// test for normal contents.
|
||||
await runIMEStateOnFocusMoveTests("in non-editable container");
|
||||
|
||||
// test for contentEditable="true"
|
||||
container.setAttribute("contenteditable", "true");
|
||||
await runIMEStateOnFocusMoveTests(
|
||||
"in div[contenteditable]",
|
||||
container,
|
||||
tipWrapper
|
||||
);
|
||||
await runIMEStateOnFocusMoveTests("in div[contenteditable]");
|
||||
|
||||
// test for contentEditable="false"
|
||||
container.setAttribute("contenteditable", "false");
|
||||
await runIMEStateOnFocusMoveTests(
|
||||
'in div[contenteditable="false"]',
|
||||
container,
|
||||
tipWrapper
|
||||
);
|
||||
await runIMEStateOnFocusMoveTests('in div[contenteditable="false"]');
|
||||
|
||||
// test for removing contentEditable
|
||||
container.setAttribute("contenteditable", "true");
|
||||
container.removeAttribute("contenteditable");
|
||||
await runIMEStateOnFocusMoveTests(
|
||||
"after removing contenteditable from the container",
|
||||
container,
|
||||
tipWrapper
|
||||
container.focus();
|
||||
await new Promise(resolve =>
|
||||
requestAnimationFrame(
|
||||
() => requestAnimationFrame(resolve)
|
||||
)
|
||||
);
|
||||
container.removeAttribute("contenteditable");
|
||||
await runIMEStateOnFocusMoveTests("after removing contenteditable from the container");
|
||||
|
||||
// test designMode
|
||||
document.designMode = "on";
|
||||
await runIMEStateOnFocusMoveTests(
|
||||
'in designMode="on"',
|
||||
container,
|
||||
tipWrapper
|
||||
);
|
||||
await runIMEStateOnFocusMoveTests('in designMode="on"');
|
||||
document.designMode = "off";
|
||||
await runIMEStateOnFocusMoveTests(
|
||||
'in designMode="off"',
|
||||
container,
|
||||
tipWrapper
|
||||
);
|
||||
await runIMEStateOnFocusMoveTests('in designMode="off"');
|
||||
|
||||
tipWrapper.destroy();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче