| Differences between
and this patch
- a/Source/WebCore/ChangeLog +15 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2020-02-06  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: show JavaScript Worker terminated state as an internal property
4
        https://bugs.webkit.org/show_bug.cgi?id=207347
5
6
        Reviewed by Brian Burg.
7
8
        Test: inspector/worker/worker-create-and-terminate.html
9
10
        * inspector/WebInjectedScriptHost.cpp:
11
        (WebCore::WebInjectedScriptHost::getInternalProperties):
12
13
        * workers/Worker.h:
14
        (WebCore::Worker::wasTerminated): Added.
15
1
2020-02-06  Commit Queue  <commit-queue@webkit.org>
16
2020-02-06  Commit Queue  <commit-queue@webkit.org>
2
17
3
        Unreviewed, rolling out r255910, r255970, and r255972.
18
        Unreviewed, rolling out r255910, r255970, and r255972.
- a/Source/WebCore/inspector/WebInjectedScriptHost.cpp -6 / +12 lines
Lines 32-37 a/Source/WebCore/inspector/WebInjectedScriptHost.cpp_sec1
32
#include "JSHTMLCollection.h"
32
#include "JSHTMLCollection.h"
33
#include "JSNode.h"
33
#include "JSNode.h"
34
#include "JSNodeList.h"
34
#include "JSNodeList.h"
35
#include "JSWorker.h"
36
#include "Worker.h"
35
37
36
#if ENABLE(PAYMENT_REQUEST)
38
#if ENABLE(PAYMENT_REQUEST)
37
#include "JSPaymentRequest.h"
39
#include "JSPaymentRequest.h"
Lines 59-65 JSValue WebInjectedScriptHost::subtype(JSGlobalObject* exec, JSValue value) a/Source/WebCore/inspector/WebInjectedScriptHost.cpp_sec2
59
    return jsUndefined();
61
    return jsUndefined();
60
}
62
}
61
63
62
#if ENABLE(PAYMENT_REQUEST)
63
static JSObject* constructInternalProperty(VM& vm, JSGlobalObject* exec, const String& name, JSValue value)
64
static JSObject* constructInternalProperty(VM& vm, JSGlobalObject* exec, const String& name, JSValue value)
64
{
65
{
65
    auto* object = constructEmptyObject(exec);
66
    auto* object = constructEmptyObject(exec);
Lines 68-73 static JSObject* constructInternalProperty(VM& vm, JSGlobalObject* exec, const S a/Source/WebCore/inspector/WebInjectedScriptHost.cpp_sec3
68
    return object;
69
    return object;
69
}
70
}
70
71
72
#if ENABLE(PAYMENT_REQUEST)
71
static JSObject* objectForPaymentOptions(VM& vm, JSGlobalObject* exec, const PaymentOptions& paymentOptions)
73
static JSObject* objectForPaymentOptions(VM& vm, JSGlobalObject* exec, const PaymentOptions& paymentOptions)
72
{
74
{
73
    auto* object = constructEmptyObject(exec);
75
    auto* object = constructEmptyObject(exec);
Lines 161-169 static JSString* jsStringForPaymentRequestState(VM& vm, PaymentRequest::State st a/Source/WebCore/inspector/WebInjectedScriptHost.cpp_sec4
161
163
162
JSValue WebInjectedScriptHost::getInternalProperties(VM& vm, JSGlobalObject* exec, JSC::JSValue value)
164
JSValue WebInjectedScriptHost::getInternalProperties(VM& vm, JSGlobalObject* exec, JSC::JSValue value)
163
{
165
{
164
#if ENABLE(PAYMENT_REQUEST)
165
    auto scope = DECLARE_THROW_SCOPE(vm);
166
    auto scope = DECLARE_THROW_SCOPE(vm);
166
167
168
    if (auto* worker = JSWorker::toWrapped(vm, value)) {
169
        unsigned index = 0;
170
        auto* array = constructEmptyArray(exec, nullptr);
171
        array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "terminated"_s, jsBoolean(worker->wasTerminated())));
172
        RETURN_IF_EXCEPTION(scope, { });
173
        return array;
174
    }
175
176
#if ENABLE(PAYMENT_REQUEST)
167
    if (PaymentRequest* paymentRequest = JSPaymentRequest::toWrapped(vm, value)) {
177
    if (PaymentRequest* paymentRequest = JSPaymentRequest::toWrapped(vm, value)) {
168
        unsigned index = 0;
178
        unsigned index = 0;
169
        auto* array = constructEmptyArray(exec, nullptr);
179
        auto* array = constructEmptyArray(exec, nullptr);
Lines 173-182 JSValue WebInjectedScriptHost::getInternalProperties(VM& vm, JSGlobalObject* exe a/Source/WebCore/inspector/WebInjectedScriptHost.cpp_sec5
173
        RETURN_IF_EXCEPTION(scope, { });
183
        RETURN_IF_EXCEPTION(scope, { });
174
        return array;
184
        return array;
175
    }
185
    }
176
#else
177
    UNUSED_PARAM(vm);
178
    UNUSED_PARAM(exec);
179
    UNUSED_PARAM(value);
180
#endif
186
#endif
181
187
182
    return { };
188
    return { };
- a/Source/WebCore/workers/Worker.h +1 lines
Lines 61-66 public: a/Source/WebCore/workers/Worker.h_sec1
61
    ExceptionOr<void> postMessage(JSC::JSGlobalObject&, JSC::JSValue message, PostMessageOptions&&);
61
    ExceptionOr<void> postMessage(JSC::JSGlobalObject&, JSC::JSValue message, PostMessageOptions&&);
62
62
63
    void terminate();
63
    void terminate();
64
    bool wasTerminated() const { return m_wasTerminated; }
64
65
65
    bool hasPendingActivity() const final;
66
    bool hasPendingActivity() const final;
66
67
- a/LayoutTests/ChangeLog +11 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2020-02-06  Devin Rousso  <drousso@apple.com>
2
3
        Web Inspector: show JavaScript Worker terminated state as an internal property
4
        https://bugs.webkit.org/show_bug.cgi?id=207347
5
6
        Reviewed by Brian Burg.
7
8
        * inspector/worker/worker-create-and-terminate.html:
9
        Add assertions throughout the test to check that the `terminated` value matches what the
10
        frontend knows.
11
1
2020-02-06  Commit Queue  <commit-queue@webkit.org>
12
2020-02-06  Commit Queue  <commit-queue@webkit.org>
2
13
3
        Unreviewed, rolling out r255910, r255970, and r255972.
14
        Unreviewed, rolling out r255910, r255970, and r255972.
- a/LayoutTests/inspector/worker/worker-create-and-terminate.html -40 / +89 lines
Lines 43-48 function test() a/LayoutTests/inspector/worker/worker-create-and-terminate.html_sec1
43
            ProtocolTest.log("No Workers");
43
            ProtocolTest.log("No Workers");
44
    }
44
    }
45
45
46
    async function checkInternalProperties(expression, {terminated} = {}) {
47
        let evaluateResult = await InspectorProtocol.awaitCommand({
48
            method: "Runtime.evaluate",
49
            params: {
50
                expression,
51
                objectGroup: "test",
52
            },
53
        });
54
55
        ProtocolTest.assert(evaluateResult.result.type === "object", `Evaluate result of '${expression}' should have type 'object'.`);
56
        ProtocolTest.assert(evaluateResult.result.className === "Worker", `Evaluate result of '${expression}' should have className 'Worker'.`);
57
58
        let getPropertiesResult = await InspectorProtocol.awaitCommand({
59
            method: "Runtime.getProperties",
60
            params: {
61
                objectId: evaluateResult.result.objectId,
62
            },
63
        });
64
65
        let internalProperties = getPropertiesResult.internalProperties;
66
        ProtocolTest.assert(internalProperties.length === 1, `Worker '${expression}' should only have one internal property.`);
67
68
        ProtocolTest.assert(internalProperties[0].name === "terminated", `Worker '${expression}' should have 'terminated' internal property.`);
69
        ProtocolTest.assert(internalProperties[0].value.type === "boolean", `Internal 'terminated' property of '${expression}' should be a boolean.`);
70
        ProtocolTest.assert(internalProperties[0].value.value === terminated, `Internal 'terminated' property of '${expression}' should have value '${terminated}'.`);
71
    }
72
46
73
47
    let triggerNextCreate;
74
    let triggerNextCreate;
48
    let triggerNextTerminate;
75
    let triggerNextTerminate;
Lines 78-147 function test() a/LayoutTests/inspector/worker/worker-create-and-terminate.html_sec2
78
    suite.addTestCase({
105
    suite.addTestCase({
79
        name: "Worker.enable",
106
        name: "Worker.enable",
80
        description: "Worker.enable informs the frontend of the two existing Workers",
107
        description: "Worker.enable informs the frontend of the two existing Workers",
81
        test(resolve, reject) {
108
        async test() {
82
            InspectorProtocol.awaitCommand({method: "Worker.enable", params: {}})
109
            await InspectorProtocol.awaitCommand({method: "Worker.enable", params: {}});
83
                .then(() => {
110
84
                    ProtocolTest.expectEqual(workers.length, 2, "Should be informed of two existing Workers.");
111
            ProtocolTest.expectEqual(workers.length, 2, "Should be informed of two existing Workers.");
85
                    dumpWorkers();
112
            dumpWorkers();
86
                    resolve();
113
87
                }).catch(reject);
114
            await Promise.all([
115
                checkInternalProperties(`worker1`, {terminated: false}),
116
                checkInternalProperties(`worker2`, {terminated: false}),
117
            ]);
88
        }
118
        }
89
    });
119
    });
90
120
91
    suite.addTestCase({
121
    suite.addTestCase({
92
        name: "Worker.workerCreated",
122
        name: "Worker.workerCreated",
93
        description: "Should receive a Worker.workerCreated event when creating a Worker.",
123
        description: "Should receive a Worker.workerCreated event when creating a Worker.",
94
        test(resolve, reject) {
124
        async test() {
95
            ProtocolTest.evaluateInPage("createWorker3()");
125
            await Promise.all([
96
            waitForWorkerCreatedEvent()
126
                waitForWorkerCreatedEvent(),
97
                .then(() => {
127
                ProtocolTest.evaluateInPage("createWorker3()"),
98
                    ProtocolTest.pass("Worker.workerCreated");
128
            ]);
99
                    dumpWorkers();
129
100
                    resolve();
130
            ProtocolTest.pass("Worker.workerCreated");
101
                }).catch(reject);
131
            dumpWorkers();
132
133
            await Promise.all([
134
                checkInternalProperties(`worker1`, {terminated: false}),
135
                checkInternalProperties(`worker2`, {terminated: false}),
136
                checkInternalProperties(`worker3`, {terminated: false}),
137
            ]);
102
        }
138
        }
103
    });
139
    });
104
140
105
    suite.addTestCase({
141
    suite.addTestCase({
106
        name: "Worker.workerTerminated.Page",
142
        name: "Worker.workerTerminated.Page",
107
        description: "Should receive a Worker.workerTerminated event when terminating a Worker from the Page.",
143
        description: "Should receive a Worker.workerTerminated event when terminating a Worker from the Page.",
108
        test(resolve, reject) {
144
        async test() {
109
            ProtocolTest.evaluateInPage("terminateWorker2FromPage()");
145
            await Promise.all([
110
            waitForWorkerTerminatedEvent()
146
                waitForWorkerTerminatedEvent(),
111
                .then(() => {
147
                ProtocolTest.evaluateInPage("terminateWorker2FromPage()"),
112
                    ProtocolTest.pass("Worker.workerTerminated");
148
            ]);
113
                    dumpWorkers();
149
114
                    resolve();
150
            ProtocolTest.pass("Worker.workerTerminated");
115
                }).catch(reject);
151
            dumpWorkers();
152
153
            await Promise.all([
154
                checkInternalProperties(`worker1`, {terminated: false}),
155
                checkInternalProperties(`worker2`, {terminated: true}),
156
                checkInternalProperties(`worker3`, {terminated: false}),
157
            ]);
116
        }
158
        }
117
    });
159
    });
118
160
119
    suite.addTestCase({
161
    suite.addTestCase({
120
        name: "Worker.workerTerminated.Worker",
162
        name: "Worker.workerTerminated.Worker",
121
        description: "Should receive a Worker.workerTerminated event when terminating a Worker from the Worker.",
163
        description: "Should receive a Worker.workerTerminated event when terminating a Worker from the Worker.",
122
        test(resolve, reject) {
164
        async test() {
123
            ProtocolTest.evaluateInPage("terminateWorker3FromWorker()");
165
            await Promise.all([
124
            waitForWorkerTerminatedEvent()
166
                waitForWorkerTerminatedEvent(),
125
                .then(() => {
167
                ProtocolTest.evaluateInPage("terminateWorker3FromWorker()"),
126
                    ProtocolTest.pass("Worker.workerTerminated");
168
            ]);
127
                    dumpWorkers();
169
128
                    resolve();
170
            ProtocolTest.pass("Worker.workerTerminated");
129
                }).catch(reject);
171
            dumpWorkers();
172
173
            await Promise.all([
174
                checkInternalProperties(`worker1`, {terminated: false}),
175
                checkInternalProperties(`worker2`, {terminated: true}),
176
            ]);
130
        }
177
        }
131
    });
178
    });
132
179
133
    suite.addTestCase({
180
    suite.addTestCase({
134
        name: "Worker.workerTerminated.GC",
181
        name: "Worker.workerTerminated.GC",
135
        description: "Should receive a Worker.workerTerminated event when terminating a Worker via Garbage Collection.",
182
        description: "Should receive a Worker.workerTerminated event when terminating a Worker via Garbage Collection.",
136
        test(resolve, reject) {
183
        async test() {
137
            ProtocolTest.evaluateInPage("terminateWorker1ViaCollection()");
184
            let workerTerminatedPromise = waitForWorkerTerminatedEvent();
138
            InspectorProtocol.sendCommand("Heap.gc", {});
185
            await ProtocolTest.evaluateInPage("terminateWorker1ViaCollection()");
139
            waitForWorkerTerminatedEvent()
186
            await InspectorProtocol.awaitCommand({method: "Runtime.releaseObjectGroup", params: {objectGroup: "test"}});
140
                .then(() => {
187
            await InspectorProtocol.awaitCommand({method: "Heap.gc", params: {}});
141
                    ProtocolTest.pass("Worker.workerTerminated");
188
            await workerTerminatedPromise;
142
                    dumpWorkers();
189
143
                    resolve();
190
            ProtocolTest.pass("Worker.workerTerminated");
144
                }).catch(reject);
191
            dumpWorkers();
192
193
            await checkInternalProperties(`worker2`, {terminated: true});
145
        }
194
        }
146
    });
195
    });
147
196

Return to Bug 207347