From f44406c15ca5b587515c2c81349d0763af13d83b Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 12 Oct 2015 11:24:23 +1100 Subject: [PATCH] Bug 1212299 part 3 - Add test for requesting fullscreen from doc inside frame/object. rs=smaug --HG-- extra : source : c931d9c561e66a9a026bfc3c69e4c664f3168055 --- .../test/file_fullscreen-denied-inner.html | 4 +- dom/html/test/file_fullscreen-denied.html | 49 +++++++++++++++---- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/dom/html/test/file_fullscreen-denied-inner.html b/dom/html/test/file_fullscreen-denied-inner.html index 364934d0f53c..16c132439cf4 100644 --- a/dom/html/test/file_fullscreen-denied-inner.html +++ b/dom/html/test/file_fullscreen-denied-inner.html @@ -10,11 +10,11 @@ function doRequestFullscreen() { document.removeEventListener("mozfullscreenchange", handler); document.removeEventListener("mozfullscreenerror", handler); parent.is(evt.type, "mozfullscreenerror", "Request from " + - "an iframe without allowfullscreen should be denied"); + `document inside ${parent.testTargetName} should be denied`); parent.continueTest(); } parent.ok(!document.mozFullScreenEnabled, "Fullscreen " + - "should not be enabled in an iframe without allowfullscreen"); + `should not be enabled in ${parent.testTargetName}`); document.addEventListener("mozfullscreenchange", handler); document.addEventListener("mozfullscreenerror", handler); document.documentElement.mozRequestFullScreen(); diff --git a/dom/html/test/file_fullscreen-denied.html b/dom/html/test/file_fullscreen-denied.html index d1e22274a551..88892943faf3 100644 --- a/dom/html/test/file_fullscreen-denied.html +++ b/dom/html/test/file_fullscreen-denied.html @@ -31,6 +31,16 @@ 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("mozfullscreenchange", () => { ok(false, "Should never receive " + @@ -40,21 +50,42 @@ function begin() { } function testIFrameWithoutAllowFullscreen() { - window.continueTest = () => { - delete window.continueTest; + // 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); - }; - // 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 = "file_fullscreen-denied-inner.html"; - document.body.appendChild(iframe); + }); + document.body.appendChild(objectElem); } function testNonTrustContext() {