Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/webappapis/events/event-handler-object-environment-instantiation.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="UTF-8" />
<title>Inline handler correct ObjectEnvironment instantiation</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
"use strict";
window.element = document.element = {
get [Symbol.unscopables]() {
return assert_unreached("get element[Symbol.unscopables]()");
},
onclickCalled: null
};
</script>
<div id="foo" onclick='
assert_equals(element, window.element, "element === window.element");
assert_equals(onclickCalled, false);
onclickCalled = true;
'></div>
<script>
"use strict";
test(() => {
const foo = document.getElementById("foo");
foo.onclickCalled = false;
foo.click();
assert_equals(foo.onclickCalled, true);
});
</script>