Bug 67977 - Implement a PopStateEvent constructor for JSC
Summary: Implement a PopStateEvent constructor for JSC
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kentaro Hara
URL:
Keywords:
Depends on:
Blocks: 67824
  Show dependency treegraph
 
Reported: 2011-09-12 18:41 PDT by Kentaro Hara
Modified: 2011-09-15 19:45 PDT (History)
6 users (show)

See Also:


Attachments
WIP patch (13.31 KB, patch)
2011-09-14 21:27 PDT, Kentaro Hara
no flags Details | Formatted Diff | Diff
WIP patch (12.67 KB, patch)
2011-09-14 21:56 PDT, Kentaro Hara
no flags Details | Formatted Diff | Diff
Patch (13.87 KB, patch)
2011-09-15 00:41 PDT, Kentaro Hara
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kentaro Hara 2011-09-12 18:41:49 PDT
PopStateEvent should have a constructor (Spec: http://www.whatwg.org/specs/web-apps/current-work/#popstateevent). 

After this patch is landed, I will add the PopStateEvent constructor for V8 as a follow-up patch.
Comment 1 Kentaro Hara 2011-09-14 21:27:25 PDT
Created attachment 107450 [details]
WIP patch
Comment 2 Kentaro Hara 2011-09-14 21:56:09 PDT
Created attachment 107455 [details]
WIP patch
Comment 3 Kentaro Hara 2011-09-14 22:08:33 PDT
Question: Which should IDL 'any' be implemented as ScriptValue or SerializedScriptValue?

The spec says that the type of both PopStateEvent.state and CustomEvent.detail should be 'any' (http://www.whatwg.org/specs/web-apps/current-work/#popstateevent, http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-customevent). However, in the current WebCore implementation, CustomEvent.state is implemented as ScriptValue (https://bugs.webkit.org/show_bug.cgi?id=67248), and PopStateEvent.detail is implemented as SerializedScriptValue. Which is correct?

If we use SerializedScriptValue, some tests violate the spec of IDL 'any' (http://www.w3.org/TR/WebIDL/#es-any), as you can see in the WIP patch.

> FAIL new PopStateEvent('eventType', { state: '' }).state should be undefined (of type undefined). Was  (of type string).
> FAIL new PopStateEvent('eventType', { state: object1 }).state should be [object Object]. Was [object Object].
> FAIL new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state should be [object Object]. Was [object Object].
> FAIL new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).state should be [object Object]. Was [object Object].

In addition, if we use SerializedScriptValue, the test crashes when we pass a DOM object. (I guess we can fix this crash, but we need to throw some exception anyway.)

> //shouldBe("new PopStateEvent('eventType', { state: document }).state", "document"); // Crash!!!

On the other hand, if we use ScriptValue, we can get correct test results.

With these observations, I guess that we should implement PopStateEvent.state as ScriptValue, but are there any problem to change it from SeriazliedScriptValue to ScriptValue?
Comment 4 Kentaro Hara 2011-09-14 22:12:10 PDT
> CustomEvent.state is implemented as ScriptValue (https://bugs.webkit.org/show_bug.cgi?id=67248), and PopStateEvent.detail is implemented as SerializedScriptValue.

Correction:

CustomEvent.detail is implemented as ScriptValue (https://bugs.webkit.org/show_bug.cgi?id=67248), and PopStateEvent.state is implemented as SerializedScriptValue.
Comment 5 Sam Weinig 2011-09-14 22:33:00 PDT
For now, I would match what the event already has, and file follow up bugs.
Comment 6 Kentaro Hara 2011-09-15 00:41:05 PDT
Created attachment 107472 [details]
Patch
Comment 7 Kentaro Hara 2011-09-15 00:42:21 PDT
(In reply to comment #5)
> For now, I would match what the event already has, and file follow up bugs.

Sam: Thanks. If the patch is OK, I will file the follow-up bugs.
Comment 8 Sam Weinig 2011-09-15 09:42:14 PDT
Comment on attachment 107472 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=107472&action=review

> Source/WebCore/dom/PopStateEvent.cpp:36
> +PopStateEventInit::PopStateEventInit()
> +{
> +    state = SerializedScriptValue::create();

This should probably use initializer syntax.
Comment 9 WebKit Review Bot 2011-09-15 19:45:02 PDT
Comment on attachment 107472 [details]
Patch

Clearing flags on attachment: 107472

Committed r95262: <http://trac.webkit.org/changeset/95262>
Comment 10 WebKit Review Bot 2011-09-15 19:45:07 PDT
All reviewed patches have been landed.  Closing bug.