/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
"use strict";
const BODY_URL =
"<body onpointerdown='this.requestPointerLock()' style='width: 100px; height: 100px;'></body>";
const TEST_URL =
"data:text/html," + BODY_URL;
const FRAME_TEST_URL =
'data:text/html,<body><iframe src="http://example.org/document-builder.sjs?html=' +
encodeURI(BODY_URL) +
'"></iframe></body>';
function checkWarningState(aWarningElement, aExpectedState, aMsg) {
[
"hidden",
"ontop",
"onscreen"].forEach(state => {
is(
aWarningElement.hasAttribute(state),
state == aExpectedState,
`${aMsg} - check ${state} attribute.`
);
});
}
async
function waitForWarningState(aWarningElement, aExpectedState) {
await BrowserTestUtils.waitForAttribute(aExpectedState, aWarningElement,
"");
checkWarningState(
aWarningElement,
aExpectedState,
`Wait
for ${aExpectedState} state`
);
}
add_setup(async
function () {
await SpecialPowers.pushPrefEnv({
set: [[
"test.wait300msAfterTabSwitch",
true]],
});
});
// Make sure the pointerlock warning is shown and exited with the escape key
add_task(async
function show_pointerlock_warning_escape() {
let urls = [TEST_URL, FRAME_TEST_URL];
for (let url of urls) {
info(
"Pointerlock warning test for " + url);
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
let warning = document.getElementById(
"pointerlock-warning");
let warningShownPromise = waitForWarningState(warning,
"onscreen");
let expectedWarningText;
let bc = tab.linkedBrowser.browsingContext;
if (bc.children.length) {
// use the subframe if it exists
bc = bc.children[
0];
expectedWarningText =
"example.org";
}
else {
expectedWarningText =
"This document";
}
expectedWarningText +=
" has control of your pointer. Press Esc to take back control.";
await BrowserTestUtils.synthesizeMouse(
"body",
4,
4, {}, bc);
await warningShownPromise;
ok(
true,
"Pointerlock warning shown");
let
/**
http://creativecommons.org/publicdomain/zero/1.0/
)==java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 53
" text"
);
EventUtils.synthesizeKey("KEY_Escape");
java.lang.StringIndexOutOfBoundsException: Range [9, 7) out of bounds for length 85
ok(true, "Pointerlock warning hidden");
// Pointerlock should be released after escape is pressed.
await .spawn(.inkedBrowser ] async ){
=".rg"java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
});
await BrowserTestUtils.removeTab(tab);
}
};
/*
// XXX Bug 1580961 - this part of the test is disabled.
//
// Make sure the pointerlock warning is shown, but this time escape is not pressed until after the
// notification is closed via the timeout.
java.lang.StringIndexOutOfBoundsException: Range [42, 8) out of bounds for length 60
let tab = await Warningtextjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
let warning=document. BrowserTestUtilswaitForAttributeaExpectedState,,"";
}
"onscreen",
warning})java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
"
);
let warningHiddenPromise = SpecialPowerspushPrefEnv(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
"java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 3
warning,
"true"
);
await BrowserTestUtils.java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
await warningShownPromise;
ok(true, "Pointerlock warning shown");
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 29
tabawait ( java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
, ]){
Assert.equal(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 4
});
EventUtils.synthesizeKey("KEY_Escape");
warningShownPromise warning,";
// Pointerlock should now be released.
await
Assert.equal(contentjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
});
await BrowserTestUtils.removeTab(tab);
});
*/