Introduce new test helper for live location synchronization
Asynchronous source mapping requires asynchronous live locations.
To prepare web tests for asynchronous live locations, we introduce a
test helper {TestRunner.waitForPendingLiveLocationUpdates} that allows
us to wait for pending updates before checking expectations in
web tests.
Using the following approach we do not need to disable web tests:
1.) Introduce {TestRunner.waitForPendingLiveLocationUpdates} helper
2.) Re-write web tests using async/await and the new helper
3.) Actually implement asynchronous live locations and the helper
R=mathias@chromium.org
Bug: chromium:1032016
Change-Id: I8a67c699826c272a974e96966f62f1b3ff7e44ab
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2059996
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
diff --git a/front_end/test_runner/TestRunner.js b/front_end/test_runner/TestRunner.js
index 9f95363..5ad57d3 100644
--- a/front_end/test_runner/TestRunner.js
+++ b/front_end/test_runner/TestRunner.js
@@ -1414,6 +1414,23 @@
addResult(value);
}
+/**
+ * This method blocks until all currently queued live location update handlers are done.
+ *
+ * Creating and updating live locations causes the update handler of each live location
+ * to run. These update handlers are potentially asynchronous and usually cause re-rendering or
+ * UI updates. Web tests then check for these updates.
+ * To give tests more control, waitForPendingLiveLocationUpdates returns a promise that resolves
+ * once all currently-pending updates (at call time) are completed.
+ */
+export async function waitForPendingLiveLocationUpdates() {
+ // TODO(chromium:1032016): Implement once the frontend has the actual methods in the bindings.
+ //
+ // This empty function is here so we can prepare affected web
+ // tests and than asyncify the frontend without needing to disable the
+ // affected web tests inbetween.
+}
+
/** @type {!{logToStderr: function(), navigateSecondaryWindow: function(string), notifyDone: function()}|undefined} */
self.testRunner;
@@ -1492,6 +1509,7 @@
TestRunner.deprecatedInitAsync = deprecatedInitAsync;
TestRunner.runAsyncTestSuite = runAsyncTestSuite;
TestRunner.dumpInspectedPageElementText = dumpInspectedPageElementText;
+TestRunner.waitForPendingLiveLocationUpdates = waitForPendingLiveLocationUpdates;
/**
* @typedef {!Object<string, string>}