Skip to content

Commit

Permalink
Test snapshotting of allowfullscreen attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
zcorpan committed Oct 30, 2019
1 parent c9064ef commit 1328c64
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<title>Document#fullscreenEnabled removing allowfullscreen after load and then navigating</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test((t) => {
const iframe = document.createElement('iframe');
iframe.allowFullscreen = true;

let i = 0;

iframe.src = "http://{{domains[www1]}}:{{ports[http][0]}}/fullscreen/api/echo-fullscreenEnabled.html";
iframe.onload = t.step_func(() => {
if (i === 0) {
iframe.allowFullscreen = false;
}
iframe.contentWindow.postMessage('What is document.fullscreenEnabled?', '*');
});

window.onmessage = t.step_func((e) => {
i++;
if (i === 1) {
assert_true(e.data, 'document.fullscreenEnabled in the iframe, before navigation');

// Navigate the iframe. This will fire a second 'load' event on the iframe.
iframe.contentWindow.location.href = iframe.src + '?2';
} else {
assert_false(e.data, 'document.fullscreenEnabled in the iframe, after navigation');
t.done();
}
});

document.body.appendChild(iframe);
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<title>Document#fullscreenEnabled setting allowfullscreen after load and then navigating</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test((t) => {
const iframe = document.createElement('iframe');
// no allowfullscreen attribute

let i = 0;

iframe.src = "http://{{domains[www1]}}:{{ports[http][0]}}/fullscreen/api/echo-fullscreenEnabled.html";
iframe.onload = t.step_func(() => {
if (i === 0) {
iframe.allowFullscreen = true;
}
iframe.contentWindow.postMessage('What is document.fullscreenEnabled?', '*');
});

window.onmessage = t.step_func((e) => {
i++;
if (i === 1) {
assert_false(e.data, 'document.fullscreenEnabled in the iframe, before navigation');

// Navigate the iframe. This will fire a second 'load' event on the iframe.
iframe.contentWindow.location.href = iframe.src + '?2';
} else {
assert_true(e.data, 'document.fullscreenEnabled in the iframe, after navigation');
t.done();
}
});

document.body.appendChild(iframe);
});
</script>
11 changes: 11 additions & 0 deletions fullscreen/api/echo-fullscreenEnabled.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<script>
window.onmessage = (e) => {
if (e.data === 'What is document.fullscreenEnabled?') {
e.source.postMessage(document.fullscreenEnabled, '*');
} else {
e.source.postMessage('Incorrect message', '*');
}
}
</script>
<p>This page echos document.fullscreenEnabled.</p>

0 comments on commit 1328c64

Please sign in to comment.