LayoutTest inspector/worker/debugger-pause.html sometimes times out
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2018 18:41:30 +0000 (18:41 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2018 18:41:30 +0000 (18:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188580

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2018-08-16
Reviewed by Matt Baker.

Source/WebInspectorUI:

* UserInterface/Protocol/Target.js:
(WI.Target.prototype.get mainResource):
(WI.Target.prototype.set mainResource):
Dispatch an event when the Main Resource is set.

LayoutTests:

* inspector/worker/debugger-pause.html:
* inspector/worker/resources/worker-utilities.js: Added.
(TestPage.registerInitializer.window.awaitTargetMainResource):
(TestPage.registerInitializer):
Use a more deterministic wait for the main resource.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234945 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/worker/debugger-pause.html
LayoutTests/inspector/worker/resources/worker-utilities.js [new file with mode: 0644]
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Protocol/Target.js

index 444ebfd..7ed9fed 100644 (file)
@@ -1,3 +1,16 @@
+2018-08-16  Joseph Pecoraro  <pecoraro@apple.com>
+
+        LayoutTest inspector/worker/debugger-pause.html sometimes times out
+        https://bugs.webkit.org/show_bug.cgi?id=188580
+
+        Reviewed by Matt Baker.
+
+        * inspector/worker/debugger-pause.html:
+        * inspector/worker/resources/worker-utilities.js: Added.
+        (TestPage.registerInitializer.window.awaitTargetMainResource):
+        (TestPage.registerInitializer):
+        Use a more deterministic wait for the main resource.
+
 2018-08-16  Ryosuke Niwa  <rniwa@webkit.org>
 
         Perform a microtask checkpoint before creating a custom element
 2018-08-16  Ryosuke Niwa  <rniwa@webkit.org>
 
         Perform a microtask checkpoint before creating a custom element
index 0de5134..8f4425e 100644 (file)
@@ -3,6 +3,7 @@
 <head>
 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
 <script src="../debugger/resources/log-pause-location.js"></script>
 <head>
 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
 <script src="../debugger/resources/log-pause-location.js"></script>
+<script src="resources/worker-utilities.js"></script>
 <script>
 TestPage.allowUncaughtExceptions = true;
 TestPage.needToSanitizeUncaughtExceptionURLs = true;
 <script>
 TestPage.allowUncaughtExceptions = true;
 TestPage.needToSanitizeUncaughtExceptionURLs = true;
@@ -111,8 +112,7 @@ function test()
         }
     });
 
         }
     });
 
-    // Turn once to ensure workerTarget.mainResource is loaded.
-    Promise.resolve().then(() => {
+    awaitTargetMainResource(workerTarget).then(() => {
         window.loadLinesFromSourceCode(workerTarget.mainResource).then(() => {
             suite.runTestCasesAndFinish();
         });
         window.loadLinesFromSourceCode(workerTarget.mainResource).then(() => {
             suite.runTestCasesAndFinish();
         });
diff --git a/LayoutTests/inspector/worker/resources/worker-utilities.js b/LayoutTests/inspector/worker/resources/worker-utilities.js
new file mode 100644 (file)
index 0000000..ae17aa3
--- /dev/null
@@ -0,0 +1,7 @@
+TestPage.registerInitializer(() => {
+    window.awaitTargetMainResource = function(workerTarget) {
+        if (workerTarget.mainResource)
+            return Promise.resolve();
+        return workerTarget.awaitEvent(WI.Target.Event.MainResourceAdded);
+    }
+});
index 03e1783..452180e 100644 (file)
@@ -1,3 +1,15 @@
+2018-08-16  Joseph Pecoraro  <pecoraro@apple.com>
+
+        LayoutTest inspector/worker/debugger-pause.html sometimes times out
+        https://bugs.webkit.org/show_bug.cgi?id=188580
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Protocol/Target.js:
+        (WI.Target.prototype.get mainResource):
+        (WI.Target.prototype.set mainResource):
+        Dispatch an event when the Main Resource is set.
+
 2018-08-15  Aditya Keerthi  <akeerthi@apple.com>
 
         [Datalist] Add button to TextFieldInputs with a datalist
 2018-08-15  Aditya Keerthi  <akeerthi@apple.com>
 
         [Datalist] Add button to TextFieldInputs with a datalist
index 2d4cf13..92d13fc 100644 (file)
@@ -56,9 +56,6 @@ WI.Target = class Target extends WI.Object
     get name() { return this._name; }
     set name(name) { this._name = name; }
 
     get name() { return this._name; }
     set name(name) { this._name = name; }
 
-    get mainResource() { return this._mainResource; }
-    set mainResource(resource) { this._mainResource = resource; }
-
     get type() { return this._type; }
     get connection() { return this._connection; }
     get executionContext() { return this._executionContext; }
     get type() { return this._type; }
     get connection() { return this._connection; }
     get executionContext() { return this._executionContext; }
@@ -68,6 +65,20 @@ WI.Target = class Target extends WI.Object
 
     get displayName() { return this._name; }
 
 
     get displayName() { return this._name; }
 
+    get mainResource()
+    {
+        return this._mainResource;
+    }
+
+    set mainResource(resource)
+    {
+        console.assert(!this._mainResource);
+
+        this._mainResource = resource;
+
+        this.dispatchEventToListeners(WI.Target.Event.MainResourceAdded, {resource});
+    }
+
     addResource(resource)
     {
         this._resourceCollection.add(resource);
     addResource(resource)
     {
         this._resourceCollection.add(resource);
@@ -98,6 +109,7 @@ WI.Target.Type = {
 };
 
 WI.Target.Event = {
 };
 
 WI.Target.Event = {
+    MainResourceAdded: "target-main-resource-added",
     ResourceAdded: "target-resource-added",
     ScriptAdded: "target-script-added",
 };
     ResourceAdded: "target-resource-added",
     ScriptAdded: "target-script-added",
 };