Compile raw inline event handlers lazily. Resolves #8489.

This commit is contained in:
Josh Matthews 2015-11-12 11:20:08 -05:00 committed by Ms2ger
parent 3703e6d4f6
commit 2796a4dfa8
11 changed files with 323 additions and 67 deletions

View file

@ -33719,6 +33719,18 @@
"deleted": [],
"items": {
"testharness": {
"html/webappapis/scripting/events/inline-event-handler-ordering.html": [
{
"path": "html/webappapis/scripting/events/inline-event-handler-ordering.html",
"url": "/html/webappapis/scripting/events/inline-event-handler-ordering.html"
}
],
"html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-once.html": [
{
"path": "html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-once.html",
"url": "/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-once.html"
}
],
"websockets/Send-data.worker.js": [
{
"path": "websockets/Send-data.worker.js",

View file

@ -0,0 +1,6 @@
[invalid-uncompiled-raw-handler-compiled-once.html]
type: testharness
note: remove inline-event-listener-panic.html when onerror is implemented properly.
[Invalid uncompiled raw handlers should only be compiled once.]
expected: FAIL

View file

@ -5874,6 +5874,12 @@
"url": "/_mozilla/mozilla/img_width_height.html"
}
],
"mozilla/inline-event-listener-panic.html": [
{
"path": "mozilla/inline-event-listener-panic.html",
"url": "/_mozilla/mozilla/inline-event-listener-panic.html"
}
],
"mozilla/inline_event_handler.html": [
{
"path": "mozilla/inline_event_handler.html",

View file

@ -0,0 +1,14 @@
<!doctype html>
<meta charset="utf-8">
<title>Getting the value of an inline event handler shouldn't panic.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
var e = document.body;
e.setAttribute("onclick", "console.log('x')");
assert_not_equals(e.onclick, null);
assert_not_equals(e.onclick, null);
done();
</script>
</body>

View file

@ -0,0 +1,52 @@
<!doctype html>
<meta charset="utf-8">
<title>Inline event handlers retain their ordering even when invalid</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
var events = [];
test(function() {
events = [];
var e = document.createElement("div");
document.body.appendChild(e);
e.addEventListener("click", function() { events.push("ONE") });
e.setAttribute("onclick", "window.open(");
e.addEventListener("click", function() { events.push("THREE") });
// Try to compile the event handler.
e.onclick;
e.setAttribute("onclick", "events.push('TWO')");
e.dispatchEvent(new Event("click"));
var expected_events = ["ONE", "TWO", "THREE"];
assert_array_equals(events, expected_events);
}, "Inline event handlers retain their ordering when invalid and force-compiled");
test(function() {
events = [];
var e = document.createElement("div");
document.body.appendChild(e);
e.addEventListener("click", function() { events.push("ONE") });
e.setAttribute("onclick", "window.open(");
e.addEventListener("click", function() { events.push("THREE") });
e.dispatchEvent(new Event("click"));
e.setAttribute("onclick", "events.push('TWO')");
e.dispatchEvent(new Event("click"));
var expected_events = ["ONE", "THREE", "ONE", "TWO", "THREE"];
assert_array_equals(events, expected_events);
}, "Inline event handlers retain their ordering when invalid and force-compiled via dispatch");
test(function() {
events = [];
var e = document.createElement("div");
document.body.appendChild(e);
e.addEventListener("click", function() { events.push("ONE") });
e.setAttribute("onclick", "window.open(");
e.addEventListener("click", function() { events.push("THREE") });
e.setAttribute("onclick", "events.push('TWO')");
e.dispatchEvent(new Event("click"));
var expected_events = ["ONE", "TWO", "THREE"];
assert_array_equals(events, expected_events);
}, "Inline event handlers retain their ordering when invalid and lazy-compiled");
</script>
</body>

View file

@ -0,0 +1,23 @@
<!doctype html>
<meta charset="utf-8">
<title>Invalid uncompiled raw handlers should only be compiled once.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
setup({ allow_uncaught_exception: true });
var errors = 0;
window.onerror = function() {
errors++;
};
test(function() {
var e = document.body;
e.setAttribute("onclick", "window.open(");
assert_equals(e.onclick, null);
assert_equals(e.onclick, null);
assert_equals(errors, 1);
});
</script>
</body>