WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-117523-20131128230531.patch (text/plain), 33.17 KB, created by
Tullio Lucena
on 2013-11-28 18:05:28 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tullio Lucena
Created:
2013-11-28 18:05:28 PST
Size:
33.17 KB
patch
obsolete
>Subversion Revision: 159862 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d0334226da84434118a3267045e8ebde7c7dd79d..f5c8accaccee8d8f2dc28d79d18bad3f50d98aae 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,23 @@ >+2013-11-28 Tullio Lucena <tullio.lucena@openbossa.org> >+ >+ [WK2] Proof of concept to inject custom JavaScript objects on WebWorker context. >+ https://bugs.webkit.org/show_bug.cgi?id=117523 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Callbacks were added for initialize and terminate WebWorkers using WK2 API. >+ These callbacks handle bindings between functions of JavaScript Workers and functions defined at a previously loaded bundle. >+ An API test was added to check the these callbacks. It verifies the two types of workers, dedicated and shared. >+ >+ * bindings/js/WorkerScriptController.cpp: >+ (WebCore::WorkerScriptController::~WorkerScriptController): >+ (WebCore::WorkerScriptController::initScript): >+ (WebCore::WorkerScriptController::setInitScriptCallback): >+ (WebCore::WorkerScriptController::initScriptCallback): >+ (WebCore::WorkerScriptController::setTerminateScriptCallback): >+ (WebCore::WorkerScriptController::terminateScriptCallback): >+ * bindings/js/WorkerScriptController.h: >+ > 2013-11-28 Gyuyoung Kim <gyuyoung.kim@samsung.com> > > Rename InlineIterator::m_obj and make it private >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 14a5cf0567598d1652ddc67bf23f0dacc5ef4b72..b84a231322d187247f6831fc9309ed158f056854 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,21 @@ >+2013-11-28 Tullio Lucena <tullio.lucena@openbossa.org> >+ >+ [WK2] Proof of concept to inject custom JavaScript objects on WebWorker context. >+ https://bugs.webkit.org/show_bug.cgi?id=117523 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Callbacks were added for initialize and terminate WebWorkers using WK2 API. >+ These callbacks handle bindings between functions of JavaScript Workers and functions defined at a previously loaded bundle. >+ An API test was added to check the these callbacks. It verifies the two types of workers, dedicated and shared. >+ >+ * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: >+ (localWorkerScriptInitCallback): >+ (WKBundleFrameSetWorkerInitializeCallback): >+ (localWorkerScriptTerminateCallback): >+ (WKBundleFrameSetWorkerTerminateCallback): >+ * WebProcess/InjectedBundle/API/c/WKBundleFrame.h: >+ > 2013-11-28 Nick Diego Yamane <nick.yamane@openbossa.org> > > [GTK] Build fix after r159859 >diff --git a/Source/WebCore/bindings/js/WorkerScriptController.cpp b/Source/WebCore/bindings/js/WorkerScriptController.cpp >index 290b1f11444a6a4cb23e977d1da8b7945b0b4398..581d7dcbf039449551701bd1f526f75907d0b8ed 100644 >--- a/Source/WebCore/bindings/js/WorkerScriptController.cpp >+++ b/Source/WebCore/bindings/js/WorkerScriptController.cpp >@@ -63,6 +63,9 @@ WorkerScriptController::WorkerScriptController(WorkerGlobalScope* workerGlobalSc > > WorkerScriptController::~WorkerScriptController() > { >+ if (terminateScriptCallback()) >+ terminateScriptCallback()(m_workerGlobalScopeWrapper->globalExec(), m_workerGlobalScope->isDedicatedWorkerGlobalScope()); >+ > JSLockHolder lock(vm()); > m_workerGlobalScopeWrapper.clear(); > m_vm.clear(); >@@ -106,6 +109,9 @@ void WorkerScriptController::initScript() > } > ASSERT(m_workerGlobalScopeWrapper->globalObject() == m_workerGlobalScopeWrapper); > ASSERT(asObject(m_workerGlobalScopeWrapper->prototype())->globalObject() == m_workerGlobalScopeWrapper); >+ >+ if (initScriptCallback()) >+ initScriptCallback()(m_workerGlobalScopeWrapper->globalExec(), m_workerGlobalScope->isDedicatedWorkerGlobalScope()); > } > > void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) >@@ -203,4 +209,27 @@ void WorkerScriptController::detachDebugger(JSC::Debugger* debugger) > debugger->detach(m_workerGlobalScopeWrapper->globalObject()); > } > >+WorkerScriptCallback WorkerScriptController::m_initScriptCallback = 0; >+WorkerScriptCallback WorkerScriptController::m_terminateScriptCallback = 0; >+ >+void WorkerScriptController::setInitScriptCallback(WorkerScriptCallback callback) >+{ >+ m_initScriptCallback = callback; >+} >+ >+WorkerScriptCallback WorkerScriptController::initScriptCallback() >+{ >+ return m_initScriptCallback; >+} >+ >+void WorkerScriptController::setTerminateScriptCallback(WorkerScriptCallback callback) >+{ >+ m_terminateScriptCallback = callback; >+} >+ >+WorkerScriptCallback WorkerScriptController::terminateScriptCallback() >+{ >+ return m_terminateScriptCallback; >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/bindings/js/WorkerScriptController.h b/Source/WebCore/bindings/js/WorkerScriptController.h >index 8bb7f49b085fc5cdd87227719e3315f1a26b8f85..91cf76c8a7ce3664c9ea4ca2d52ef530833816f2 100644 >--- a/Source/WebCore/bindings/js/WorkerScriptController.h >+++ b/Source/WebCore/bindings/js/WorkerScriptController.h >@@ -39,6 +39,8 @@ namespace JSC { > > namespace WebCore { > >+ typedef void (*WorkerScriptCallback)(JSC::ExecState*, bool); >+ > class JSWorkerGlobalScope; > class ScriptSourceCode; > class ScriptValue; >@@ -81,6 +83,10 @@ namespace WebCore { > void attachDebugger(JSC::Debugger*); > void detachDebugger(JSC::Debugger*); > >+ static void setInitScriptCallback(WorkerScriptCallback); >+ static WorkerScriptCallback initScriptCallback(); >+ static void setTerminateScriptCallback(WorkerScriptCallback); >+ static WorkerScriptCallback terminateScriptCallback(); > private: > void initScriptIfNeeded() > { >@@ -94,6 +100,9 @@ namespace WebCore { > JSC::Strong<JSWorkerGlobalScope> m_workerGlobalScopeWrapper; > bool m_executionForbidden; > mutable Mutex m_scheduledTerminationMutex; >+ >+ static WorkerScriptCallback m_initScriptCallback; >+ static WorkerScriptCallback m_terminateScriptCallback; > }; > > } // namespace WebCore >diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp >index 91279cb785815fbfa8189069ae7fb2cdbb959132..a8fcc0c7a35c891870b488b08c20702cddf63058 100644 >--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp >+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp >@@ -29,6 +29,7 @@ > > #include "APIArray.h" > #include "InjectedBundleHitTestResult.h" >+#include "JavaScriptCore/APICast.h" > #include "WKAPICast.h" > #include "WKBundleAPICast.h" > #include "WKData.h" >@@ -38,6 +39,8 @@ > #include <WebCore/Frame.h> > #include <WebCore/FrameLoader.h> > #include <WebCore/FrameView.h> >+#include <WebCore/WorkerScriptController.h> >+ > > using namespace WebCore; > using namespace WebKit; >@@ -106,6 +109,38 @@ JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef fr > return toImpl(frameRef)->jsContextForWorld(toImpl(worldRef)); > } > >+static WKBundleFrameWorkerScriptCallback s_localWorkerScriptInitCallback; >+ >+static void localWorkerScriptInitCallback(JSC::ExecState* execState, bool isDedicated) >+{ >+ s_localWorkerScriptInitCallback(toRef(execState), isDedicated); >+} >+ >+void WKBundleFrameSetWorkerInitializeCallback(WKBundleFrameWorkerScriptCallback callback) >+{ >+ if (callback) { >+ s_localWorkerScriptInitCallback = callback; >+ WorkerScriptController::setInitScriptCallback(localWorkerScriptInitCallback); >+ } else >+ WorkerScriptController::setInitScriptCallback(0); >+} >+ >+static WKBundleFrameWorkerScriptCallback s_localWorkerScriptTerminateCallback; >+ >+static void localWorkerScriptTerminateCallback(JSC::ExecState* execState, bool isDedicated) >+{ >+ s_localWorkerScriptTerminateCallback(toRef(execState), isDedicated); >+} >+ >+void WKBundleFrameSetWorkerTerminateCallback(WKBundleFrameWorkerScriptCallback callback) >+{ >+ if (callback) { >+ s_localWorkerScriptTerminateCallback = callback; >+ WorkerScriptController::setTerminateScriptCallback(localWorkerScriptTerminateCallback); >+ } else >+ WorkerScriptController::setTerminateScriptCallback(0); >+} >+ > JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frameRef, WKBundleNodeHandleRef nodeHandleRef, WKBundleScriptWorldRef worldRef) > { > return toImpl(frameRef)->jsWrapperForWorld(toImpl(nodeHandleRef), toImpl(worldRef)); >diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h >index 8c2b875f50f40fc3ab31b29abe2abbea408f544f..539718d057d7dc6f5b74343d9ce25563762beea7 100644 >--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h >+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h >@@ -51,6 +51,10 @@ WK_EXPORT WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frame > WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame); > WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frame, WKBundleScriptWorldRef world); > >+typedef void (*WKBundleFrameWorkerScriptCallback)(JSContextRef context, int isDedicated); >+WK_EXPORT void WKBundleFrameSetWorkerInitializeCallback(WKBundleFrameWorkerScriptCallback callback); >+WK_EXPORT void WKBundleFrameSetWorkerTerminateCallback(WKBundleFrameWorkerScriptCallback callback); >+ > WK_EXPORT WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef context); > > WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index cef003221bdefa35c23f719e5a9e658cf03cdac9..78cd9056f10ec5546efc61e58d149fd4a804ab27 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,37 @@ >+2013-11-28 Tullio Lucena <tullio.lucena@openbossa.org> >+ >+ [WK2] Proof of concept to inject custom JavaScript objects on WebWorker context. >+ https://bugs.webkit.org/show_bug.cgi?id=117523 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Callbacks were added for initialize and terminate WebWorkers using WK2 API. >+ These callbacks handle bindings between functions of JavaScript Workers and functions defined at a previously loaded bundle. >+ An API test was added to check the these callbacks. It verifies the two types of workers, dedicated and shared. >+ >+ * TestWebKitAPI/CMakeLists.txt: >+ * TestWebKitAPI/GNUmakefile.am: >+ * TestWebKitAPI/PlatformEfl.cmake: >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKit2/WebWorker.cpp: Added. >+ (TestWebKitAPI::didReceiveMessageFromInjectedBundle): >+ (TestWebKitAPI::didReceiveTitleForFrame): >+ (TestWebKitAPI::TEST): >+ * TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp: Added. >+ (TestWebKitAPI::foo): >+ (TestWebKitAPI::bar): >+ (TestWebKitAPI::webWorkerInitialize): >+ (TestWebKitAPI::webWorkerTerminate): >+ (TestWebKitAPI::WebWorkerTest::WebWorkerTest): >+ (TestWebKitAPI::WebWorkerTest::initialize): >+ * TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.html: Added. >+ * TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.js: Added. >+ (onconnect): >+ (listenForMessage): >+ * TestWebKitAPI/Tests/WebKit2/webWorkerTest.html: Added. >+ * TestWebKitAPI/Tests/WebKit2/webWorkerTest.js: Added. >+ (self.onmessage): >+ > 2013-11-28 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r159839. >diff --git a/Tools/TestWebKitAPI/CMakeLists.txt b/Tools/TestWebKitAPI/CMakeLists.txt >index 2578518e3fc1ad788ef88970a8e7ae63c1e755a4..873d5dc7b2ccf174ce7e58387d15a1a9616d4d11 100644 >--- a/Tools/TestWebKitAPI/CMakeLists.txt >+++ b/Tools/TestWebKitAPI/CMakeLists.txt >@@ -10,6 +10,7 @@ include_directories(${CMAKE_BINARY_DIR} > ${JAVASCRIPTCORE_DIR}/API > ${JAVASCRIPTCORE_DIR}/ForwardingHeaders > ${THIRDPARTY_DIR}/gtest/include >+ ${WEBCORE_DIR}/bindings/js > ${WEBCORE_DIR}/editing > ${WEBCORE_DIR}/platform > ${WEBCORE_DIR}/platform/graphics >@@ -76,6 +77,7 @@ add_library(TestWebKitAPIInjectedBundle SHARED > ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage_Bundle.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKConnection_Bundle.cpp >+ ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WebWorker_Bundle.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillLoad_Bundle.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp > ) >diff --git a/Tools/TestWebKitAPI/GNUmakefile.am b/Tools/TestWebKitAPI/GNUmakefile.am >index 03428aa72259219165140c4ea599ae22c27618d8..3f4cea273d26d721d75e150dc9c5e992025fd6b6 100644 >--- a/Tools/TestWebKitAPI/GNUmakefile.am >+++ b/Tools/TestWebKitAPI/GNUmakefile.am >@@ -293,6 +293,7 @@ Programs_TestWebKitAPI_TestWebKit2_SOURCES = \ > Tools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/TerminateTwice.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/UserMessage.cpp \ >+ Tools/TestWebKitAPI/Tests/WebKit2/WebWorker.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/WillLoad.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/WillSendSubmitEvent.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/WKConnection.cpp \ >@@ -334,6 +335,7 @@ Libraries_libTestWebKitAPIInjectedBundle_la_SOURCES = \ > Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/UserMessage_Bundle.cpp \ >+ Tools/TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/WillLoad_Bundle.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp \ > Tools/TestWebKitAPI/Tests/WebKit2/WKConnection_Bundle.cpp \ >diff --git a/Tools/TestWebKitAPI/PlatformEfl.cmake b/Tools/TestWebKitAPI/PlatformEfl.cmake >index 7ffc6cf90067f211d039c4d8cdc42144989da3da..02ec6cbf3f2d7ff1a6357ac955ea056c86f9edec 100644 >--- a/Tools/TestWebKitAPI/PlatformEfl.cmake >+++ b/Tools/TestWebKitAPI/PlatformEfl.cmake >@@ -54,6 +54,7 @@ set(test_webcore_BINARIES > > # In here we list the bundles that are used by our specific WK2 API Tests > list(APPEND bundle_harness_SOURCES >+ ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WebWorker_Bundle.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive_Bundle.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp > ) >@@ -101,6 +102,7 @@ set(test_webkit2_api_BINARIES > WKString > WKStringJSString > WKURL >+ WebWorker > WillLoad > WillSendSubmitEvent > CoordinatedGraphics/WKViewIsActiveSetIsActive >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 4936b1c8a4e2f3f4ebaebcf766665b466f3e8185..83e97ba8e65276b35128b53aaa09cd1cc29c467d 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -66,6 +66,12 @@ > 333B9CE21277F23100FEFCE3 /* PreventEmptyUserAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */; }; > 33BE5AF5137B5A6C00705813 /* MouseMoveAfterCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */; }; > 33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; }; >+ 33BE5AFA137B5A2100705813 /* WebWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AFA137B5A2300705813 /* WebWorker.cpp */; }; >+ 33BE5AFB137B5A2200705813 /* WebWorker_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AFB137B5A2400705813 /* WebWorker_Bundle.cpp */; }; >+ 33BE4BE137B54B2500614713 /* webWorkerSharedTest.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33BE4BEC137B512700614713 /* webWorkerSharedTest.html */; }; >+ 33BE4BE137B54B2600614713 /* webWorkerSharedTest.js in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33BE4BEC137B512800614713 /* webWorkerSharedTest.js */; }; >+ 33BE4BE137B54B2900614713 /* webWorkerTest.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33BE4BEC137B512B00614713 /* webWorkerTest.html */; }; >+ 33BE4BE137B54B2A00614713 /* webWorkerTest.js in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33BE4BEC137B512C00614713 /* webWorkerTest.js */; }; > 33DC8911141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */; }; > 33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; }; > 33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; }; >@@ -324,6 +330,10 @@ > C01A23F21266156700C9ED55 /* spacebar-scrolling.html in Copy Resources */, > E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */, > C540F784152E5A9A00A40C8C /* verboseMarkup.html in Copy Resources */, >+ 33BE4BE137B54B2500614713 /* webWorkerSharedTest.html in Copy Resources */, >+ 33BE4BE137B54B2600614713 /* webWorkerSharedTest.js in Copy Resources */, >+ 33BE4BE137B54B2900614713 /* webWorkerTest.html in Copy Resources */, >+ 33BE4BE137B54B2A00614713 /* webWorkerTest.js in Copy Resources */, > A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */, > ); > name = "Copy Resources"; >@@ -392,6 +402,12 @@ > 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; }; > 33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash.cpp; sourceTree = "<group>"; }; > 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash_Bundle.cpp; sourceTree = "<group>"; }; >+ 33BE5AFA137B5A2300705813 /* WebWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebWorker.cpp; sourceTree = "<group>"; }; >+ 33BE5AFB137B5A2400705813 /* WebWorker_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebWorker_Bundle.cpp; sourceTree = "<group>"; }; >+ 33BE4BEC137B512700614713 /* webWorkerSharedTest.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "webWorkerSharedTest.html"; sourceTree = "<group>"; }; >+ 33BE4BEC137B512800614713 /* webWorkerSharedTest.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "webWorkerSharedTest.js"; sourceTree = "<group>"; }; >+ 33BE4BEC137B512B00614713 /* webWorkerTest.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "webWorkerTest.html"; sourceTree = "<group>"; }; >+ 33BE4BEC137B512C00614713 /* webWorkerTest.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "webWorkerTest.js"; sourceTree = "<group>"; }; > 33DC890E1419539300747EF7 /* simple-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-iframe.html"; sourceTree = "<group>"; }; > 33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCanceledNoServerRedirectCallback.cpp; sourceTree = "<group>"; }; > 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCanceledNoServerRedirectCallback_Bundle.cpp; sourceTree = "<group>"; }; >@@ -817,6 +833,8 @@ > 520BCF4B141EB09E00937EA8 /* WebArchive.cpp */, > 520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */, > 0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */, >+ 33BE5AFA137B5A2300705813 /* WebWorker.cpp */, >+ 33BE5AFB137B5A2400705813 /* WebWorker_Bundle.cpp */, > 7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */, > 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */, > 76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */, >@@ -897,6 +915,10 @@ > BCAA485514A021640088FAC4 /* simple-tall.html */, > BC909778125571AB00083756 /* simple.html */, > C02B7882126615410026BF0F /* spacebar-scrolling.html */, >+ 33BE4BEC137B512700614713 /* webWorkerSharedTest.html */, >+ 33BE4BEC137B512800614713 /* webWorkerSharedTest.js */, >+ 33BE4BEC137B512B00614713 /* webWorkerTest.html */, >+ 33BE4BEC137B512C00614713 /* webWorkerTest.js */, > ); > name = Resources; > sourceTree = "<group>"; >@@ -1277,6 +1299,7 @@ > C08587BF13FE956C001EF4E5 /* WebKitAgnosticTest.mm in Sources */, > 51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */, > 37E38C34169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */, >+ 33BE5AFA137B5A2100705813 /* WebWorker.cpp in Sources */, > 76E182DA1547550100F1FADD /* WillSendSubmitEvent.cpp in Sources */, > A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */, > F6B7BE9417469209008A3445 /* DidAssociateFormControls.cpp in Sources */, >@@ -1329,6 +1352,7 @@ > 51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */, > BC22D31914DC68B900FFB1DD /* UserMessage_Bundle.cpp in Sources */, > 520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */, >+ 33BE5AFB137B5A2200705813 /* WebWorker_Bundle.cpp in Sources */, > 76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */, > 1A9E32941821945C00F5D04C /* WKRemoteObjectRegistry_Bundle.mm in Sources */, > BC901E331492AF390074A667 /* WKConnection_Bundle.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..4bd7edf2a4a1dfb10055c476f214ad208377395e >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker.cpp >@@ -0,0 +1,101 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#include "PlatformUtilities.h" >+#include "PlatformWebView.h" >+#include <WebKit2/WKContext.h> >+#include <WebKit2/WKPage.h> >+#include <WebKit2/WKPreferencesPrivate.h> >+ >+namespace TestWebKitAPI { >+ >+static bool initialized = false; >+static bool terminated = false; >+static bool changedTitle = false; >+static bool initializedShared = false; >+static bool terminatedShared = false; >+static bool changedTitleShared = false; >+ >+static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef, const void*) >+{ >+ if (WKStringIsEqualToUTF8CString(messageName, "WebWorkerInitMessage")) >+ initialized = true; >+ else if (WKStringIsEqualToUTF8CString(messageName, "WebWorkerTerminateMessage")) >+ terminated = true; >+ else if (WKStringIsEqualToUTF8CString(messageName, "WebWorkerSharedInitMessage")) >+ initializedShared = true; >+ else if (WKStringIsEqualToUTF8CString(messageName, "WebWorkerSharedTerminateMessage")) >+ terminatedShared = true; >+} >+ >+static void didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef, WKTypeRef, const void *) >+{ >+ if (WKStringIsEqualToUTF8CString(title, "WebWorkerTitle")) >+ changedTitle = true; >+ else if (WKStringIsEqualToUTF8CString(title, "WebWorkerSharedTitle")) >+ changedTitleShared = true; >+} >+ >+TEST(WebKit2, WebWorker) >+{ >+ // This test cover the binding between functions of JavaScript Workers and >+ // functions defined at a previously loaded bundle. It verifies the two >+ // types of Workers, dedicated and shared. >+ WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("WebWorkerTest")); >+ >+ WKContextInjectedBundleClient injectedBundleClient; >+ memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); >+ injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; >+ WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient); >+ >+ PlatformWebView webView(context.get()); >+ >+ WKPageLoaderClient pageLoaderClient; >+ memset(&pageLoaderClient, 0, sizeof(WKPageLoaderClient)); >+ pageLoaderClient.version = kWKPageLoaderClientCurrentVersion; >+ pageLoaderClient.didReceiveTitleForFrame = didReceiveTitleForFrame; >+ WKPageSetPageLoaderClient(webView.page(), &pageLoaderClient); >+ >+ WKPageGroupRef pageGroup = WKPageGetPageGroup(webView.page()); >+ WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup); >+ WKPreferencesSetFileAccessFromFileURLsAllowed(preferences, true); >+ >+ WKRetainPtr<WKURLRef> url = adoptWK(Util::createURLForResource("webWorkerTest", "html")); >+ WKPageLoadURL(webView.page(), url.get()); >+ >+ Util::run(&initialized); >+ Util::run(&terminated); >+ Util::run(&changedTitle); >+ >+ url = adoptWK(Util::createURLForResource("webWorkerSharedTest", "html")); >+ WKPageLoadURL(webView.page(), url.get()); >+ Util::run(&initializedShared); >+ Util::run(&terminatedShared); >+ Util::run(&changedTitleShared); >+} >+ >+} // TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..b3ab5b2ddf8e73c13417b97aec0ff08b6429b66c >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp >@@ -0,0 +1,85 @@ >+/* >+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "PlatformUtilities.h" >+#include "InjectedBundleTest.h" >+#include <WebKit2/WKBundleFrame.h> >+#include <cstdio> >+ >+namespace TestWebKitAPI { >+ >+JSValueRef foo(JSContextRef ctx, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef*) >+{ >+ WKBundlePostMessage(InjectedBundleController::shared().bundle(), Util::toWK("WebWorkerInitMessage").get(), 0); >+ return JSValueMakeString(ctx, JSStringCreateWithUTF8CString("WebWorkerTitle")); >+} >+ >+JSValueRef bar(JSContextRef ctx, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef*) >+{ >+ WKBundlePostMessage(InjectedBundleController::shared().bundle(), Util::toWK("WebWorkerSharedInitMessage").get(), 0); >+ return JSValueMakeString(ctx, JSStringCreateWithUTF8CString("WebWorkerSharedTitle")); >+} >+ >+void webWorkerInitialize(JSContextRef context, int isDedicated) >+{ >+ if (isDedicated) { >+ JSStringRef funcName = JSStringCreateWithUTF8CString("foo"); >+ JSObjectRef jsFunc = JSObjectMakeFunctionWithCallback(context, funcName, &foo); >+ JSObjectSetProperty(context, JSContextGetGlobalObject(context), funcName, jsFunc, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0); >+ JSStringRelease(funcName); >+ } else { >+ JSStringRef funcName = JSStringCreateWithUTF8CString("bar"); >+ JSObjectRef jsFunc = JSObjectMakeFunctionWithCallback(context, funcName, &bar); >+ JSObjectSetProperty(context, JSContextGetGlobalObject(context), funcName, jsFunc, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0); >+ JSStringRelease(funcName); >+ } >+} >+ >+void webWorkerTerminate(JSContextRef context, int isDedicated) >+{ >+ if (isDedicated) >+ WKBundlePostMessage(InjectedBundleController::shared().bundle(), Util::toWK("WebWorkerTerminateMessage").get(), 0); >+ else >+ WKBundlePostMessage(InjectedBundleController::shared().bundle(), Util::toWK("WebWorkerSharedTerminateMessage").get(), 0); >+} >+ >+class WebWorkerTest : public InjectedBundleTest { >+public: >+ explicit WebWorkerTest(const std::string& identifier) >+ : InjectedBundleTest(identifier) >+ { >+ } >+ >+ virtual void initialize(WKBundleRef, WKTypeRef) >+ { >+ WKBundleFrameSetWorkerInitializeCallback(webWorkerInitialize); >+ WKBundleFrameSetWorkerTerminateCallback(webWorkerTerminate); >+ } >+}; >+ >+static InjectedBundleTest::Register<WebWorkerTest> registrar("WebWorkerTest"); >+ >+} // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.html b/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9aa6962e7ee6018d7cea391b4e9413148e9de50a >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.html >@@ -0,0 +1,12 @@ >+<html> >+ <body> >+ <script> >+ var worker = new SharedWorker("webWorkerSharedTest.js"); >+ worker.port.addEventListener("message", function(event) { >+ document.title = event.data; >+ }, false); >+ worker.port.start(); >+ worker.port.postMessage("WebWorkerSharedMessage"); >+ </script> >+ </body> >+</html> >diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.js b/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.js >new file mode 100644 >index 0000000000000000000000000000000000000000..984baf6773b6a4fe8dbdbc78ded1a8e7dc1beea4 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.js >@@ -0,0 +1,13 @@ >+var ports = []; >+ >+onconnect = function(event) { >+ var port = event.ports[0]; >+ ports.push(port); >+ port.start(); >+ port.addEventListener("message", function(event) { listenForMessage(event, port); } ); >+} >+ >+listenForMessage = function (event, port) { >+ port.postMessage(self.bar()); >+ self.close(); >+} >diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.html b/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.html >new file mode 100644 >index 0000000000000000000000000000000000000000..b2a7b82bd13cb10a26067463393c254f5df0f48f >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.html >@@ -0,0 +1,11 @@ >+<html> >+ <body> >+ <script> >+ var worker = new Worker("webWorkerTest.js"); >+ worker.postMessage("WebWorkerMessage"); >+ worker.onmessage = function(event) { >+ document.title = event.data; >+ }; >+ </script> >+ </body> >+</html> >diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.js b/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.js >new file mode 100644 >index 0000000000000000000000000000000000000000..7685bb55c22154e107f34b525258517240491328 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.js >@@ -0,0 +1,5 @@ >+self.onmessage = function(event) { >+ self.postMessage(self.foo()); >+ self.close(); >+ return; >+};
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
sam
:
review-
buildbot
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 117523
:
204363
|
204364
|
204638
|
205214
|
206940
|
218024
| 218029