Skip to content

Commit

Permalink
Bug 1651493 [wpt PR 24518] - Add a test for network errors with <embe…
Browse files Browse the repository at this point in the history
…d>, a=testonly

Automatic update from web-platform-tests
Add a test for network errors with <embed> and <iframe>

Follows whatwg/html#4247 for <embed> and existing spec text for <iframe>.
--

wpt-commits: 91b0d35770bcb521c540d08002d8d3700666180c
wpt-pr: 24518
  • Loading branch information
domenic authored and moz-wptsync-bot committed Jul 24, 2020
1 parent 4a25c48 commit 795e500
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>I should not be embeddable because of X-Frame-Options</title>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
X-Frame-Options: deny
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Network errors with embed elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<script>
"use strict";

async_test(t => {
const embed = document.createElement("embed");
embed.src = "//{{hosts[][nonexistent]}}/";
embed.onload = () => t.done();
embed.onerror = t.unreached_func("error event must not fire");
document.body.append(embed);
}, "new embed: nonexistent host");

async_test(t => {
const embed = document.createElement("embed");
embed.src = "../resources/not-embeddable.html";
embed.onload = () => t.done();
embed.onerror = t.unreached_func("error event must not fire");
document.body.append(embed);
}, "new embed: X-Frame-Options prevents embedding");

async_test(t => {
const embed = document.createElement("embed");
embed.src = "/common/blank.html";
embed.name = "existingEmbed1";
embed.onload = t.step_func(() => {
embed.onload = () => t.done();
embed.onerror = t.unreached_func("error event must not fire 2");

frames.existingEmbed1.location.href = "//{{hosts[][nonexistent]}}/";
});
embed.onerror = t.unreached_func("error event must not fire 1");
document.body.append(embed);
}, "navigating an existing embed: nonexistent host");

async_test(t => {
const embed = document.createElement("embed");
embed.src = "/common/blank.html";
embed.name = "existingEmbed2";
embed.onload = t.step_func(() => {
embed.onload = () => t.done();
embed.onerror = t.unreached_func("error event must not fire 2");

frames.existingEmbed2.location.href = "../resources/not-embeddable.html";
});
embed.onerror = t.unreached_func("error event must not fire 1");
document.body.append(embed);
}, "navigating an existing embed: X-Frame-Options prevents embedding");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Network errors with iframe elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<script>
"use strict";

async_test(t => {
const iframe = document.createElement("iframe");
iframe.src = "//{{hosts[][nonexistent]}}/";
iframe.onload = () => t.done();
iframe.onerror = t.unreached_func("error event must not fire");
document.body.append(iframe);
}, "new iframe: nonexistent host");

async_test(t => {
const iframe = document.createElement("iframe");
iframe.src = "../resources/not-embeddable.html";
iframe.onload = () => t.done();
iframe.onerror = t.unreached_func("error event must not fire");
document.body.append(iframe);
}, "new iframe: X-Frame-Options prevents embedding");

async_test(t => {
const iframe = document.createElement("iframe");
iframe.src = "/common/blank.html";
iframe.name = "existingIframe1";
iframe.onload = t.step_func(() => {
iframe.onload = () => t.done();
iframe.onerror = t.unreached_func("error event must not fire 2");

frames.existingIframe1.location.href = "//{{hosts[][nonexistent]}}/";
});
iframe.onerror = t.unreached_func("error event must not fire 1");
document.body.append(iframe);
}, "navigating an existing iframe: nonexistent host");

async_test(t => {
const iframe = document.createElement("iframe");
iframe.src = "/common/blank.html";
iframe.name = "existingIframe2";
iframe.onload = t.step_func(() => {
iframe.onload = () => t.done();
iframe.onerror = t.unreached_func("error event must not fire 2");

frames.existingIframe2.location.href = "../resources/not-embeddable.html";
});
iframe.onerror = t.unreached_func("error event must not fire 1");
document.body.append(iframe);
}, "navigating an existing iframe: X-Frame-Options prevents embedding");
</script>

0 comments on commit 795e500

Please sign in to comment.