Skip to content

Commit

Permalink
Support onmessage and onmessageerror event handler content attributes.
Browse files Browse the repository at this point in the history
Add tests for them, as well as the recently added load event (which should
have one for all HTML attributes, so comes for free).

Bug: 914120
Change-Id: I8ae57e48e87434122a19cf02b86e0fec0cf578c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1594052
Reviewed-by: Adithya Srinivasan <adithyas@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656360}
  • Loading branch information
jeremyroman authored and chromium-wpt-export-bot committed May 3, 2019
1 parent ec1d6a1 commit 109fe36
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions portals/htmlportalelement-event-handler-content-attributes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// Dispatch of these events is tested elsewhere.
// This test merely ensures that the event handler content attributes work.
let eventNames = ["load", "message", "messageerror"];
test(() => {
try {
let portal = document.createElement("portal");
for (let eventName of eventNames) {
window.testValue = "not fired";
portal.setAttribute("on" + eventName, "window.testValue = 'fired'");
portal.dispatchEvent(new Event(eventName));
assert_equals(window.testValue, "fired", `${eventName} should have fired`);

window.testValue = "not fired";
portal.removeAttribute("on" + eventName);
portal.dispatchEvent(new Event(eventName));
assert_equals(window.testValue, "not fired", `${eventName} should not have fired`);
}
} finally {
delete window.testValue;
}
}, "Tests that event handler content attributes for supported event names work.");
</script>

0 comments on commit 109fe36

Please sign in to comment.