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-object-element/object-javascript-url.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>object - javascript: URL</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// the steps to (re)determine what the object element represents
// fetches url, which results in a network error
// and thus "fallback".
promise_test(async function (t) {
const object = document.createElement('object');
object.data = 'javascript:"foo"';
object.onload = t.unreached_func('No load event expected');
document.body.append(object);
t.add_cleanup(() => { object.remove(); });
await new Promise(resolve => { t.step_timeout(resolve, 100); });
}, "javascript: in data attribute should do nothing");
function insertObjectNavigable(t) {
const object = document.createElement('object');
object.data = '/resources/blank.html';
document.body.append(object);
t.add_cleanup(() => { object.remove(); });
return object;
}
promise_test(async function (t) {
const object = insertObjectNavigable(t);
await new Promise(resolve => { object.onload = resolve; });
const loaded = new Promise(resolve => { object.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 object = insertObjectNavigable(t);
await new Promise(resolve => { object.onload = resolve; });
object.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>