Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/embedded-content/the-embed-element/embed-javascript-url.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>embed - javascript: URL</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// embed element setup steps fetches url, which results in a network error
// and thus "Display no plugin".
promise_test(async function (t) {
const embed = document.createElement('embed');
embed.src = 'javascript:"foo"';
embed.onload = t.unreached_func('No load event expected');
document.body.append(embed);
t.add_cleanup(() => { embed.remove(); });
await new Promise(resolve => { t.step_timeout(resolve, 100); });
}, "javascript: in src attribute should do nothing");
function insertEmbedNavigable(t) {
const embed = document.createElement('embed');
embed.src = '/resources/blank.html';
document.body.append(embed);
t.add_cleanup(() => { embed.remove(); });
return embed;
}
promise_test(async function (t) {
const embed = insertEmbedNavigable(t);
await new Promise(resolve => { embed.onload = resolve; });
const loaded = new Promise(resolve => { embed.onload = resolve; });
window[0].location.href = 'javascript:"test"';
await loaded;
}, 'location.href = \'javascript:"test"\' should fire a load event');
promise_test(async function (t) {
const embed = insertEmbedNavigable(t);
await new Promise(resolve => { embed.onload = resolve; });
embed.onload = t.unreached_func('No second load event expected');
window[0].location.href = 'javascript:1';
await new Promise(resolve => { t.step_timeout(resolve, 100); });
}, 'location.href = \'javascript:1\' should not fire a load event');
</script>