mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 06:08:24 +02:00
This reduces the amount of places where we need to specify the mozilla/frame-script environment. It does have the side effect of allowing those globals in the whole file, but that is what specifying the environment would do, and this is also for mochitest test files only. MozReview-Commit-ID: 1LLFbn6fFJR --HG-- extra : rebase_source : 82a6934d90bbbbd25f91b7b06bf4f9354e38865a
17 lines
678 B
JavaScript
17 lines
678 B
JavaScript
function hideSelectPopup(selectPopup, mode = "enter", win = window) {
|
|
let browser = win.gBrowser.selectedBrowser;
|
|
let selectClosedPromise = ContentTask.spawn(browser, null, function*() {
|
|
Cu.import("resource://gre/modules/SelectContentHelper.jsm");
|
|
return ContentTaskUtils.waitForCondition(() => !SelectContentHelper.open);
|
|
});
|
|
|
|
if (mode == "escape") {
|
|
EventUtils.synthesizeKey("KEY_Escape", { code: "Escape" }, win);
|
|
} else if (mode == "enter") {
|
|
EventUtils.synthesizeKey("KEY_Enter", { code: "Enter" }, win);
|
|
} else if (mode == "click") {
|
|
EventUtils.synthesizeMouseAtCenter(selectPopup.lastChild, { }, win);
|
|
}
|
|
|
|
return selectClosedPromise;
|
|
}
|