| Differences between
and this patch
- a/Source/WebCore/ChangeLog +20 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2013-11-28  Tullio Lucena  <tullio.lucena@openbossa.org>
2
3
        [WK2] Proof of concept to inject custom JavaScript objects on WebWorker context.
4
        https://bugs.webkit.org/show_bug.cgi?id=117523
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Callbacks were added for initialize and terminate WebWorkers using WK2 API.
9
        These callbacks handle bindings between functions of JavaScript Workers and functions defined at a previously loaded bundle.
10
        An API test was added to check the these callbacks. It verifies the two types of workers, dedicated and shared.
11
12
        * bindings/js/WorkerScriptController.cpp:
13
        (WebCore::WorkerScriptController::~WorkerScriptController):
14
        (WebCore::WorkerScriptController::initScript):
15
        (WebCore::WorkerScriptController::setInitScriptCallback):
16
        (WebCore::WorkerScriptController::initScriptCallback):
17
        (WebCore::WorkerScriptController::setTerminateScriptCallback):
18
        (WebCore::WorkerScriptController::terminateScriptCallback):
19
        * bindings/js/WorkerScriptController.h:
20
1
2013-11-28  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
21
2013-11-28  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
2
22
3
        Rename InlineIterator::m_obj and make it private
23
        Rename InlineIterator::m_obj and make it private
- a/Source/WebKit2/ChangeLog +18 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2013-11-28  Tullio Lucena  <tullio.lucena@openbossa.org>
2
3
        [WK2] Proof of concept to inject custom JavaScript objects on WebWorker context.
4
        https://bugs.webkit.org/show_bug.cgi?id=117523
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Callbacks were added for initialize and terminate WebWorkers using WK2 API.
9
        These callbacks handle bindings between functions of JavaScript Workers and functions defined at a previously loaded bundle.
10
        An API test was added to check the these callbacks. It verifies the two types of workers, dedicated and shared.
11
12
        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
13
        (localWorkerScriptInitCallback):
14
        (WKBundleFrameSetWorkerInitializeCallback):
15
        (localWorkerScriptTerminateCallback):
16
        (WKBundleFrameSetWorkerTerminateCallback):
17
        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
18
1
2013-11-28  Nick Diego Yamane  <nick.yamane@openbossa.org>
19
2013-11-28  Nick Diego Yamane  <nick.yamane@openbossa.org>
2
20
3
        [GTK] Build fix after r159859
21
        [GTK] Build fix after r159859
- a/Source/WebCore/bindings/js/WorkerScriptController.cpp +29 lines
Lines 63-68 WorkerScriptController::WorkerScriptController(WorkerGlobalScope* workerGlobalSc a/Source/WebCore/bindings/js/WorkerScriptController.cpp_sec1
63
63
64
WorkerScriptController::~WorkerScriptController()
64
WorkerScriptController::~WorkerScriptController()
65
{
65
{
66
    if (terminateScriptCallback())
67
        terminateScriptCallback()(m_workerGlobalScopeWrapper->globalExec(), m_workerGlobalScope->isDedicatedWorkerGlobalScope());
68
66
    JSLockHolder lock(vm());
69
    JSLockHolder lock(vm());
67
    m_workerGlobalScopeWrapper.clear();
70
    m_workerGlobalScopeWrapper.clear();
68
    m_vm.clear();
71
    m_vm.clear();
Lines 106-111 void WorkerScriptController::initScript() a/Source/WebCore/bindings/js/WorkerScriptController.cpp_sec2
106
    }
109
    }
107
    ASSERT(m_workerGlobalScopeWrapper->globalObject() == m_workerGlobalScopeWrapper);
110
    ASSERT(m_workerGlobalScopeWrapper->globalObject() == m_workerGlobalScopeWrapper);
108
    ASSERT(asObject(m_workerGlobalScopeWrapper->prototype())->globalObject() == m_workerGlobalScopeWrapper);
111
    ASSERT(asObject(m_workerGlobalScopeWrapper->prototype())->globalObject() == m_workerGlobalScopeWrapper);
112
113
    if (initScriptCallback())
114
        initScriptCallback()(m_workerGlobalScopeWrapper->globalExec(), m_workerGlobalScope->isDedicatedWorkerGlobalScope());
109
}
115
}
110
116
111
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
117
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
Lines 203-206 void WorkerScriptController::detachDebugger(JSC::Debugger* debugger) a/Source/WebCore/bindings/js/WorkerScriptController.cpp_sec3
203
    debugger->detach(m_workerGlobalScopeWrapper->globalObject());
209
    debugger->detach(m_workerGlobalScopeWrapper->globalObject());
204
}
210
}
205
211
212
WorkerScriptCallback WorkerScriptController::m_initScriptCallback = 0;
213
WorkerScriptCallback WorkerScriptController::m_terminateScriptCallback = 0;
214
215
void WorkerScriptController::setInitScriptCallback(WorkerScriptCallback callback)
216
{
217
    m_initScriptCallback = callback;
218
}
219
220
WorkerScriptCallback WorkerScriptController::initScriptCallback()
221
{
222
    return m_initScriptCallback;
223
}
224
225
void WorkerScriptController::setTerminateScriptCallback(WorkerScriptCallback callback)
226
{
227
    m_terminateScriptCallback = callback;
228
}
229
230
WorkerScriptCallback WorkerScriptController::terminateScriptCallback()
231
{
232
    return m_terminateScriptCallback;
233
}
234
206
} // namespace WebCore
235
} // namespace WebCore
- a/Source/WebCore/bindings/js/WorkerScriptController.h +9 lines
Lines 39-44 namespace JSC { a/Source/WebCore/bindings/js/WorkerScriptController.h_sec1
39
39
40
namespace WebCore {
40
namespace WebCore {
41
41
42
    typedef void (*WorkerScriptCallback)(JSC::ExecState*, bool);
43
42
    class JSWorkerGlobalScope;
44
    class JSWorkerGlobalScope;
43
    class ScriptSourceCode;
45
    class ScriptSourceCode;
44
    class ScriptValue;
46
    class ScriptValue;
Lines 81-86 namespace WebCore { a/Source/WebCore/bindings/js/WorkerScriptController.h_sec2
81
        void attachDebugger(JSC::Debugger*);
83
        void attachDebugger(JSC::Debugger*);
82
        void detachDebugger(JSC::Debugger*);
84
        void detachDebugger(JSC::Debugger*);
83
85
86
        static void setInitScriptCallback(WorkerScriptCallback);
87
        static WorkerScriptCallback initScriptCallback();
88
        static void setTerminateScriptCallback(WorkerScriptCallback);
89
        static WorkerScriptCallback terminateScriptCallback();
84
    private:
90
    private:
85
        void initScriptIfNeeded()
91
        void initScriptIfNeeded()
86
        {
92
        {
Lines 94-99 namespace WebCore { a/Source/WebCore/bindings/js/WorkerScriptController.h_sec3
94
        JSC::Strong<JSWorkerGlobalScope> m_workerGlobalScopeWrapper;
100
        JSC::Strong<JSWorkerGlobalScope> m_workerGlobalScopeWrapper;
95
        bool m_executionForbidden;
101
        bool m_executionForbidden;
96
        mutable Mutex m_scheduledTerminationMutex;
102
        mutable Mutex m_scheduledTerminationMutex;
103
104
        static WorkerScriptCallback m_initScriptCallback;
105
        static WorkerScriptCallback m_terminateScriptCallback;
97
    };
106
    };
98
107
99
} // namespace WebCore
108
} // namespace WebCore
- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +35 lines
Lines 29-34 a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp_sec1
29
29
30
#include "APIArray.h"
30
#include "APIArray.h"
31
#include "InjectedBundleHitTestResult.h"
31
#include "InjectedBundleHitTestResult.h"
32
#include "JavaScriptCore/APICast.h"
32
#include "WKAPICast.h"
33
#include "WKAPICast.h"
33
#include "WKBundleAPICast.h"
34
#include "WKBundleAPICast.h"
34
#include "WKData.h"
35
#include "WKData.h"
Lines 38-43 a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp_sec2
38
#include <WebCore/Frame.h>
39
#include <WebCore/Frame.h>
39
#include <WebCore/FrameLoader.h>
40
#include <WebCore/FrameLoader.h>
40
#include <WebCore/FrameView.h>
41
#include <WebCore/FrameView.h>
42
#include <WebCore/WorkerScriptController.h>
43
41
44
42
using namespace WebCore;
45
using namespace WebCore;
43
using namespace WebKit;
46
using namespace WebKit;
Lines 106-111 JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef fr a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp_sec3
106
    return toImpl(frameRef)->jsContextForWorld(toImpl(worldRef));
109
    return toImpl(frameRef)->jsContextForWorld(toImpl(worldRef));
107
}
110
}
108
111
112
static WKBundleFrameWorkerScriptCallback s_localWorkerScriptInitCallback;
113
114
static void localWorkerScriptInitCallback(JSC::ExecState* execState, bool isDedicated)
115
{
116
    s_localWorkerScriptInitCallback(toRef(execState), isDedicated);
117
}
118
119
void WKBundleFrameSetWorkerInitializeCallback(WKBundleFrameWorkerScriptCallback callback)
120
{
121
    if (callback) {
122
        s_localWorkerScriptInitCallback = callback;
123
        WorkerScriptController::setInitScriptCallback(localWorkerScriptInitCallback);
124
    } else
125
        WorkerScriptController::setInitScriptCallback(0);
126
}
127
128
static WKBundleFrameWorkerScriptCallback s_localWorkerScriptTerminateCallback;
129
130
static void localWorkerScriptTerminateCallback(JSC::ExecState* execState, bool isDedicated)
131
{
132
    s_localWorkerScriptTerminateCallback(toRef(execState), isDedicated);
133
}
134
135
void WKBundleFrameSetWorkerTerminateCallback(WKBundleFrameWorkerScriptCallback callback)
136
{
137
    if (callback) {
138
        s_localWorkerScriptTerminateCallback = callback;
139
        WorkerScriptController::setTerminateScriptCallback(localWorkerScriptTerminateCallback);
140
    } else
141
        WorkerScriptController::setTerminateScriptCallback(0);
142
}
143
109
JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frameRef, WKBundleNodeHandleRef nodeHandleRef, WKBundleScriptWorldRef worldRef)
144
JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frameRef, WKBundleNodeHandleRef nodeHandleRef, WKBundleScriptWorldRef worldRef)
110
{
145
{
111
    return toImpl(frameRef)->jsWrapperForWorld(toImpl(nodeHandleRef), toImpl(worldRef));
146
    return toImpl(frameRef)->jsWrapperForWorld(toImpl(nodeHandleRef), toImpl(worldRef));
- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h +4 lines
Lines 51-56 WK_EXPORT WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frame a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h_sec1
51
WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame);
51
WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame);
52
WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frame, WKBundleScriptWorldRef world);
52
WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frame, WKBundleScriptWorldRef world);
53
53
54
typedef void (*WKBundleFrameWorkerScriptCallback)(JSContextRef context, int isDedicated);
55
WK_EXPORT void WKBundleFrameSetWorkerInitializeCallback(WKBundleFrameWorkerScriptCallback callback);
56
WK_EXPORT void WKBundleFrameSetWorkerTerminateCallback(WKBundleFrameWorkerScriptCallback callback);
57
54
WK_EXPORT WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef context);
58
WK_EXPORT WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef context);
55
59
56
WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world);
60
WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world);
- a/Tools/ChangeLog +34 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2013-11-28  Tullio Lucena  <tullio.lucena@openbossa.org>
2
3
        [WK2] Proof of concept to inject custom JavaScript objects on WebWorker context.
4
        https://bugs.webkit.org/show_bug.cgi?id=117523
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Callbacks were added for initialize and terminate WebWorkers using WK2 API.
9
        These callbacks handle bindings between functions of JavaScript Workers and functions defined at a previously loaded bundle.
10
        An API test was added to check the these callbacks. It verifies the two types of workers, dedicated and shared.
11
12
        * TestWebKitAPI/CMakeLists.txt:
13
        * TestWebKitAPI/GNUmakefile.am:
14
        * TestWebKitAPI/PlatformEfl.cmake:
15
        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
16
        * TestWebKitAPI/Tests/WebKit2/WebWorker.cpp: Added.
17
        (TestWebKitAPI::didReceiveMessageFromInjectedBundle):
18
        (TestWebKitAPI::didReceiveTitleForFrame):
19
        (TestWebKitAPI::TEST):
20
        * TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp: Added.
21
        (TestWebKitAPI::foo):
22
        (TestWebKitAPI::bar):
23
        (TestWebKitAPI::webWorkerInitialize):
24
        (TestWebKitAPI::webWorkerTerminate):
25
        (TestWebKitAPI::WebWorkerTest::WebWorkerTest):
26
        (TestWebKitAPI::WebWorkerTest::initialize):
27
        * TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.html: Added.
28
        * TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.js: Added.
29
        (onconnect):
30
        (listenForMessage):
31
        * TestWebKitAPI/Tests/WebKit2/webWorkerTest.html: Added.
32
        * TestWebKitAPI/Tests/WebKit2/webWorkerTest.js: Added.
33
        (self.onmessage):
34
1
2013-11-28  Commit Queue  <commit-queue@webkit.org>
35
2013-11-28  Commit Queue  <commit-queue@webkit.org>
2
36
3
        Unreviewed, rolling out r159839.
37
        Unreviewed, rolling out r159839.
- a/Tools/TestWebKitAPI/CMakeLists.txt +2 lines
Lines 10-15 include_directories(${CMAKE_BINARY_DIR} a/Tools/TestWebKitAPI/CMakeLists.txt_sec1
10
    ${JAVASCRIPTCORE_DIR}/API
10
    ${JAVASCRIPTCORE_DIR}/API
11
    ${JAVASCRIPTCORE_DIR}/ForwardingHeaders
11
    ${JAVASCRIPTCORE_DIR}/ForwardingHeaders
12
    ${THIRDPARTY_DIR}/gtest/include
12
    ${THIRDPARTY_DIR}/gtest/include
13
    ${WEBCORE_DIR}/bindings/js
13
    ${WEBCORE_DIR}/editing
14
    ${WEBCORE_DIR}/editing
14
    ${WEBCORE_DIR}/platform
15
    ${WEBCORE_DIR}/platform
15
    ${WEBCORE_DIR}/platform/graphics
16
    ${WEBCORE_DIR}/platform/graphics
Lines 76-81 add_library(TestWebKitAPIInjectedBundle SHARED a/Tools/TestWebKitAPI/CMakeLists.txt_sec2
76
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp
77
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp
77
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage_Bundle.cpp
78
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage_Bundle.cpp
78
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKConnection_Bundle.cpp
79
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKConnection_Bundle.cpp
80
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WebWorker_Bundle.cpp
79
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillLoad_Bundle.cpp
81
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillLoad_Bundle.cpp
80
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp
82
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp
81
)
83
)
- a/Tools/TestWebKitAPI/GNUmakefile.am +2 lines
Lines 293-298 Programs_TestWebKitAPI_TestWebKit2_SOURCES = \ a/Tools/TestWebKitAPI/GNUmakefile.am_sec1
293
	Tools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp \
293
	Tools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp \
294
	Tools/TestWebKitAPI/Tests/WebKit2/TerminateTwice.cpp \
294
	Tools/TestWebKitAPI/Tests/WebKit2/TerminateTwice.cpp \
295
	Tools/TestWebKitAPI/Tests/WebKit2/UserMessage.cpp \
295
	Tools/TestWebKitAPI/Tests/WebKit2/UserMessage.cpp \
296
	Tools/TestWebKitAPI/Tests/WebKit2/WebWorker.cpp \
296
	Tools/TestWebKitAPI/Tests/WebKit2/WillLoad.cpp \
297
	Tools/TestWebKitAPI/Tests/WebKit2/WillLoad.cpp \
297
	Tools/TestWebKitAPI/Tests/WebKit2/WillSendSubmitEvent.cpp \
298
	Tools/TestWebKitAPI/Tests/WebKit2/WillSendSubmitEvent.cpp \
298
	Tools/TestWebKitAPI/Tests/WebKit2/WKConnection.cpp \
299
	Tools/TestWebKitAPI/Tests/WebKit2/WKConnection.cpp \
Lines 334-339 Libraries_libTestWebKitAPIInjectedBundle_la_SOURCES = \ a/Tools/TestWebKitAPI/GNUmakefile.am_sec2
334
	Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp \
335
	Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp \
335
	Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp \
336
	Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp \
336
	Tools/TestWebKitAPI/Tests/WebKit2/UserMessage_Bundle.cpp \
337
	Tools/TestWebKitAPI/Tests/WebKit2/UserMessage_Bundle.cpp \
338
	Tools/TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp \
337
	Tools/TestWebKitAPI/Tests/WebKit2/WillLoad_Bundle.cpp \
339
	Tools/TestWebKitAPI/Tests/WebKit2/WillLoad_Bundle.cpp \
338
	Tools/TestWebKitAPI/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp \
340
	Tools/TestWebKitAPI/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp \
339
	Tools/TestWebKitAPI/Tests/WebKit2/WKConnection_Bundle.cpp \
341
	Tools/TestWebKitAPI/Tests/WebKit2/WKConnection_Bundle.cpp \
- a/Tools/TestWebKitAPI/PlatformEfl.cmake +2 lines
Lines 54-59 set(test_webcore_BINARIES a/Tools/TestWebKitAPI/PlatformEfl.cmake_sec1
54
54
55
# In here we list the bundles that are used by our specific WK2 API Tests
55
# In here we list the bundles that are used by our specific WK2 API Tests
56
list(APPEND bundle_harness_SOURCES
56
list(APPEND bundle_harness_SOURCES
57
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WebWorker_Bundle.cpp
57
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive_Bundle.cpp
58
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive_Bundle.cpp
58
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp
59
    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp
59
)
60
)
Lines 101-106 set(test_webkit2_api_BINARIES a/Tools/TestWebKitAPI/PlatformEfl.cmake_sec2
101
    WKString
102
    WKString
102
    WKStringJSString
103
    WKStringJSString
103
    WKURL
104
    WKURL
105
    WebWorker
104
    WillLoad
106
    WillLoad
105
    WillSendSubmitEvent
107
    WillSendSubmitEvent
106
    CoordinatedGraphics/WKViewIsActiveSetIsActive
108
    CoordinatedGraphics/WKViewIsActiveSetIsActive
- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj +24 lines
Lines 66-71 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec1
66
		333B9CE21277F23100FEFCE3 /* PreventEmptyUserAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */; };
66
		333B9CE21277F23100FEFCE3 /* PreventEmptyUserAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */; };
67
		33BE5AF5137B5A6C00705813 /* MouseMoveAfterCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */; };
67
		33BE5AF5137B5A6C00705813 /* MouseMoveAfterCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */; };
68
		33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
68
		33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
69
		33BE5AFA137B5A2100705813 /* WebWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AFA137B5A2300705813 /* WebWorker.cpp */; };
70
		33BE5AFB137B5A2200705813 /* WebWorker_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AFB137B5A2400705813 /* WebWorker_Bundle.cpp */; };
71
		33BE4BE137B54B2500614713 /* webWorkerSharedTest.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33BE4BEC137B512700614713 /* webWorkerSharedTest.html */; };
72
		33BE4BE137B54B2600614713 /* webWorkerSharedTest.js in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33BE4BEC137B512800614713 /* webWorkerSharedTest.js */; };
73
		33BE4BE137B54B2900614713 /* webWorkerTest.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33BE4BEC137B512B00614713 /* webWorkerTest.html */; };
74
		33BE4BE137B54B2A00614713 /* webWorkerTest.js in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33BE4BEC137B512C00614713 /* webWorkerTest.js */; };
69
		33DC8911141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */; };
75
		33DC8911141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */; };
70
		33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; };
76
		33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; };
71
		33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
77
		33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
Lines 324-329 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec2
324
				C01A23F21266156700C9ED55 /* spacebar-scrolling.html in Copy Resources */,
330
				C01A23F21266156700C9ED55 /* spacebar-scrolling.html in Copy Resources */,
325
				E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */,
331
				E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */,
326
				C540F784152E5A9A00A40C8C /* verboseMarkup.html in Copy Resources */,
332
				C540F784152E5A9A00A40C8C /* verboseMarkup.html in Copy Resources */,
333
				33BE4BE137B54B2500614713 /* webWorkerSharedTest.html in Copy Resources */,
334
				33BE4BE137B54B2600614713 /* webWorkerSharedTest.js in Copy Resources */,
335
				33BE4BE137B54B2900614713 /* webWorkerTest.html in Copy Resources */,
336
				33BE4BE137B54B2A00614713 /* webWorkerTest.js in Copy Resources */,
327
				A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */,
337
				A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */,
328
			);
338
			);
329
			name = "Copy Resources";
339
			name = "Copy Resources";
Lines 392-397 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec3
392
		333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
402
		333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
393
		33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash.cpp; sourceTree = "<group>"; };
403
		33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash.cpp; sourceTree = "<group>"; };
394
		33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash_Bundle.cpp; sourceTree = "<group>"; };
404
		33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash_Bundle.cpp; sourceTree = "<group>"; };
405
		33BE5AFA137B5A2300705813 /* WebWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebWorker.cpp; sourceTree = "<group>"; };
406
		33BE5AFB137B5A2400705813 /* WebWorker_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebWorker_Bundle.cpp; sourceTree = "<group>"; };
407
		33BE4BEC137B512700614713 /* webWorkerSharedTest.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "webWorkerSharedTest.html"; sourceTree = "<group>"; };
408
		33BE4BEC137B512800614713 /* webWorkerSharedTest.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "webWorkerSharedTest.js"; sourceTree = "<group>"; };
409
		33BE4BEC137B512B00614713 /* webWorkerTest.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "webWorkerTest.html"; sourceTree = "<group>"; };
410
		33BE4BEC137B512C00614713 /* webWorkerTest.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "webWorkerTest.js"; sourceTree = "<group>"; };
395
		33DC890E1419539300747EF7 /* simple-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-iframe.html"; sourceTree = "<group>"; };
411
		33DC890E1419539300747EF7 /* simple-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-iframe.html"; sourceTree = "<group>"; };
396
		33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCanceledNoServerRedirectCallback.cpp; sourceTree = "<group>"; };
412
		33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCanceledNoServerRedirectCallback.cpp; sourceTree = "<group>"; };
397
		33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCanceledNoServerRedirectCallback_Bundle.cpp; sourceTree = "<group>"; };
413
		33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCanceledNoServerRedirectCallback_Bundle.cpp; sourceTree = "<group>"; };
Lines 817-822 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec4
817
				520BCF4B141EB09E00937EA8 /* WebArchive.cpp */,
833
				520BCF4B141EB09E00937EA8 /* WebArchive.cpp */,
818
				520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */,
834
				520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */,
819
				0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */,
835
				0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */,
836
				33BE5AFA137B5A2300705813 /* WebWorker.cpp */,
837
				33BE5AFB137B5A2400705813 /* WebWorker_Bundle.cpp */,
820
				7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */,
838
				7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */,
821
				7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */,
839
				7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */,
822
				76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */,
840
				76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */,
Lines 897-902 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec5
897
				BCAA485514A021640088FAC4 /* simple-tall.html */,
915
				BCAA485514A021640088FAC4 /* simple-tall.html */,
898
				BC909778125571AB00083756 /* simple.html */,
916
				BC909778125571AB00083756 /* simple.html */,
899
				C02B7882126615410026BF0F /* spacebar-scrolling.html */,
917
				C02B7882126615410026BF0F /* spacebar-scrolling.html */,
918
				33BE4BEC137B512700614713 /* webWorkerSharedTest.html */,
919
				33BE4BEC137B512800614713 /* webWorkerSharedTest.js */,
920
				33BE4BEC137B512B00614713 /* webWorkerTest.html */,
921
				33BE4BEC137B512C00614713 /* webWorkerTest.js */,
900
			);
922
			);
901
			name = Resources;
923
			name = Resources;
902
			sourceTree = "<group>";
924
			sourceTree = "<group>";
Lines 1277-1282 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec6
1277
				C08587BF13FE956C001EF4E5 /* WebKitAgnosticTest.mm in Sources */,
1299
				C08587BF13FE956C001EF4E5 /* WebKitAgnosticTest.mm in Sources */,
1278
				51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */,
1300
				51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */,
1279
				37E38C34169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */,
1301
				37E38C34169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */,
1302
				33BE5AFA137B5A2100705813 /* WebWorker.cpp in Sources */,
1280
				76E182DA1547550100F1FADD /* WillSendSubmitEvent.cpp in Sources */,
1303
				76E182DA1547550100F1FADD /* WillSendSubmitEvent.cpp in Sources */,
1281
				A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */,
1304
				A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */,
1282
				F6B7BE9417469209008A3445 /* DidAssociateFormControls.cpp in Sources */,
1305
				F6B7BE9417469209008A3445 /* DidAssociateFormControls.cpp in Sources */,
Lines 1329-1334 a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj_sec7
1329
				51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */,
1352
				51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */,
1330
				BC22D31914DC68B900FFB1DD /* UserMessage_Bundle.cpp in Sources */,
1353
				BC22D31914DC68B900FFB1DD /* UserMessage_Bundle.cpp in Sources */,
1331
				520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */,
1354
				520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */,
1355
				33BE5AFB137B5A2200705813 /* WebWorker_Bundle.cpp in Sources */,
1332
				76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */,
1356
				76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */,
1333
				1A9E32941821945C00F5D04C /* WKRemoteObjectRegistry_Bundle.mm in Sources */,
1357
				1A9E32941821945C00F5D04C /* WKRemoteObjectRegistry_Bundle.mm in Sources */,
1334
				BC901E331492AF390074A667 /* WKConnection_Bundle.cpp in Sources */,
1358
				BC901E331492AF390074A667 /* WKConnection_Bundle.cpp in Sources */,
- a/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker.cpp +101 lines
Line 0 a/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker.cpp_sec1
1
/*
2
 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
28
#include "PlatformUtilities.h"
29
#include "PlatformWebView.h"
30
#include <WebKit2/WKContext.h>
31
#include <WebKit2/WKPage.h>
32
#include <WebKit2/WKPreferencesPrivate.h>
33
34
namespace TestWebKitAPI {
35
36
static bool initialized = false;
37
static bool terminated = false;
38
static bool changedTitle = false;
39
static bool initializedShared = false;
40
static bool terminatedShared = false;
41
static bool changedTitleShared = false;
42
43
static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef, const void*)
44
{
45
    if (WKStringIsEqualToUTF8CString(messageName, "WebWorkerInitMessage"))
46
        initialized = true;
47
    else if (WKStringIsEqualToUTF8CString(messageName, "WebWorkerTerminateMessage"))
48
        terminated = true;
49
    else if (WKStringIsEqualToUTF8CString(messageName, "WebWorkerSharedInitMessage"))
50
        initializedShared = true;
51
    else if (WKStringIsEqualToUTF8CString(messageName, "WebWorkerSharedTerminateMessage"))
52
        terminatedShared = true;
53
}
54
55
static void didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef, WKTypeRef, const void *)
56
{
57
    if (WKStringIsEqualToUTF8CString(title, "WebWorkerTitle"))
58
        changedTitle = true;
59
    else if (WKStringIsEqualToUTF8CString(title, "WebWorkerSharedTitle"))
60
        changedTitleShared = true;
61
}
62
63
TEST(WebKit2, WebWorker)
64
{
65
    // This test cover the binding between functions of JavaScript Workers and
66
    // functions defined at a previously loaded bundle. It verifies the two
67
    // types of Workers, dedicated and shared.
68
    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("WebWorkerTest"));
69
70
    WKContextInjectedBundleClient injectedBundleClient;
71
    memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
72
    injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle;
73
    WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient);
74
75
    PlatformWebView webView(context.get());
76
77
    WKPageLoaderClient pageLoaderClient;
78
    memset(&pageLoaderClient, 0, sizeof(WKPageLoaderClient));
79
    pageLoaderClient.version = kWKPageLoaderClientCurrentVersion;
80
    pageLoaderClient.didReceiveTitleForFrame = didReceiveTitleForFrame;
81
    WKPageSetPageLoaderClient(webView.page(), &pageLoaderClient);
82
83
    WKPageGroupRef pageGroup = WKPageGetPageGroup(webView.page());
84
    WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup);
85
    WKPreferencesSetFileAccessFromFileURLsAllowed(preferences, true);
86
87
    WKRetainPtr<WKURLRef> url = adoptWK(Util::createURLForResource("webWorkerTest", "html"));
88
    WKPageLoadURL(webView.page(), url.get());
89
90
    Util::run(&initialized);
91
    Util::run(&terminated);
92
    Util::run(&changedTitle);
93
94
    url = adoptWK(Util::createURLForResource("webWorkerSharedTest", "html"));
95
    WKPageLoadURL(webView.page(), url.get());
96
    Util::run(&initializedShared);
97
    Util::run(&terminatedShared);
98
    Util::run(&changedTitleShared);
99
}
100
101
} // TestWebKitAPI
- a/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp +85 lines
Line 0 a/Tools/TestWebKitAPI/Tests/WebKit2/WebWorker_Bundle.cpp_sec1
1
/*
2
 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "PlatformUtilities.h"
28
#include "InjectedBundleTest.h"
29
#include <WebKit2/WKBundleFrame.h>
30
#include <cstdio>
31
32
namespace TestWebKitAPI {
33
34
JSValueRef foo(JSContextRef ctx, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef*)
35
{
36
    WKBundlePostMessage(InjectedBundleController::shared().bundle(), Util::toWK("WebWorkerInitMessage").get(), 0);
37
    return JSValueMakeString(ctx, JSStringCreateWithUTF8CString("WebWorkerTitle"));
38
}
39
40
JSValueRef bar(JSContextRef ctx, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef*)
41
{
42
    WKBundlePostMessage(InjectedBundleController::shared().bundle(), Util::toWK("WebWorkerSharedInitMessage").get(), 0);
43
    return JSValueMakeString(ctx, JSStringCreateWithUTF8CString("WebWorkerSharedTitle"));
44
}
45
46
void webWorkerInitialize(JSContextRef context, int isDedicated)
47
{
48
    if (isDedicated) {
49
        JSStringRef funcName = JSStringCreateWithUTF8CString("foo");
50
        JSObjectRef jsFunc = JSObjectMakeFunctionWithCallback(context, funcName, &foo);
51
        JSObjectSetProperty(context, JSContextGetGlobalObject(context), funcName, jsFunc, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
52
        JSStringRelease(funcName);
53
    } else {
54
        JSStringRef funcName = JSStringCreateWithUTF8CString("bar");
55
        JSObjectRef jsFunc = JSObjectMakeFunctionWithCallback(context, funcName, &bar);
56
        JSObjectSetProperty(context, JSContextGetGlobalObject(context), funcName, jsFunc, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
57
        JSStringRelease(funcName);
58
    }
59
}
60
61
void webWorkerTerminate(JSContextRef context, int isDedicated)
62
{
63
    if (isDedicated)
64
        WKBundlePostMessage(InjectedBundleController::shared().bundle(), Util::toWK("WebWorkerTerminateMessage").get(), 0);
65
    else
66
        WKBundlePostMessage(InjectedBundleController::shared().bundle(), Util::toWK("WebWorkerSharedTerminateMessage").get(), 0);
67
}
68
69
class WebWorkerTest : public InjectedBundleTest {
70
public:
71
    explicit WebWorkerTest(const std::string& identifier)
72
        : InjectedBundleTest(identifier)
73
    {
74
    }
75
76
    virtual void initialize(WKBundleRef, WKTypeRef)
77
    {
78
        WKBundleFrameSetWorkerInitializeCallback(webWorkerInitialize);
79
        WKBundleFrameSetWorkerTerminateCallback(webWorkerTerminate);
80
    }
81
};
82
83
static InjectedBundleTest::Register<WebWorkerTest> registrar("WebWorkerTest");
84
85
} // namespace TestWebKitAPI
- a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.html +12 lines
Line 0 a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.html_sec1
1
<html>
2
    <body>
3
        <script>
4
            var worker = new SharedWorker("webWorkerSharedTest.js");
5
            worker.port.addEventListener("message", function(event) {
6
                document.title = event.data;
7
            }, false);
8
            worker.port.start();
9
            worker.port.postMessage("WebWorkerSharedMessage");
10
        </script>
11
    </body>
12
</html>
- a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.js +13 lines
Line 0 a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerSharedTest.js_sec1
1
var ports = [];
2
3
onconnect = function(event) {
4
    var port = event.ports[0];
5
    ports.push(port);
6
    port.start();
7
    port.addEventListener("message", function(event) { listenForMessage(event, port); } );
8
}
9
10
listenForMessage = function (event, port) {
11
    port.postMessage(self.bar());
12
    self.close();
13
}
- a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.html +11 lines
Line 0 a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.html_sec1
1
<html>
2
    <body>
3
        <script>
4
            var worker = new Worker("webWorkerTest.js");
5
            worker.postMessage("WebWorkerMessage");
6
            worker.onmessage = function(event) {
7
                document.title = event.data;
8
            };
9
        </script>
10
    </body>
11
</html>
- a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.js +5 lines
Line 0 a/Tools/TestWebKitAPI/Tests/WebKit2/webWorkerTest.js_sec1
1
self.onmessage = function(event) {
2
    self.postMessage(self.foo());
3
    self.close();
4
    return;
5
};

Return to Bug 117523