Title: [261499] trunk
Revision
261499
Author
[email protected]
Date
2020-05-11 15:42:18 -0700 (Mon, 11 May 2020)

Log Message

Web Inspector: show _javascript_ Worker name as an internal property
https://bugs.webkit.org/show_bug.cgi?id=211708

Reviewed by Timothy Hatcher.

Source/WebCore:

Test: inspector/worker/worker-create-and-terminate.html

* inspector/WebInjectedScriptHost.cpp:
(WebCore::WebInjectedScriptHost::getInternalProperties):

* workers/Worker.h:
(WebCore::Worker::name const): Added.

LayoutTests:

* inspector/worker/worker-create-and-terminate.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261498 => 261499)


--- trunk/LayoutTests/ChangeLog	2020-05-11 22:40:20 UTC (rev 261498)
+++ trunk/LayoutTests/ChangeLog	2020-05-11 22:42:18 UTC (rev 261499)
@@ -1,3 +1,12 @@
+2020-05-11  Devin Rousso  <[email protected]>
+
+        Web Inspector: show _javascript_ Worker name as an internal property
+        https://bugs.webkit.org/show_bug.cgi?id=211708
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/worker/worker-create-and-terminate.html:
+
 2020-05-11  Peng Liu  <[email protected]>
 
         Enable the mock video presentation mode in related layout tests and fix test failures

Modified: trunk/LayoutTests/inspector/worker/worker-create-and-terminate.html (261498 => 261499)


--- trunk/LayoutTests/inspector/worker/worker-create-and-terminate.html	2020-05-11 22:40:20 UTC (rev 261498)
+++ trunk/LayoutTests/inspector/worker/worker-create-and-terminate.html	2020-05-11 22:42:18 UTC (rev 261499)
@@ -3,12 +3,12 @@
 <head>
 <script src=""
 <script>
-let worker1 = new Worker("resources/worker-1.js");
-let worker2 = new Worker("resources/worker-2.js");
+let worker1 = new Worker("resources/worker-1.js", {name: "Worker 1"});
+let worker2 = new Worker("resources/worker-2.js", {name: "Worker 2"});
 let worker3 = null;
 
 function createWorker3() {
-    worker3 = new Worker("resources/worker-3.js");
+    worker3 = new Worker("resources/worker-3.js", {name: "Worker 3"});
 }
 
 function terminateWorker2FromPage() {
@@ -43,7 +43,7 @@
             ProtocolTest.log("No Workers");
     }
 
-    async function checkInternalProperties(_expression_, {terminated} = {}) {
+    async function checkInternalProperties(_expression_, internalPropertiesToCheck) {
         let evaluateResult = await InspectorProtocol.awaitCommand({
             method: "Runtime.evaluate",
             params: {
@@ -55,19 +55,25 @@
         ProtocolTest.assert(evaluateResult.result.type === "object", `Evaluate result of '${_expression_}' should have type 'object'.`);
         ProtocolTest.assert(evaluateResult.result.className === "Worker", `Evaluate result of '${_expression_}' should have className 'Worker'.`);
 
-        let getPropertiesResult = await InspectorProtocol.awaitCommand({
+        let {internalProperties} = await InspectorProtocol.awaitCommand({
             method: "Runtime.getProperties",
             params: {
                 objectId: evaluateResult.result.objectId,
             },
         });
+        ProtocolTest.assert(internalProperties.length === 2, `Worker '${_expression_}' should only have one internal property.`);
 
-        let internalProperties = getPropertiesResult.internalProperties;
-        ProtocolTest.assert(internalProperties.length === 1, `Worker '${_expression_}' should only have one internal property.`);
+        function checkInternalProperty(propertyName, type) {
+            let internalProperty = internalProperties.find((item) => item.name === propertyName);
 
-        ProtocolTest.assert(internalProperties[0].name === "terminated", `Worker '${_expression_}' should have 'terminated' internal property.`);
-        ProtocolTest.assert(internalProperties[0].value.type === "boolean", `Internal 'terminated' property of '${_expression_}' should be a boolean.`);
-        ProtocolTest.assert(internalProperties[0].value.value === terminated, `Internal 'terminated' property of '${_expression_}' should have value '${terminated}'.`);
+            ProtocolTest.assert(internalProperty, `Worker '${_expression_}' should have '${propertyName}' internal property.`);
+            ProtocolTest.assert(internalProperty.value.type === type, `Internal '${propertyName}' property of '${_expression_}' should be a boolean.`);
+            ProtocolTest.assert(internalProperty.value.value === internalPropertiesToCheck[propertyName], `Internal '${propertyName}' property of '${_expression_}' should have value '${internalPropertiesToCheck[propertyName]}'.`);
+        }
+        if ("name" in internalPropertiesToCheck)
+            checkInternalProperty("name", "string");
+        if ("terminated" in internalPropertiesToCheck)
+            checkInternalProperty("terminated", "boolean");
     }
 
 
@@ -112,8 +118,8 @@
             dumpWorkers();
 
             await Promise.all([
-                checkInternalProperties(`worker1`, {terminated: false}),
-                checkInternalProperties(`worker2`, {terminated: false}),
+                checkInternalProperties(`worker1`, {name: "Worker 1", terminated: false}),
+                checkInternalProperties(`worker2`, {name: "Worker 2", terminated: false}),
             ]);
         }
     });
@@ -131,9 +137,9 @@
             dumpWorkers();
 
             await Promise.all([
-                checkInternalProperties(`worker1`, {terminated: false}),
-                checkInternalProperties(`worker2`, {terminated: false}),
-                checkInternalProperties(`worker3`, {terminated: false}),
+                checkInternalProperties(`worker1`, {name: "Worker 1", terminated: false}),
+                checkInternalProperties(`worker2`, {name: "Worker 2", terminated: false}),
+                checkInternalProperties(`worker3`, {name: "Worker 3", terminated: false}),
             ]);
         }
     });
@@ -151,9 +157,9 @@
             dumpWorkers();
 
             await Promise.all([
-                checkInternalProperties(`worker1`, {terminated: false}),
-                checkInternalProperties(`worker2`, {terminated: true}),
-                checkInternalProperties(`worker3`, {terminated: false}),
+                checkInternalProperties(`worker1`, {name: "Worker 1", terminated: false}),
+                checkInternalProperties(`worker2`, {name: "Worker 2", terminated: true}),
+                checkInternalProperties(`worker3`, {name: "Worker 3", terminated: false}),
             ]);
         }
     });
@@ -171,8 +177,8 @@
             dumpWorkers();
 
             await Promise.all([
-                checkInternalProperties(`worker1`, {terminated: false}),
-                checkInternalProperties(`worker2`, {terminated: true}),
+                checkInternalProperties(`worker1`, {name: "Worker 1", terminated: false}),
+                checkInternalProperties(`worker2`, {name: "Worker 2", terminated: true}),
             ]);
         }
     });
@@ -190,7 +196,9 @@
             ProtocolTest.pass("Worker.workerTerminated");
             dumpWorkers();
 
-            await checkInternalProperties(`worker2`, {terminated: true});
+            await Promise.all([
+                checkInternalProperties(`worker2`, {name: "Worker 2", terminated: true}),
+            ]);
         }
     });
 

Modified: trunk/Source/WebCore/ChangeLog (261498 => 261499)


--- trunk/Source/WebCore/ChangeLog	2020-05-11 22:40:20 UTC (rev 261498)
+++ trunk/Source/WebCore/ChangeLog	2020-05-11 22:42:18 UTC (rev 261499)
@@ -1,3 +1,18 @@
+2020-05-11  Devin Rousso  <[email protected]>
+
+        Web Inspector: show _javascript_ Worker name as an internal property
+        https://bugs.webkit.org/show_bug.cgi?id=211708
+
+        Reviewed by Timothy Hatcher.
+
+        Test: inspector/worker/worker-create-and-terminate.html
+
+        * inspector/WebInjectedScriptHost.cpp:
+        (WebCore::WebInjectedScriptHost::getInternalProperties):
+
+        * workers/Worker.h:
+        (WebCore::Worker::name const): Added.
+
 2020-05-11  Simon Fraser  <[email protected]>
 
         Have ScrollingThread use a RunLoop rather than rolling its own

Modified: trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp (261498 => 261499)


--- trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp	2020-05-11 22:40:20 UTC (rev 261498)
+++ trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp	2020-05-11 22:42:18 UTC (rev 261499)
@@ -168,6 +168,7 @@
     if (auto* worker = JSWorker::toWrapped(vm, value)) {
         unsigned index = 0;
         auto* array = constructEmptyArray(exec, nullptr);
+        array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "name"_s, jsString(vm, worker->name())));
         array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "terminated"_s, jsBoolean(worker->wasTerminated())));
         RETURN_IF_EXCEPTION(scope, { });
         return array;

Modified: trunk/Source/WebCore/workers/Worker.h (261498 => 261499)


--- trunk/Source/WebCore/workers/Worker.h	2020-05-11 22:40:20 UTC (rev 261498)
+++ trunk/Source/WebCore/workers/Worker.h	2020-05-11 22:42:18 UTC (rev 261499)
@@ -64,6 +64,7 @@
     bool wasTerminated() const { return m_wasTerminated; }
 
     String identifier() const { return m_identifier; }
+    const String& name() const { return m_name; }
 
     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to