New issue
Advanced search Search tips

Issue 597900 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

Invalid JavaScript code for inline event handler should be compiled only once

Project Member Reported by tkent@chromium.org, Mar 25 2016

Issue description

1. Open http://w3c-test.org/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-once.html

Expected: The test passes.
Actual: The test fails.

It seems we try to compile invalid JavaScript code in body[onclick] every time when body.onclick is called.

 

Comment 1 by phistuck@gmail.com, Mar 25 2016

There are two issues here.
1. The test fails because it expects null, but get undefined and not because of the thrown exceptions.
2. Chrome does throw an exception every time you access onclick.

So the test case fails due to issue 1 right now (and once this is fixed, it will fail due to  issue 2 ).

Here is a test for the both of the issues (I just eliminated the early bail out due to the first exception) -
data:text/html,
<script>
window.addEventListener(
 "load",
 function ()
 {
  var errors = 0;
  window.onerror =
   function ()
   {
    errors++;
   };
  var e = document.body;
  e.setAttribute("onclick", "window.open(");
  console.log(e.onclick === null);
  console.log(e.onclick === null);
  console.log(errors);
 });
</script>

Comment 2 by phistuck@gmail.com, Mar 25 2016

Or you can change console.log(errors) to console.log(errors === 1);
The expected result should be -
true
true
true

The actual result -
false
false
false

Comment 3 by rbyers@chromium.org, May 20 2016

Labels: OS-All
phistuck: thanks for the analysis!  Filed  issue 613671  for the null/undefined issue.

Comment 4 by rbyers@chromium.org, May 20 2016

Cc: haraken@chromium.org bashi@chromium.org
Relevant spec:
https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-content-attributes
https://html.spec.whatwg.org/multipage/webappapis.html#internal-raw-uncompiled-handler

Simple demo page: http://output.jsbin.com/vecoto

Browsers tested:
Chrome 52.0.2739.0 Linux: fail
Firefox 46.0 Linux: pass
Safari 9.1 Mac: fail
Edge 13.10586 Win10: pass
IE 11 Win10: pass

Cc: yukishiino@chromium.org

Comment 6 by rbyers@chromium.org, Jul 25 2016

Owner: haraken@chromium.org
haraken@ thoughts?
Owner: yukishiino@chromium.org
Status: Assigned (was: Untriaged)
Status: Fixed (was: Assigned)

Sign in to add a comment