Bug 1268749 part 6 - Add test for behavior when unprefixed api is disabled. r=smaug

MozReview-Commit-ID: EUaoiTsVJK9

--HG--
extra : rebase_source : 5dce9bd6bc53fdefd1668908fe433e6f9b592e95
This commit is contained in:
Xidorn Quan 2016-05-02 15:36:53 +10:00
Родитель 7854a13c5b
Коммит 6d755304f4
4 изменённых файлов: 132 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,95 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test for Bug 1268749</title>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<div id="fullscreen"></div>
<script>
function ok(condition, msg) {
opener.opener.ok(condition, "[unprefix-disabled] " + msg);
}
function is(a, b, msg) {
opener.opener.is(a, b, "[unprefix-disabled] " + msg);
}
function info(msg) {
opener.opener.info("[unprefix-disabled] " + msg);
}
SimpleTest.requestFlakyTimeout(
"need to wait for a while to confirm no unexpected event is dispatched");
let div = document.getElementById("fullscreen");
let unattachedDiv = document.createElement('div');
function begin() {
ok(!("requestFullscreen" in div), "No element.requestFullscreen");
ok(!("exitFullscreen" in document), "No document.exitFullscreen");
ok(!("fullscreenElement" in document), "No document.fullscreenElement");
ok(!("fullscreenEnabled" in document), "No document.fullscreenEnabled");
ok(!("onfullscreenchange" in document), "No document.onfullscreenchange");
ok(!("onfullscreenerror" in document), "No document.onfullscreenerror");
for (var event of ["fullscreenchange", "fullscreenerror"]) {
let customEvent = new Event(event, {bubbles: true});
let gotCustomEventFromWindow = false;
let gotCustomEventFromDocument = false;
let listenerForWindow = evt => {
ok(!gotCustomEventFromWindow,
"Should get custom event from window only once");
ok(evt == customEvent, "Should get the desired custom event");
gotCustomEventFromWindow = true;
};
let listenerForDocument = evt => {
ok(!gotCustomEventFromDocument,
"Should get custom event from document only once");
ok(evt == customEvent, "Should get the desired custom event");
gotCustomEventFromDocument = true;
};
window.addEventListener(event, listenerForWindow);
document.addEventListener(event, listenerForDocument);
document.dispatchEvent(customEvent);
ok(gotCustomEventFromWindow, "Should get the custom event from window");
ok(gotCustomEventFromDocument, "Should get the custom event from document");
window.removeEventListener(event, listenerForWindow);
document.removeEventListener(event, listenerForDocument);
for (var target of [window, document]) {
target.addEventListener(event, () => {
ok(false, `No ${event} should be triggered on ${target}`);
});
}
}
document.addEventListener("mozfullscreenchange", enteredFullscreen);
SimpleTest.executeSoon(() => div.mozRequestFullScreen());
}
function enteredFullscreen() {
document.removeEventListener("mozfullscreenchange", enteredFullscreen);
document.addEventListener("mozfullscreenchange", exitedFullscreen);
SimpleTest.executeSoon(() => document.mozCancelFullScreen());
}
function exitedFullscreen() {
document.removeEventListener("mozfullscreenchange", exitedFullscreen);
document.addEventListener("mozfullscreenerror", errorFullscreen);
SimpleTest.executeSoon(() => unattachedDiv.mozRequestFullScreen());
}
function errorFullscreen() {
document.removeEventListener("mozfullscreenerror", errorFullscreen);
// Wait a short time before exiting this test to confirm that there is
// really no unwanted event gets dispatched.
setTimeout(() => opener.finish(), 200);
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test for Bug 1268749</title>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<script>
var gWindow = null;
function begin() {
SpecialPowers.pushPrefEnv({
"set": [["full-screen-api.unprefix.enabled", false]]
}, () => {
gWindow = window.open("file_fullscreen-unprefix-disabled-inner.html",
"", "width=500,height=500");
gWindow.addEventListener("load", () => {
gWindow.focus();
SimpleTest.waitForFocus(() => gWindow.begin(), gWindow);
});
});
}
function finish() {
gWindow.close();
SpecialPowers.popPrefEnv(opener.nextTest);
}
</script>
</body>
</html>

Просмотреть файл

@ -64,6 +64,8 @@ support-files =
file_fullscreen-selector.html
file_fullscreen-svg-element.html
file_fullscreen-top-layer.html
file_fullscreen-unprefix-disabled-inner.html
file_fullscreen-unprefix-disabled.html
file_fullscreen-utils.js
file_iframe_sandbox_a_if1.html
file_iframe_sandbox_a_if10.html

Просмотреть файл

@ -43,6 +43,7 @@ var gTestWindows = [
"file_fullscreen-backdrop.html",
"file_fullscreen-nested.html",
"file_fullscreen-prefixed.html",
"file_fullscreen-unprefix-disabled.html",
];
var testWindow = null;