New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 632940 link

Starred by 4 users

Issue metadata

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

Blocking:
issue 594918



Sign in to add a comment

Custom elements v1 constructor failure does not "report an error"

Project Member Reported by kojii@chromium.org, Jul 30 2016

Issue description

From #61 of  issue 594918 :

When constructor check failed as per the spec, it should "report an error", but following example does not show errors to console.

<!doctype html>
<html>
<head>
	<script>
		class Cev1 extends HTMLElement {
		
			constructor () 
			{
				super()
				this.innerHTML = "Hello V1"
			}
			
		} 
		customElements.define( "test-v1", Cev1 )
	</script>
</head>
	
<body>
	<test-v1>Avant</test-v1>
</body>
</html>
 

Comment 1 by kojii@chromium.org, Jul 30 2016

Cc: haraken@chromium.org
Labels: OS-All
So SetVerbose(true) doesn't do what we expect in all cases?

I guess we should re-review this and come up with a standard way to "report the exception"
https://html.spec.whatwg.org/multipage/webappapis.html#report-the-exception
and use it everywhere.

IIUC this should be cross-function of DOM and binding?
Owner: kojii@chromium.org
Status: Assigned (was: Untriaged)

Comment 3 by kojii@chromium.org, Aug 1 2016

Owner: davaajav@google.com
Looks like you're fixing another case in
https://codereview.chromium.org/2161003002/
and applying the same fix to this code path should fix this too. Can you take a look?
Side note: When I put the "script" in "body" instead of "head". The innerHTML is well updated. (I know now it's not permitted either but I wanted to signal it,  reason why I suspected a bug.) 


I'm working on the case where define happens before the <test-v1> element is parsed right now.

If you move the script tag after <test-v1>, then the behavior you are seeing is correct and working as intended:

In that case, when the parser encounters test-v1, there is no definition for it. The parser does not wait for one; it creates the element and continues to set children ('Avant') on that node, etc.

When you call define after that point the definition is "upgraded." This is a distinct operation from "creating" the element. Although both "creation" and "upgrade" run the element's constructor, the restrictions on what they can do are different.

Comment 6 by kojii@chromium.org, Aug 15 2016

dava@, if you find not easy to work on this, please assign back to me. If this is on your queue, that's fine.

Comment 7 by davaajav@google.com, Aug 15 2016

Owner: kojii@chromium.org
Project Member

Comment 8 by bugdroid1@chromium.org, Aug 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8b406045bb585b6a4bc7808d15df7070ba6e93ca

commit 8b406045bb585b6a4bc7808d15df7070ba6e93ca
Author: kojii <kojii@chromium.org>
Date: Mon Aug 22 08:34:26 2016

Fix "report the exception" in Custom Elements V1

There are 2 places the spec uses "report the exception"[1]:

1. The document parser invokes constructors synchronously.
2. Upgrade.

Currently Blink has 2 different code paths for each, and each has
different issues:
1. The synchronous constructor uses SetVerbose(true), which works for
   thrown exceptions, but ExceptionState::throwIfNeeded() only puts
   the exception into pending exceptions, which will be cleared when
   TryCatch scope exits.
2. Upgrade fires error events and calls
   ExecutionContext::reportException() to avoid it, but it always uses
   NotSharableCrossOrigin. This works in run-layout-test where the
   origin has m_unversalAccess, but not in, for instance, file URL.

This patch unifies the 2 code paths.

[1] https://html.spec.whatwg.org/multipage/webappapis.html#report-the-exception

BUG= 632940 

Review-Url: https://codereview.chromium.org/2244203002
Cr-Commit-Position: refs/heads/master@{#413421}

[add] https://crrev.com/8b406045bb585b6a4bc7808d15df7070ba6e93ca/third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html
[modify] https://crrev.com/8b406045bb585b6a4bc7808d15df7070ba6e93ca/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h
[modify] https://crrev.com/8b406045bb585b6a4bc7808d15df7070ba6e93ca/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp
[modify] https://crrev.com/8b406045bb585b6a4bc7808d15df7070ba6e93ca/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h
[modify] https://crrev.com/8b406045bb585b6a4bc7808d15df7070ba6e93ca/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
[modify] https://crrev.com/8b406045bb585b6a4bc7808d15df7070ba6e93ca/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h

Comment 9 by kojii@chromium.org, Aug 23 2016

Status: Fixed (was: Assigned)
Let's say fixed, I'll open another if the spec goes differently.

Sign in to add a comment