Bug 1648545: Part 1 - Move most of SpecialPowers to testing-common. r=ahal

Differential Revision: https://phabricator.services.mozilla.com/D119448
This commit is contained in:
Kris Maglione
2023-05-25 22:04:31 +00:00
parent 288f917737
commit 197ec67454
17 changed files with 25 additions and 42 deletions

View File

@@ -90,8 +90,8 @@ const intermittently_loaded_scripts = {
"resource://testing-common/BrowserTestUtilsChild.sys.mjs",
"resource://testing-common/ContentEventListenerChild.sys.mjs",
"resource://specialpowers/AppTestDelegateChild.sys.mjs",
"resource://specialpowers/SpecialPowersChild.sys.mjs",
"resource://specialpowers/WrapPrivileged.sys.mjs",
"resource://testing-common/SpecialPowersChild.sys.mjs",
"resource://testing-common/WrapPrivileged.sys.mjs",
]),
frameScripts: new Set([]),
processScripts: new Set([

View File

@@ -72,9 +72,9 @@ const intermittently_loaded_scripts = {
"chrome://remote/content/shared/Log.sys.mjs",
"resource://testing-common/BrowserTestUtilsChild.sys.mjs",
"resource://testing-common/ContentEventListenerChild.sys.mjs",
"resource://specialpowers/SpecialPowersChild.sys.mjs",
"resource://testing-common/SpecialPowersChild.sys.mjs",
"resource://specialpowers/AppTestDelegateChild.sys.mjs",
"resource://specialpowers/WrapPrivileged.sys.mjs",
"resource://testing-common/WrapPrivileged.sys.mjs",
]),
processScripts: new Set([]),
};

View File

@@ -234,9 +234,6 @@ async function synthesizeMouse(browser, link, event) {
browser,
[link, event],
(linkInContent, eventInContent) => {
const { EventUtils } = ChromeUtils.importESModule(
"resource://specialpowers/SpecialPowersEventUtils.sys.mjs"
);
const target = content.document.getElementById(linkInContent);
EventUtils.synthesizeMouseAtCenter(target, eventInContent, content);
return target.href;

View File

@@ -155,10 +155,7 @@ async function clickOn(selector, beforeContentFn) {
}
await SpecialPowers.spawn(lastTab.linkedBrowser, [selector], arg => {
const { EventUtils } = ChromeUtils.importESModule(
"resource://specialpowers/SpecialPowersEventUtils.sys.mjs"
);
/* eslint-env mozilla/chrome-script */
let element = content.document.querySelector(arg);
return EventUtils.synthesizeClick(element);
});

View File

@@ -13,9 +13,6 @@
function triggerKey() {
SpecialPowers.loadChromeScript(() => {
/* eslint-env mozilla/chrome-script */
const { EventUtils } = ChromeUtils.import(
"resource://specialpowers/SpecialPowersEventUtils.jsm"
);
var win = Services.wm.getMostRecentBrowserWindow();
for (let i = 0; i < 200; ++i) {
EventUtils.synthesizeKey("a", {}, win);

View File

@@ -26,9 +26,6 @@
// InputTaskManager properly
SpecialPowers.loadChromeScript(() => {
/* eslint-env mozilla/chrome-script */
const { EventUtils } = ChromeUtils.import(
"resource://specialpowers/SpecialPowersEventUtils.jsm"
);
var win = Services.wm.getMostRecentBrowserWindow();
EventUtils.synthesizeKey("a", {}, win);
EventUtils.synthesizeKey("b", {}, win);

View File

@@ -14,9 +14,6 @@
input.focus();
SpecialPowers.loadChromeScript(() => {
/* eslint-env mozilla/chrome-script */
const { EventUtils } = ChromeUtils.import(
"resource://specialpowers/SpecialPowersEventUtils.jsm"
);
var win = Services.wm.getMostRecentBrowserWindow();
EventUtils.synthesizeKey("a", {}, win);
});

View File

@@ -9,10 +9,7 @@ add_task(async function test_explicit_object_prototype() {
const url =
"http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_promise_userInteractionHandling.html";
await BrowserTestUtils.withNewTab(url, async browser => {
await ContentTask.spawn(browser, {}, async () => {
const { EventUtils } = ChromeUtils.importESModule(
"resource://specialpowers/SpecialPowersEventUtils.sys.mjs"
);
await SpecialPowers.spawn(browser, [], async () => {
const DOMWindowUtils = EventUtils._getDOMWindowUtils(content.window);
is(
DOMWindowUtils.isHandlingUserInput,

View File

@@ -29,7 +29,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=960820
// Check Components.stack, but first filter through the SpecialPowers junk.
var stack = SpecialPowers.wrap(SpecialPowers.Components).stack;
while (/specialpowers/.test(stack)) {
while (/testing-common/.test(stack)) {
stack = stack.caller;
}
ok(/clickCallback/.test(stack), "clickCallback should be reachable via Components.stack");

View File

@@ -31,14 +31,14 @@ this.specialpowers = class extends ExtensionAPI {
allFrames: true,
includeChrome: true,
child: {
esModuleURI: "resource://specialpowers/SpecialPowersChild.sys.mjs",
esModuleURI: "resource://testing-common/SpecialPowersChild.sys.mjs",
observers: [
"chrome-document-global-created",
"content-document-global-created",
],
},
parent: {
esModuleURI: "resource://specialpowers/SpecialPowersParent.sys.mjs",
esModuleURI: "resource://testing-common/SpecialPowersParent.sys.mjs",
},
});

View File

@@ -5,7 +5,7 @@
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
WrapPrivileged: "resource://specialpowers/WrapPrivileged.sys.mjs",
WrapPrivileged: "resource://testing-common/WrapPrivileged.sys.mjs",
});
const Cm = Components.manager;

View File

@@ -6,7 +6,7 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
WrapPrivileged: "resource://specialpowers/WrapPrivileged.sys.mjs",
WrapPrivileged: "resource://testing-common/WrapPrivileged.sys.mjs",
});
const Cm = Components.manager;

View File

@@ -12,14 +12,16 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
ContentTaskUtils: "resource://testing-common/ContentTaskUtils.sys.mjs",
MockColorPicker: "resource://specialpowers/MockColorPicker.sys.mjs",
MockFilePicker: "resource://specialpowers/MockFilePicker.sys.mjs",
MockPermissionPrompt: "resource://specialpowers/MockPermissionPrompt.sys.mjs",
MockColorPicker: "resource://testing-common/MockColorPicker.sys.mjs",
MockFilePicker: "resource://testing-common/MockFilePicker.sys.mjs",
MockPermissionPrompt:
"resource://testing-common/MockPermissionPrompt.sys.mjs",
PerTestCoverageUtils:
"resource://testing-common/PerTestCoverageUtils.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
SpecialPowersSandbox: "resource://specialpowers/SpecialPowersSandbox.sys.mjs",
WrapPrivileged: "resource://specialpowers/WrapPrivileged.sys.mjs",
SpecialPowersSandbox:
"resource://testing-common/SpecialPowersSandbox.sys.mjs",
WrapPrivileged: "resource://testing-common/WrapPrivileged.sys.mjs",
});
ChromeUtils.defineModuleGetter(
lazy,

View File

@@ -11,7 +11,8 @@ ChromeUtils.defineESModuleGetters(lazy, {
HiddenFrame: "resource://gre/modules/HiddenFrame.sys.mjs",
PerTestCoverageUtils:
"resource://testing-common/PerTestCoverageUtils.sys.mjs",
SpecialPowersSandbox: "resource://specialpowers/SpecialPowersSandbox.sys.mjs",
SpecialPowersSandbox:
"resource://testing-common/SpecialPowersSandbox.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {

View File

@@ -28,7 +28,7 @@ const SANDBOX_GLOBALS = [
"URL",
];
const EXTRA_IMPORTS = {
EventUtils: "resource://specialpowers/SpecialPowersEventUtils.sys.mjs",
EventUtils: "resource://testing-common/SpecialPowersEventUtils.sys.mjs",
};
let expectFail = false;

View File

@@ -15,10 +15,12 @@ FINAL_TARGET_FILES += [
]
FINAL_TARGET_FILES.content += [
"../modules/Assert.sys.mjs",
"content/AppTestDelegate.sys.mjs",
"content/AppTestDelegateChild.sys.mjs",
"content/AppTestDelegateParent.sys.mjs",
]
TESTING_JS_MODULES += [
"content/MockColorPicker.sys.mjs",
"content/MockFilePicker.sys.mjs",
"content/MockPermissionPrompt.sys.mjs",
@@ -29,9 +31,5 @@ FINAL_TARGET_FILES.content += [
"content/WrapPrivileged.sys.mjs",
]
TESTING_JS_MODULES += [
"content/MockFilePicker.sys.mjs",
]
with Files("**"):
BUG_COMPONENT = ("Testing", "Mochitest")

View File

@@ -128,7 +128,7 @@ async function submitFormAndGetResults(
) {
async function contentSubmitForm([contentFormAction, contentSelectorValues]) {
const { WrapPrivileged } = ChromeUtils.importESModule(
"resource://specialpowers/WrapPrivileged.sys.mjs"
"resource://testing-common/WrapPrivileged.sys.mjs"
);
let doc = content.document;
let form = doc.querySelector("form");