Skip to content

Commit

Permalink
Reenable feature policy control over fullscreen
Browse files Browse the repository at this point in the history
This CL also changes test expectations to bring the fullscreen tests in
line with the new behaviour prescribed by Feature Policy.

Specifically:
 - Same origin iframes by default have the same ability to use
   fullscreen as their parent frame. Tests which previously only used
   same-origin frame have been changed to verify the new behaviour,
   and new tests in LayoutTests/http/tests have been added to test the
   same situation with cross-origin frames.
 - Dynamic modification of the allowfullscreen flag has no effect until
   the iframe contents are navigated/reloaded.
 - Web platform tests are marked as failing, and should remain so until
   the fullscreen spec is updated fo include the new behaviour.
 - A new Browser test class is created which explicitly disables
   feature policy so that we don't lose coverage for the old behaviour
   when FP is disabled.

BUG=718155,623682

Review-Url: https://codereview.chromium.org/2898503002
Cr-Commit-Position: refs/heads/master@{#495331}
  • Loading branch information
clelland authored and chromium-wpt-export-bot committed Aug 17, 2017
1 parent b4c1979 commit 3cc0d89
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 0 deletions.
37 changes: 37 additions & 0 deletions fullscreen/api/document-fullscreen-enabled-cross-origin.sub.html
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<title>Document#fullscreenEnabled</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="resources/report-fullscreen-enabled.html" name="same-origin-default"></iframe>
<iframe src="resources/report-fullscreen-enabled.html" allowfullscreen name="same-origin-allow"></iframe>
<iframe src="http://{{domains[www1]}}:{{ports[http][0]}}/fullscreen/api/resources/report-fullscreen-enabled.html" name="cross-origin-default"></iframe>
<iframe src="http://{{domains[www1]}}:{{ports[http][0]}}/fullscreen/api/resources/report-fullscreen-enabled.html" allowfullscreen name="cross-origin-allow"></iframe>
<script>
var expectations = {
"same-origin-default": false,
"same-origin-allow": true,
"cross-origin-default": false,
"cross-origin-allow": true
};

var tests = {};
for (var name in expectations) {
tests[name] = async_test( 'Fullscreen enabled test: ' + name);
}

// When a message is received from a child frame, ensure that the report
// matches the expectations.
window.addEventListener('message', e => {
if (e.data.report && e.data.report.api == "fullscreen") {
if (e.data.report.frame in expectations) {
tests[e.data.report.frame].step(() => {
assert_equals(e.data.report.enabled, expectations[e.data.report.frame],
e.data.report.frame + " frame fullscreenEnabled");
});
delete expectations[e.data.report.frame];
tests[e.data.report.frame].done();
}
}
});
</script>
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<title>Element ready check with allowfullscreen attribute</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<iframe src="http://{{domains[www1]}}:{{ports[http][0]}}/fullscreen/api/resources/attempt-fullscreen.html" name="cross-origin-allowed" allowfullscreen></iframe>
<script>

async_test((t) => {
t.add_cleanup(() => document.exitFullscreen());

// When a message is received from a child frame, ensure that the report
// matches the expectations.
window.addEventListener('message', t.step_func(e => {
if (e.data.report && e.data.report.api == "fullscreen") {
assert_equals(e.data.report.result, true,
e.data.report.frame + " frame did enter fullscreen");
t.done();
}
}));

// Trigger the child frame to report as soon as its content is loaded.
var elem = document.querySelector('iframe');
elem.addEventListener('load', () => {
trusted_click(t, () => {
elem.contentWindow.postMessage({"action": "report"}, "*");
}, document.body);
});
});
</script>
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<title>Element ready check with no allowfullscreen attribute</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<iframe src="http://{{domains[www1]}}:{{ports[http][0]}}/fullscreen/api/resources/attempt-fullscreen.html" name="cross-origin-default"></iframe>
<script>

async_test((t) => {
document.onfullscreenchange = t.unreached_func("document fullscreenchange event");
document.onfullscreenerror = t.unreached_func("document fullscreenerror event");

// When a message is received from a child frame, ensure that the report
// matches the expectations.
window.addEventListener('message', t.step_func(e => {
if (e.data.report && e.data.report.api == "fullscreen") {
assert_equals(e.data.report.result, false,
e.data.report.frame + " frame did enter fullscreen");
t.done();
}
}));

// Trigger the child frame to report as soon as its content is loaded.
var elem = document.querySelector('iframe');
elem.addEventListener('load', () => {
trusted_click(t, () => {
elem.contentWindow.postMessage({"action": "report"}, "*");
}, document.body);
});
});
</script>
23 changes: 23 additions & 0 deletions fullscreen/api/resources/attempt-fullscreen.html
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>IFrame Fullscreen API success reporter</title>
<body>
<script>
reportFullscreenSuccessful = (success) => {
return () => {
parent.postMessage({"report": {
"api": "fullscreen",
"result": success,
"frame": window.name
}}, "*");
};
};

window.addEventListener('message', e => {
if (e.data.action == "report") {
document.onfullscreenchange = reportFullscreenSuccessful(true);
document.onfullscreenerror = reportFullscreenSuccessful(false);
document.body.requestFullscreen();
}
});
</script>
11 changes: 11 additions & 0 deletions fullscreen/api/resources/report-fullscreen-enabled.html
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>IFrame fullscreenEnabled attribute reporter</title>
<body>
<script>
parent.postMessage({"report": {
"api": "fullscreen",
"enabled": document.fullscreenEnabled,
"frame": window.name
}}, "*");
</script>

0 comments on commit 3cc0d89

Please sign in to comment.