diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/html/test/file_fullscreen-denied.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/html/test/file_fullscreen-denied.html')
-rw-r--r-- | dom/html/test/file_fullscreen-denied.html | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/dom/html/test/file_fullscreen-denied.html b/dom/html/test/file_fullscreen-denied.html new file mode 100644 index 000000000..322723083 --- /dev/null +++ b/dom/html/test/file_fullscreen-denied.html @@ -0,0 +1,129 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=545812 + +Test DOM fullscreen API. + +--> +<head> + <title>Test for Bug 545812</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <script type="application/javascript" src="file_fullscreen-utils.js"></script> + <style> + body { + background-color: black; + } + </style> +</head> +<body> + +<script type="application/javascript"> + +/** Test for Bug 545812 **/ + +function ok(condition, msg) { + opener.ok(condition, "[denied] " + msg); +} + +function is(a, b, msg) { + opener.is(a, b, "[denied] " + msg); +} + +const INNER_FILE = "file_fullscreen-denied-inner.html"; +function setupForInnerTest(targetName, callback) { + window.testTargetName = targetName; + window.continueTest = () => { + delete window.testTargetName; + delete window.continueTest; + callback(); + }; +} + +function begin() { + document.addEventListener("fullscreenchange", () => { + ok(false, "Should never receive " + + "a fullscreenchange event in the main window."); + }); + SimpleTest.executeSoon(testIFrameWithoutAllowFullscreen); +} + +function testIFrameWithoutAllowFullscreen() { + // Create an iframe without an allowfullscreen attribute, whose + // contents request fullscreen. The request should be denied, and + // we should not receive a fullscreenchange event in this document. + var iframe = document.createElement("iframe"); + iframe.src = INNER_FILE; + setupForInnerTest("an iframe without allowfullscreen", () => { + document.body.removeChild(iframe); + SimpleTest.executeSoon(testFrameElement); + }); + document.body.appendChild(iframe); +} + +function testFrameElement() { + var frameset = document.createElement("frameset"); + var frame = document.createElement("frame"); + frame.src = INNER_FILE; + frameset.appendChild(frame); + setupForInnerTest("a frame element", () => { + document.documentElement.removeChild(frameset); + SimpleTest.executeSoon(testObjectElement); + }); + document.documentElement.appendChild(frameset); +} + +function testObjectElement() { + var objectElem = document.createElement("object"); + objectElem.data = INNER_FILE; + setupForInnerTest("an object element", () => { + document.body.removeChild(objectElem); + // In the following tests we want to test trust context requirement + // of fullscreen request, so temporary re-enable this pref. + SpecialPowers.pushPrefEnv({ + "set":[["full-screen-api.allow-trusted-requests-only", true]] + }, testNonTrustContext); + }); + document.body.appendChild(objectElem); +} + +function testNonTrustContext() { + addFullscreenErrorContinuation(() => { + ok(!document.fullscreenElement, + "Should not grant request in non-trust context."); + SimpleTest.executeSoon(testLongRunningEventHandler); + }); + document.documentElement.requestFullscreen(); +} + +function testLongRunningEventHandler() { + function longRunningHandler() { + window.removeEventListener("keypress", longRunningHandler); + // Busy loop until 2s has passed. We should then be past the one + // second threshold, and so our request for fullscreen should be + // rejected. + var end = (new Date()).getTime() + 2000; + while ((new Date()).getTime() < end) { + ; // Wait... + } + document.documentElement.requestFullscreen(); + } + addFullscreenErrorContinuation(() => { + ok(!document.fullscreenElement, + "Should not grant request in long-running event handler."); + // Restore the pref environment we changed before + // entering testNonTrustContext. + SpecialPowers.popPrefEnv(finish); + }); + window.addEventListener("keypress", longRunningHandler); + synthesizeKey("VK_A", {}); +} + +function finish() { + opener.nextTest(); +} + +</script> +</body> +</html> |