Changeset 96073 in webkit
- Timestamp:
- Sep 26, 2011 11:27:02 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r96069 r96073 1 2011-09-26 Kentaro Hara <haraken@chromium.org> 2 3 Implement PopStateEvent.state with SerializedScriptValue and ScriptValue 4 https://bugs.webkit.org/show_bug.cgi?id=68345 5 6 Reviewed by Adam Barth. 7 8 * fast/events/constructors/pop-state-event-constructor-expected.txt: 9 * fast/events/constructors/pop-state-event-constructor.html: Removed failures and crashes. Added one test case. 10 1 11 2011-09-09 Simon Fraser <simon.fraser@apple.com> 2 12 -
trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor-expected.txt
r95262 r96073 11 11 PASS new PopStateEvent('eventType', { cancelable: false }).cancelable is false 12 12 PASS new PopStateEvent('eventType', { cancelable: true }).cancelable is true 13 FAIL new PopStateEvent('eventType', { state: object1 }).state should be [object Object]. Was [object Object]. 13 PASS new PopStateEvent('eventType', { state: object1 }).state is object1 14 PASS new PopStateEvent('eventType', { state: document }).state is document 14 15 PASS new PopStateEvent('eventType', { state: undefined }).state is undefined 15 16 PASS new PopStateEvent('eventType', { state: null }).state is null 16 17 PASS new PopStateEvent('eventType', { state: false }).state is false 17 18 PASS new PopStateEvent('eventType', { state: true }).state is true 18 FAIL new PopStateEvent('eventType', { state: '' }).state should be undefined (of type undefined). Was (of type string). 19 PASS new PopStateEvent('eventType', { state: '' }).state is "" 20 PASS new PopStateEvent('eventType', { state: 'doremi' }).state is "doremi" 19 21 PASS new PopStateEvent('eventType', { state: 12345 }).state is 12345 20 22 PASS new PopStateEvent('eventType', { state: 18446744073709551615 }).state is 18446744073709552000 21 23 PASS new PopStateEvent('eventType', { state: NaN }).state is NaN 22 FAIL new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state should be [object Object]. Was [object Object]. 24 PASS new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state == object2 is false 23 25 PASS new PopStateEvent('eventType', { get state() { return 123; } }).state is 123 24 26 PASS new PopStateEvent('eventType', { get state() { throw 'PopState Error'; } }) threw exception PopState Error. 25 27 PASS new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).bubbles is true 26 28 PASS new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).cancelable is true 27 FAIL new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).state should be [object Object]. Was [object Object]. 29 PASS new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).state is object3 28 30 PASS successfullyParsed is true 29 31 -
trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor.html
r95262 r96073 28 28 var object1 = {nyannyan: 123}; 29 29 shouldBe("new PopStateEvent('eventType', { state: object1 }).state", "object1"); 30 // FIXME(haraken): When we pass a DOM object, it crashes. 31 // shouldBe("new PopStateEvent('eventType', { state: document }).state", "document"); 30 shouldBe("new PopStateEvent('eventType', { state: document }).state", "document"); 32 31 shouldBe("new PopStateEvent('eventType', { state: undefined }).state", "undefined"); 33 32 shouldBe("new PopStateEvent('eventType', { state: null }).state", "null"); 34 33 shouldBe("new PopStateEvent('eventType', { state: false }).state", "false"); 35 34 shouldBe("new PopStateEvent('eventType', { state: true }).state", "true"); 36 shouldBe("new PopStateEvent('eventType', { state: '' }).state", ""); 35 shouldBeEqualToString("new PopStateEvent('eventType', { state: '' }).state", ""); 36 shouldBeEqualToString("new PopStateEvent('eventType', { state: 'doremi' }).state", "doremi"); 37 37 shouldBe("new PopStateEvent('eventType', { state: 12345 }).state", "12345"); 38 38 shouldBe("new PopStateEvent('eventType', { state: 18446744073709551615 }).state", "18446744073709552000"); 39 39 shouldBe("new PopStateEvent('eventType', { state: NaN }).state", "NaN"); 40 40 var object2 = {nyannyan: 456}; 41 shouldBe("new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state", "object2"); 41 // Note that valueOf() is not called when the left hand side is evaluated. 42 shouldBeFalse("new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state == object2"); 42 43 shouldBe("new PopStateEvent('eventType', { get state() { return 123; } }).state", "123"); 43 44 shouldThrow("new PopStateEvent('eventType', { get state() { throw 'PopState Error'; } })"); -
trunk/Source/WebCore/ChangeLog
r96070 r96073 1 2011-09-26 Kentaro Hara <haraken@chromium.org> 2 3 Implement PopStateEvent.state with SerializedScriptValue and ScriptValue 4 https://bugs.webkit.org/show_bug.cgi?id=68345 5 6 Reviewed by Adam Barth. 7 8 Previously, the following test cases fail or crash: 9 10 - shouldBe("new PopStateEvent('eventType', { state: object1 }).state", "object1") -> FAIL 11 - new PopStateEvent('eventType', { state: document }).state -> CRASH in DRT 12 13 This is because PopStateEvent.state is implemented not as ScriptValue but as SerializedScriptValue. 14 However, we cannot simply change the type of PopStateEvent.state to ScriptValue, 15 since PopStateEvent can be constructed in the context that does not know ScriptValue. 16 For example, Document.cpp calls PopStateEvent::create() with SerializedScriptValue 17 popped from HistoryItem, but we cannot deserialize the SerializedScriptValue into 18 the corresponding ScriptValue here because the deserialization requires ExecState. 19 In other words, although we want to store PopStateEvent.state by ScriptValue internally, 20 PopStateEvent still needs to provide an API to construct it with SerializedScriptValue. 21 With these observations, this patch makes the following changes: 22 23 - If PopStateEvent is constructed with ScriptValue, it is stored as ScriptValue internally. 24 When PopStateEvent.state is called, the ScriptValue is returned. 25 - If PopStateEvent is constructed with SerializedScriptValue, it is stored as 26 SerializedScriptValue internally (since we cannot deserialize it into ScriptValue 27 at this point). When PopStateEvent.state is called, the SerializedScriptValue is 28 deserialized into the corresponding ScriptValue, and the ScriptValue is returned. 29 30 Tests: fast/events/constructors/pop-state-event-constructor.html 31 fast/events/fire-popstate-event.html 32 33 * GNUmakefile.list.am: Added JSPopStateEventCustom.cpp. 34 * UseJSC.cmake: Ditto. 35 * WebCore.gypi: Ditto. 36 * WebCore.pro: Ditto. 37 * WebCore.xcodeproj/project.pbxproj: Ditto. 38 * bindings/js/JSBindingsAllInOne.cpp: Ditto. 39 * bindings/js/JSPopStateEventCustom.cpp: 40 (WebCore::JSPopStateEvent::state): Custom getter for PopStateEvent.state. 41 * bindings/v8/custom/V8PopStateEventCustom.cpp: 42 (WebCore::V8PopStateEvent::stateAccessorGetter): Custom getter for PopStateEvent.state. 43 * dom/PopStateEvent.cpp: 44 (WebCore::PopStateEventInit::PopStateEventInit): Added initialization code for PopStateEvent.m_state. 45 (WebCore::PopStateEvent::PopStateEvent): Ditto. 46 (WebCore::PopStateEvent::create): Ditto. 47 (WebCore::PopStateEvent::initPopStateEvent): Ditto. 48 * dom/PopStateEvent.h: 49 (WebCore::PopStateEvent::serializedState): Getter. 50 (WebCore::PopStateEvent::state): Getter. 51 * dom/PopStateEvent.idl: Change the type of 'stateArg' and 'state' to DOMObject. Added [CustomGetter] to 'state'. 52 1 53 2011-09-09 Simon Fraser <simon.fraser@apple.com> 2 54 -
trunk/Source/WebCore/GNUmakefile.list.am
r96064 r96073 794 794 Source/WebCore/bindings/js/JSPluginElementFunctions.cpp \ 795 795 Source/WebCore/bindings/js/JSPluginElementFunctions.h \ 796 Source/WebCore/bindings/js/JSPopStateEventCustom.cpp \ 796 797 Source/WebCore/bindings/js/JSProcessingInstructionCustom.cpp \ 797 798 Source/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp \ -
trunk/Source/WebCore/UseJSC.cmake
r95486 r96073 106 106 bindings/js/JSPeerConnectionCustom.cpp 107 107 bindings/js/JSPluginElementFunctions.cpp 108 bindings/js/JSPopStateEventCustom.cpp 108 109 bindings/js/JSProcessingInstructionCustom.cpp 109 110 bindings/js/JSScriptProfileNodeCustom.cpp -
trunk/Source/WebCore/WebCore.gypi
r96064 r96073 1898 1898 'bindings/js/JSPeerConnectionCustom.cpp', 1899 1899 'bindings/js/JSPluginElementFunctions.cpp', 1900 'bindings/js/JSPopStateEventCustom.cpp', 1900 1901 'bindings/js/JSProcessingInstructionCustom.cpp', 1901 1902 'bindings/js/JSSQLResultSetRowListCustom.cpp', -
trunk/Source/WebCore/WebCore.pro
r96064 r96073 324 324 bindings/js/JSOptionConstructor.cpp \ 325 325 bindings/js/JSPluginElementFunctions.cpp \ 326 bindings/js/JSPopStateEventCustom.cpp \ 326 327 bindings/js/JSProcessingInstructionCustom.cpp \ 327 328 bindings/js/JSScriptProfileNodeCustom.cpp \ -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r96064 r96073 3731 3731 A84EBD840CB8C97700079609 /* JSStyleSheetList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A84EBD820CB8C97700079609 /* JSStyleSheetList.cpp */; }; 3732 3732 A853123D11D0471B00D4D077 /* FragmentScriptingPermission.h in Headers */ = {isa = PBXBuildFile; fileRef = A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3733 A85F22091430377D007CC884 /* JSPopStateEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */; }; 3733 3734 A863E2011343412000274926 /* UnicodeBidi.h in Headers */ = {isa = PBXBuildFile; fileRef = A863E2001343412000274926 /* UnicodeBidi.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3734 3735 A86629CF09DA2B47009633A5 /* JSUIEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A86629C909DA2B47009633A5 /* JSUIEvent.h */; }; … … 10253 10254 A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FragmentScriptingPermission.h; sourceTree = "<group>"; }; 10254 10255 A85D7A2F0879EBA9006A9172 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; }; 10256 A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPopStateEventCustom.cpp; sourceTree = "<group>"; }; 10255 10257 A863E2001343412000274926 /* UnicodeBidi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnicodeBidi.h; sourceTree = "<group>"; }; 10256 10258 A86629C909DA2B47009633A5 /* JSUIEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSUIEvent.h; sourceTree = "<group>"; }; … … 18718 18720 isa = PBXGroup; 18719 18721 children = ( 18722 A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */, 18720 18723 BC275CB211C5E85C00C9206C /* JSArrayBufferCustom.cpp */, 18721 18724 86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */, … … 26353 26356 0FE71405142170B800DB33BA /* ScrollbarThemeMock.cpp in Sources */, 26354 26357 5D8C4DBF1428222C0026CE72 /* DisplaySleepDisabler.cpp in Sources */, 26358 A85F22091430377D007CC884 /* JSPopStateEventCustom.cpp in Sources */, 26355 26359 ); 26356 26360 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
r96023 r96073 127 127 #include "JSPeerConnectionCustom.cpp" 128 128 #include "JSPluginElementFunctions.cpp" 129 #include "JSPopStateEventCustom.cpp" 129 130 #include "JSProcessingInstructionCustom.cpp" 130 131 #include "JSRequestAnimationFrameCallbackCustom.cpp" -
trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp
r96071 r96073 1 1 /* 2 * Copyright (C) 201 0Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 31 31 #include "config.h" 32 #include "V8PopStateEvent.h"33 32 34 #include " PopStateEvent.h"35 #include "SerializedScriptValue.h" 36 #include "V8Proxy.h" 33 #include "JSPopStateEvent.h" 34 35 using namespace JSC; 37 36 38 37 namespace WebCore { 39 38 40 v8::Handle<v8::Value> V8PopStateEvent::stateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 39 JSValue JSPopStateEvent::state(ExecState* exec) const 41 40 { 42 INC_STATS("DOM.PopStateEvent.state"); 43 44 PopStateEvent* event = V8PopStateEvent::toNative(info.Holder()); 45 SerializedScriptValue* state = event->state(); 46 if (!state) 47 return v8::Null(); 48 49 return state->deserialize(); 41 PopStateEvent* event = static_cast<PopStateEvent*>(impl()); 42 SerializedScriptValue* serializedState = event->serializedState(); 43 if (serializedState) 44 return serializedState->deserialize(exec, globalObject()); 45 if (!event->state().hasNoValue()) 46 return event->state().jsValue(); 47 return jsNull(); 50 48 } 51 49 -
trunk/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp
r95901 r96073 43 43 44 44 PopStateEvent* event = V8PopStateEvent::toNative(info.Holder()); 45 SerializedScriptValue* state = event->state(); 46 if (!state) 47 return v8::Null(); 48 49 return state->deserialize(); 45 SerializedScriptValue* serializedState = event->serializedState(); 46 if (serializedState) 47 return serializedState->deserialize(); 48 if (!event->state().hasNoValue()) 49 return event->state().v8Value(); 50 return v8::Null(); 50 51 } 51 52 -
trunk/Source/WebCore/dom/PopStateEvent.cpp
r95901 r96073 34 34 PopStateEventInit::PopStateEventInit() 35 35 { 36 state = SerializedScriptValue::create();37 36 } 38 37 39 38 PopStateEvent::PopStateEvent() 40 39 : Event(eventNames().popstateEvent, false, true) 40 , m_serializedState(0) 41 41 { 42 42 } … … 44 44 PopStateEvent::PopStateEvent(const AtomicString& type, const PopStateEventInit& initializer) 45 45 : Event(type, initializer) 46 , m_stateObject(initializer.state) 46 , m_state(initializer.state) 47 , m_serializedState(0) 47 48 { 48 49 } 49 50 50 PopStateEvent::PopStateEvent( PassRefPtr<SerializedScriptValue> stateObject)51 PopStateEvent::PopStateEvent(ScriptValue state) 51 52 : Event(eventNames().popstateEvent, false, true) 52 , m_stateObject(stateObject) 53 , m_state(state) 54 , m_serializedState(0) 55 { 56 } 57 58 PopStateEvent::PopStateEvent(PassRefPtr<SerializedScriptValue> serializedState) 59 : Event(eventNames().popstateEvent, false, true) 60 , m_serializedState(serializedState) 53 61 { 54 62 } … … 63 71 } 64 72 65 PassRefPtr<PopStateEvent> PopStateEvent::create( PassRefPtr<SerializedScriptValue> stateObject)73 PassRefPtr<PopStateEvent> PopStateEvent::create(ScriptValue state) 66 74 { 67 return adoptRef(new PopStateEvent(stateObject)); 75 return adoptRef(new PopStateEvent(state)); 76 } 77 78 PassRefPtr<PopStateEvent> PopStateEvent::create(PassRefPtr<SerializedScriptValue> serializedState) 79 { 80 return adoptRef(new PopStateEvent(serializedState)); 68 81 } 69 82 … … 73 86 } 74 87 75 void PopStateEvent::initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> stateObject)88 void PopStateEvent::initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue state) 76 89 { 77 90 if (dispatched()) 78 91 return; 79 92 80 93 initEvent(type, canBubble, cancelable); 81 94 82 m_state Object = stateObject;95 m_state = state; 83 96 } 84 97 -
trunk/Source/WebCore/dom/PopStateEvent.h
r95901 r96073 29 29 30 30 #include "Event.h" 31 #include "ScriptValue.h" 31 32 #include "SerializedScriptValue.h" 32 33 33 34 namespace WebCore { 34 35 35 class SerializedScriptValue;36 37 36 struct PopStateEventInit : public EventInit { 38 37 PopStateEventInit(); 39 38 40 RefPtr<SerializedScriptValue>state;39 ScriptValue state; 41 40 }; 42 41 … … 45 44 virtual ~PopStateEvent(); 46 45 static PassRefPtr<PopStateEvent> create(); 46 static PassRefPtr<PopStateEvent> create(ScriptValue); 47 47 static PassRefPtr<PopStateEvent> create(PassRefPtr<SerializedScriptValue>); 48 48 static PassRefPtr<PopStateEvent> create(const AtomicString&, const PopStateEventInit&); 49 void initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue>);49 void initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue); 50 50 bool isPopStateEvent() const { return true; } 51 51 52 SerializedScriptValue* state() const { return m_stateObject.get(); } 52 SerializedScriptValue* serializedState() const { return m_serializedState.get(); } 53 ScriptValue state() const { return m_state; } 53 54 54 55 private: 55 56 PopStateEvent(); 56 57 PopStateEvent(const AtomicString&, const PopStateEventInit&); 58 explicit PopStateEvent(ScriptValue); 57 59 explicit PopStateEvent(PassRefPtr<SerializedScriptValue>); 58 60 59 RefPtr<SerializedScriptValue> m_stateObject; 61 ScriptValue m_state; 62 RefPtr<SerializedScriptValue> m_serializedState; 60 63 }; 61 64 -
trunk/Source/WebCore/dom/PopStateEvent.idl
r95262 r96073 35 35 in [Optional=CallWithDefaultValue] boolean canBubbleArg, 36 36 in [Optional=CallWithDefaultValue] boolean cancelableArg, 37 in [Optional=CallWithDefaultValue] SerializedScriptValuestateArg);37 in [Optional=CallWithDefaultValue] DOMObject stateArg); 38 38 39 readonly attribute [ V8CustomGetter] anystate;39 readonly attribute [CustomGetter] DOMObject state; 40 40 }; 41 41 #endif
Note: See TracChangeset
for help on using the changeset viewer.