Skip to content

Commit

Permalink
Merge 719e19c into 7fb01a2
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Oct 26, 2016
2 parents 7fb01a2 + 719e19c commit 2358a06
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<title>This frame will get navigated from</title>

<h1>Navigate from here</h1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<title>This frame will get navigated to</title>

<h1>Navigate to here</h1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<title>Event handler IDL attribute realm</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler">
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<iframe></iframe>
<iframe></iframe>

<iframe id="navigate-me" src="event-handler-idl-attribute-realm-support-1.html"></iframe>

<script>
"use strict";

test(() => {
const frame0Document = frames[0].document.documentElement;
const frame1Body = frames[1].document.body;

frame1Body.setAttribute("onclick", "void(0)");
frame0Document.appendChild(frame1Body);
const get = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "onclick").get;
const f = get.call(frame1Body);

assert_false(f instanceof Function, "The function must not be created in the parent frame's global");
assert_true(f instanceof frames[0].Function, "The function must be created in the element's document's global");
assert_false(f instanceof frames[1].Function, "The function must not be created in the element's global");
}, "Event handler IDL attributes must return a function from the element's document's realm");

async_test(t => {
const iframe = document.querySelector("#navigate-me");
const windowProxy = iframe.contentWindow;

window.onload = t.step_func(() => {
windowProxy.onerror = t.step_func_done(ev => {
assert_equals(ev.error.constructor.name, "SyntaxError");
// TODO remove me; just poking it to get it to re-deploy to /submissions/
});

const oldDocument = windowProxy.document;
iframe.addEventListener("load", t.step_func(() => {
const newDocument = windowProxy.document;
assert_not_equals(oldDocument, newDocument, "Sanity check: navigation changed the document");
assert_equals(windowProxy.onerror, null, "Sanity check: after navigation reset onerror");

windowProxy.onerror = t.unreached_func("The post-navigation onerror must not be called");

oldDocument.body.setAttribute("onclick", "1 *-* 'syntax error'");
const onclick = oldDocument.body.onclick;

assert_equals(onclick, null, "Attempting to compile a syntax error must give null");
}));
windowProxy.location.href = "event-handler-idl-attribute-realm-support-2.html";
});
}, "Event handler IDL attribute compilation errors should be reported to the document's global");
</script>

0 comments on commit 2358a06

Please sign in to comment.