Files
palemoon27/dom/html/test/browser_fullscreen-contextmenu-esc.js
T
roytam1 3e34b8d21b import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1213818 - Align document.title for SVG documents with HTML spec; r=bz (fb60e8c048)
- Bug 1234170 - WebSocket should check if the channel has been opened before send the 'close' notification to the WebSocketEventService, r=jduell (4bfd6f3f3f)
- Bug 1245261 - Use an atomic to safely access gcTriggerBytes; r=jonco (f9c80d47e1)
- Bug 1243001 part 1. Remove the dead WrappedWorkerRunnable class from Promise code. r=peterv (9f8c758723)
- Bug 1243001 part 2. Make Promise an empty [NoInterfaceObject] interface when SPIDERMONKEY_PROMISE is defined. r=peterv (6be034ee59)
- Bug 1243001 part 3. Turn off the IDL bits of PromiseDebugging when SPIDERMONKEY_PROMISE is defined. r=peterv (114241ddd6)
- Bug 1243001 part 4. Switch to using MaybeResolve/MaybeReject instead of ResolveInternal/RejectInternal for PromiseWorkerProxy. r=peterv (ca8faf02f8)
- Bug 1243114 - Convert PromiseCapability::mPromise to a rooted JSObject* instead of a rooted JS::Value. r=bz (e4c907e5c2)
- Bug 1243001 part 5. Get rid of most of the dom::Promise methods when SPIDERMONKEY_PROMISE is defined, and reimplement the rest in terms of SpiderMonkey Promise. r=peterv (693a61e5a2)
- Bug 1242054. Get rid of AbortablePromise, so we can move Promise into SpiderMonkey more easily. r=khuey (6a0200e625)
- Bug 1243001 part 6. Implement Promise::AppendNativeHandler in the SPIDERMONKEY_PROMISE world. r=peterv (7c3a6390f9)
- Bug 1243001 part 7. Stop wrappercaching dom::Promise when SPIDERMONKEY_PROMISE is defined. r=peterv (be1bd9b33f)
- Bug 1243001 part 8. Tell SpiderMonkey to put its promise jobs into the CycleCollectedJSRuntime job queue. r=peterv (192e6a551c)
- Bug 1156880 - Null check the prescontext in nsDOMWindowUtils::AdvanceTimeAndRefresh; r=mstange (11f1a39f22)
- Bug 1191597 part 1 - Add head.js and dummy page for browser chrome test. r=smaug (5257870dd3)
- Bug 1191597 part 2 - Convert fullscreen-esc-context-menu to a browser chrome test. r=smaug (e1c0fe84a4)
2023-11-08 17:17:49 +08:00

106 lines
3.8 KiB
JavaScript

"use strict";
function frameScript() {
addMessageListener("Test:RequestFullscreen", () => {
content.document.body.mozRequestFullScreen();
});
content.document.addEventListener("mozfullscreenchange", () => {
sendAsyncMessage("Test:FullscreenChanged", content.document.mozFullScreen);
});
addMessageListener("Test:QueryFullscreenState", () => {
sendAsyncMessage("Test:FullscreenState", content.document.mozFullScreen);
});
function waitUntilActive() {
let doc = content.document;
if (doc.docShell.isActive && doc.hasFocus()) {
sendAsyncMessage("Test:Activated");
} else {
setTimeout(waitUntilActive, 10);
}
}
waitUntilActive();
}
var gMessageManager;
function listenOneMessage(aMsg, aListener) {
function listener({ data }) {
gMessageManager.removeMessageListener(aMsg, listener);
aListener(data);
}
gMessageManager.addMessageListener(aMsg, listener);
}
function promiseOneMessage(aMsg) {
return new Promise(resolve => listenOneMessage(aMsg, resolve));
}
function captureUnexpectedFullscreenChange() {
ok(false, "Caught an unexpected fullscreen change");
}
const kPage = "http://example.org/browser/dom/html/test/dummy_page.html";
add_task(function* () {
yield pushPrefs(
["full-screen-api.transition-duration.enter", "0 0"],
["full-screen-api.transition-duration.leave", "0 0"]);
let tab = gBrowser.addTab(kPage);
registerCleanupFunction(() => gBrowser.removeTab(tab));
let browser = tab.linkedBrowser;
gBrowser.selectedTab = tab;
yield waitForDocLoadComplete();
gMessageManager = browser.messageManager;
gMessageManager.loadFrameScript(
"data:,(" + frameScript.toString() + ")();", false);
// Wait for the document being activated, so that
// fullscreen request won't be denied.
yield promiseOneMessage("Test:Activated");
let contextMenu = document.getElementById("contentAreaContextMenu");
ok(contextMenu, "Got context menu");
let state;
info("Enter DOM fullscreen");
gMessageManager.sendAsyncMessage("Test:RequestFullscreen");
state = yield promiseOneMessage("Test:FullscreenChanged");
ok(state, "The content should have entered fullscreen");
ok(document.mozFullScreen, "The chrome should also be in fullscreen");
gMessageManager.addMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
info("Open context menu");
is(contextMenu.state, "closed", "Should not have opened context menu");
let popupShownPromise = promiseWaitForEvent(window, "popupshown");
EventUtils.synthesizeMouse(browser, screen.width / 2, screen.height / 2,
{type: "contextmenu", button: 2}, window);
yield popupShownPromise;
is(contextMenu.state, "open", "Should have opened context menu");
info("Send the first escape");
let popupHidePromise = promiseWaitForEvent(window, "popuphidden");
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield popupHidePromise;
is(contextMenu.state, "closed", "Should have closed context menu");
// Wait a small time to confirm that the first ESC key
// does not exit fullscreen.
yield new Promise(resolve => setTimeout(resolve, 1000));
gMessageManager.sendAsyncMessage("Test:QueryFullscreenState");
state = yield promiseOneMessage("Test:FullscreenState");
ok(state, "The content should still be in fullscreen");
ok(document.mozFullScreen, "The chrome should still be in fullscreen");
info("Send the second escape");
gMessageManager.removeMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
let fullscreenExitPromise = promiseOneMessage("Test:FullscreenChanged");
EventUtils.synthesizeKey("VK_ESCAPE", {});
state = yield fullscreenExitPromise;
ok(!state, "The content should have exited fullscreen");
ok(!document.mozFullScreen, "The chrome should have exited fullscreen");
});