1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// There are shutdown issues for which multiple rejections are left uncaught.
// See bug 1018184 for resolving these issues.
const { PromiseTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/PromiseTestUtils.sys.mjs"
);
PromiseTestUtils.allowMatchingRejectionsGlobally(/File closed/);
// On debug test machine, it takes about 50s to run the test.
requestLongerTimeout(4);
add_task(async function () {
const ToolboxTask = await initBrowserToolboxTask();
await ToolboxTask.importFunctions({});
const hasCloseButton = await ToolboxTask.spawn(null, async () => {
/* global gToolbox */
return !!gToolbox.doc.getElementById("toolbox-close");
});
ok(!hasCloseButton, "Browser toolbox doesn't have a close button");
info("Trigger F5 key shortcut and ensure nothing happens");
info(
"If F5 triggers a full reload, the mochitest will stop here as firefox instance will be restarted"
);
const previousInnerWindowId =
window.browsingContext.currentWindowGlobal.innerWindowId;
function onUnload() {
ok(false, "The top level window shouldn't be reloaded/closed");
}
window.addEventListener("unload", onUnload);
await ToolboxTask.spawn(null, async () => {
const isMacOS = Services.appinfo.OS === "Darwin";
const { win } = gToolbox;
// Simulate CmdOrCtrl+R
win.dispatchEvent(
new win.KeyboardEvent("keydown", {
bubbles: true,
ctrlKey: !isMacOS,
metaKey: isMacOS,
keyCode: "r".charCodeAt(0),
})
);
// Simulate F5
win.dispatchEvent(
new win.KeyboardEvent("keydown", {
bubbles: true,
keyCode: win.KeyEvent.DOM_VK_F5,
})
);
});
// Let a chance to trigger the regression where the top level document closes or reloads
await wait(1000);
is(
window.browsingContext.currentWindowGlobal.innerWindowId,
previousInnerWindowId,
"Check the browser.xhtml wasn't reloaded when pressing F5"
);
window.removeEventListener("unload", onUnload);
await ToolboxTask.destroy();
});
|