Commit 537717e4 authored by Mike West's avatar Mike West Committed by Commit Bot

Add custom element event tests for CSP nonce hiding.

Basically copy-pasting from Anne's suggestions at
https://github.com/whatwg/html/pull/2373#issuecomment-332503536

Bug: 680419
Change-Id: I9fee18d46dc00ff3ec8ec90f3d8acd80ab015622
Reviewed-on: https://chromium-review.googlesource.com/771151Reviewed-by: default avatarAndy Paicu <andypaicu@chromium.org>
Commit-Queue: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517734}
parent 3027032c
...@@ -114,6 +114,46 @@ ...@@ -114,6 +114,46 @@
}, "createElement.setAttribute."); }, "createElement.setAttribute.");
</script> </script>
<!-- Custom Element -->
<script nonce="abc">
var eventList = [];
class NonceElement extends HTMLElement {
static get observedAttributes() {
return ['nonce'];
}
constructor() {
super();
}
attributeChangedCallback(name, oldValue, newValue) {
eventList.push({
type: "AttributeChanged",
name: name,
oldValue: oldValue,
newValue: newValue
});
}
connectedCallback() {
eventList.push({
type: "Connected",
});
}
}
customElements.define("nonce-element", NonceElement);
</script>
<nonce-element nonce="abc"></nonce-element>
<script nonce="abc">
test(t => {
assert_equals(eventList.length, 3);
assert_object_equals(eventList[0], { type: "AttributeChanged", name: "nonce", oldValue: null, newValue: "abc" });
assert_object_equals(eventList[1], { type: "Connected" });
assert_object_equals(eventList[2], { type: "AttributeChanged", name: "nonce", oldValue: "abc", newValue: "" });
}, "Custom elements expose the correct events.");
</script>
<!-- CSS Leakage --> <!-- CSS Leakage -->
<style> <style>
#cssTest { display: block; } #cssTest { display: block; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment