Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: third_party/WebKit/LayoutTests/fast/workers/shared-worker-usecounter.html

Issue 2680423006: UseCounter: Introduce UseCounter::Observer for layout tests (Closed)
Patch Set: instance method Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/workers/shared-worker-usecounter.html
diff --git a/third_party/WebKit/LayoutTests/fast/workers/shared-worker-usecounter.html b/third_party/WebKit/LayoutTests/fast/workers/shared-worker-usecounter.html
index ef5fecba9666e235672aec7354df4955e58b19c9..51cf03c2cde064a3ad37f775c6e10bdae07036df 100644
--- a/third_party/WebKit/LayoutTests/fast/workers/shared-worker-usecounter.html
+++ b/third_party/WebKit/LayoutTests/fast/workers/shared-worker-usecounter.html
@@ -13,6 +13,10 @@ function isUseCounted(win, feature) {
return win.internals.isUseCounted(win.document, feature);
}
+function observeUseCounter(win, feature) {
+ return win.internals.observeUseCounter(win.document, feature);
+}
+
function openWindow(url) {
return new Promise(resolve => {
let win = window.open(url, '_blank');
@@ -54,14 +58,13 @@ promise_test(t => {
assert_false(isUseCounted(win2, kFeature));
// Request to count a feature.
- let promise =
- new Promise(resolve => worker.port.onmessage = resolve);
worker.port.postMessage({type: 'COUNT_FEATURE', feature: kFeature});
- return promise;
+ return Promise.all([
+ observeUseCounter(win1, kFeature),
+ observeUseCounter(win2, kFeature)
+ ]);
})
- .then(e => {
- assert_equals(e.data, 'COUNTED');
-
+ .then(() => {
// API use on the SharedWorkerGlobalScope is recorded in UseCounters on
// all connected documents.
assert_true(isUseCounted(win1, kFeature));
@@ -71,15 +74,14 @@ promise_test(t => {
assert_false(isUseCounted(win2, kDeprecatedFeature));
// Request to count a deprecated feature.
- let promise =
- new Promise(resolve => worker.port.onmessage = resolve);
worker.port.postMessage(
{type: 'COUNT_DEPRECATION', feature: kDeprecatedFeature});
- return promise;
+ return Promise.all([
+ observeUseCounter(win1, kDeprecatedFeature),
+ observeUseCounter(win2, kDeprecatedFeature)
+ ]);
})
- .then(e => {
- assert_equals(e.data, 'COUNTED');
-
+ .then(() => {
// Deprecated API use on the SharedWorkerGlobalScope is recorded in
// UseCounters on all connected documents.
assert_true(isUseCounted(win1, kDeprecatedFeature));
@@ -93,7 +95,11 @@ promise_test(t => {
// not be counted yet.
assert_false(isUseCounted(win3, kFeature));
assert_false(isUseCounted(win3, kDeprecatedFeature));
- return win3.connectToWorker();
+ win3.connectToWorker();
+ return Promise.all([
+ observeUseCounter(win3, kFeature),
+ observeUseCounter(win3, kDeprecatedFeature)
+ ]);
})
.then(() => {
// A counter of the newly connected document should be synced with

Powered by Google App Engine
This is Rietveld 408576698