Commit f68671e4 authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Convert async_test(async ...) to promise_tests in subresource_filter/

Passing an async function to async_test will soon be disallowed in WPT,
as any asserts thrown will be turned into unhandled promise rejections
and the test will timeout. If a test needs async functions it should use
promise_test instead.

(The naming conflict is a sad historical legacy; WPT had async_test long
before EcmaScript spec'd promises!)

Bug: https://github.com/web-platform-tests/wpt/issues/21435
Change-Id: I6082d03b6821781ed62d274dc0ca0b2741d2d285
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414675Reviewed-by: default avatarAlex Turner <alexmt@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807908}
parent 36287592
......@@ -31,7 +31,7 @@ p {
<!-- To be positioned further down in the main page to make the page scrollable -->
<div class="bottom"></div>
<script>
async_test(async function(t) {
promise_test(async function(t) {
// Create the large-sticky-ad.
appendAdFrameTo(document.body);
......@@ -40,9 +40,7 @@ async_test(async function(t) {
await timeout(1500);
await forceLayoutUpdate();
t.step(function () {
assert_false(internals.isUseCounted(document, kLargeStickyAd));
});
assert_false(internals.isUseCounted(document, kLargeStickyAd));
// Scroll down to 1px.
window.scrollTo(0, 1);
......@@ -52,9 +50,7 @@ async_test(async function(t) {
// candidate, so we expect no use counter for kLargeStickyAd.
await timeout(1500);
await forceLayoutUpdate();
t.step(function () {
assert_false(internals.isUseCounted(document, kLargeStickyAd));
});
assert_false(internals.isUseCounted(document, kLargeStickyAd));
// Scroll down to 5000px.
window.scrollTo(0, 5000);
......@@ -64,10 +60,7 @@ async_test(async function(t) {
// so the use counter kLargeStickyAd should be recorded.
await timeout(1500);
await forceLayoutUpdate();
t.step(function () {
assert_true(internals.isUseCounted(document, kLargeStickyAd));
});
t.done();
assert_true(internals.isUseCounted(document, kLargeStickyAd));
}, "Test UseCounter for large-sticky-ad at the bottom when the frame itself has a fixed position.");
</script>
</body>
......
......@@ -31,7 +31,7 @@ p {
<!-- To be positioned further down in the main page to make the page scrollable -->
<div class="bottom"></div>
<script>
async_test(async function(t) {
promise_test(async function(t) {
// Create the large-sticky-ad.
appendAdFrameTo(document.body);
......@@ -42,9 +42,7 @@ async_test(async function(t) {
// aware of the sticky ad candidate.
await timeout(1500);
await forceLayoutUpdate();
t.step(function () {
assert_false(internals.isUseCounted(document, kLargeStickyAd));
});
assert_false(internals.isUseCounted(document, kLargeStickyAd));
// Scroll down to 5000px. Reset the frame's position w.r.t. the viewport
// to its initial position.
......@@ -56,11 +54,7 @@ async_test(async function(t) {
// so the use counter kLargeStickyAd should be recorded.
await timeout(1500);
await forceLayoutUpdate();
t.step(function() {
assert_true(internals.isUseCounted(document, kLargeStickyAd));
});
t.done();
assert_true(internals.isUseCounted(document, kLargeStickyAd));
}, "Test UseCounter for large-sticky-ad at the bottom when the frame itself has an absolute position, and along with scrolling the ad's position w.r.t. the browser viewport gets frequently reset to the initial postion.");
</script>
</body>
......
......@@ -31,16 +31,14 @@ p {
<!-- To be positioned further down in the main page to make the page scrollable -->
<div class="bottom"></div>
<script>
async_test(async function(t) {
promise_test(async function(t) {
// Create the large-sticky-ad.
appendAdFrameTo(document.body);
// After 1500ms, force a layout update.
await timeout(1500);
await forceLayoutUpdate();
t.step(function () {
assert_false(internals.isUseCounted(document, kLargeStickyAd));
});
assert_false(internals.isUseCounted(document, kLargeStickyAd));
// Scroll down to 5000px.
window.scrollTo(0, 5000);
......@@ -50,11 +48,7 @@ async_test(async function(t) {
// We expect no kLargeStickyAd use counter.
await timeout(1500);
await forceLayoutUpdate();
t.step(function () {
assert_false(internals.isUseCounted(document, kLargeStickyAd));
});
t.done();
assert_false(internals.isUseCounted(document, kLargeStickyAd));
}, "Test a large-sticky-ad at the center. In this case, we expect no use counter for kLargeStickyAd.");
</script>
</body>
......
......@@ -35,7 +35,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// is aware of the first meaningful paint, and future overlay candidates
// will be considered for pop-ups rather than for prestitials.
......@@ -52,11 +52,7 @@ async_test(async function(t) {
await forceLayoutUpdate();
// Expect the OverlayPopupAd UseCounter.
t.step(function () {
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test UseCounter for overlay-popup-ad when the frame has position:absolute and the <body> has overflow:hidden.");
</script>
</body>
......
......@@ -44,8 +44,7 @@ div.bottom {
if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// is aware of the first meaningful paint, and future overlay candidates
// will be considered for pop-ups rather than for prestitials.
......@@ -75,11 +74,7 @@ async_test(async function(t) {
// Expect no OverlayPopupAd UseCounter as the popup was created with user
// gesture.
t.step(function() {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test overlay-popup-ad when the frame itself has a fixed position and it's created with user gesture. In this case, we expect no use counter for kOverlayPopupAd.");
</script>
......
......@@ -45,7 +45,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// is aware of the first meaningful paint, and future overlay candidates
// will be considered for pop-ups rather than for prestitials.
......@@ -67,11 +67,7 @@ async_test(async function(t) {
await forceLayoutUpdate();
// Expect the OverlayPopupAd UseCounter.
t.step(function() {
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test UseCounter for overlay-popup-ad when the frame itself has a fixed position.");
</script>
......
......@@ -45,7 +45,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// is aware of the first meaningful paint, and future overlay candidates
// will be considered for pop-ups rather than for prestitials.
......@@ -67,11 +67,7 @@ async_test(async function(t) {
await forceLayoutUpdate();
// Expect the OverlayPopupAd UseCounter.
t.step(function() {
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test UseCounter for overlay-popup-ad when the frame's outer div has a fixed position.");
</script>
......
......@@ -45,7 +45,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// is aware of the first meaningful paint, and future overlay candidates
// will be considered for pop-ups rather than for prestitials.
......@@ -68,11 +68,7 @@ async_test(async function(t) {
// Expect that the use counter kOverlayPopupAd is not recorded, as the
// ad size is too small relative to the viewport size.
t.step(function() {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test overlay-popup-ad when the frame itself has a fixed position and the size is less than 10% of the viewport size. In this case, we expect no use counter for kOverlayPopupAd.");
</script>
......
......@@ -46,7 +46,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// would have been aware of the first meaningful paint (hadn't we skipped
// the detection in fullscreen video scenario).
......@@ -72,11 +72,7 @@ async_test(async function(t) {
// Expect that the use counter kOverlayPopupAd is not recorded, as we
// skipped all previous detection due to there was a fullscreen video
// element.
t.step(function () {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test that we will skip the overlay-popup-ad detection if there's a dominant video element in the page.");
</script>
......
......@@ -42,7 +42,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// is aware of the first meaningful paint, and future overlay candidates
// will be considered for pop-ups rather than for prestitials.
......@@ -62,9 +62,7 @@ async_test(async function(t) {
// Expect no OverlayPopupAd usage, as the ad frame is not in the center of
// the viewport.
t.step(function () {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
// Resize the window to to make the overlay iframe centered and large
// relative to the viewport.
......@@ -78,18 +76,14 @@ async_test(async function(t) {
// Expect no OverlayPopupAd usage, as the viewport has just been resized
// so we have skipped this detection.
t.step(function () {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
// Force a layout update, to trigger another detection event.
await forceLayoutUpdate();
// Expect no OverlayPopupAd usage, as the overlay has been marked
// unqualified.
t.step(function () {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
// Create another overlay pop-up ad.
appendAdFrameTo(document.getElementsByTagName('div')[0]);
......@@ -99,11 +93,7 @@ async_test(async function(t) {
await forceLayoutUpdate();
// Expect OverlayPopupAd usage due to the appearance of the new overlay.
t.step(function () {
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test overlay-popup-ad when the ad appears before (no use counter) & after (use counter) resizing the viewport.");
</script>
</body>
......
......@@ -49,7 +49,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// is aware of the first meaningful paint, and future overlay candidates
// will be considered for pop-ups rather than for prestitials.
......@@ -72,14 +72,10 @@ async_test(async function(t) {
await forceLayoutUpdate();
// Expect use counter kOverlayPopup.
t.step(function () {
assert_true(internals.isUseCounted(document, kOverlayPopup));
});
assert_true(internals.isUseCounted(document, kOverlayPopup));
// Expect use counter kOverlayPopupAd is NOT recorded.
t.step(function () {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
// Create the overlay pop-up ad.
appendAdFrameTo(document.getElementsByTagName('div')[0]);
......@@ -96,11 +92,7 @@ async_test(async function(t) {
await forceLayoutUpdate();
// Expect use counter kOverlayPopupAd.
t.step(function () {
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_true(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test UseCounter for overlay-popup non-ad element followed by an ad element.");
</script>
</body>
......
......@@ -28,7 +28,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// Create the overlay pop-up ad.
let ad_frame = appendAdFrameTo(document.body);
......@@ -50,11 +50,7 @@ async_test(async function(t) {
// Expect no kOverlayPopupAd UseCounter as the candidate is considered to
// be 'prestitial' instead of 'pop-up'.
t.step(function () {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test overlay-prestitial-ad when the frame itself has a fixed position. In this case we expect no use counter for kOverlayPopupAd.");
</script>
......
......@@ -52,7 +52,7 @@ p {
<div class="content2">some content</div>
<script>
async_test(async function(t) {
promise_test(async function(t) {
// Create the large-sticky-ad.
appendAdFrameTo(document.body);
......@@ -64,9 +64,7 @@ async_test(async function(t) {
// detector is aware of the candidate.
await timeout(1500);
await forceLayoutUpdate();
t.step(function () {
assert_false(internals.isUseCounted(document, kLargeStickyAd));
});
assert_false(internals.isUseCounted(document, kLargeStickyAd));
// Scroll further down to the position where the parallax-ad is covered by
// "content2" and becomes invisible again.
......@@ -78,11 +76,7 @@ async_test(async function(t) {
await timeout(1500);
await forceLayoutUpdate();
t.step(function () {
assert_false(internals.isUseCounted(document, kLargeStickyAd));
});
t.done();
assert_false(internals.isUseCounted(document, kLargeStickyAd));
}, "Test parallax-ad while scrolling over the page. In this case, we expect no use counter for kLargeStickyAd.");
</script>
......
......@@ -56,7 +56,7 @@ if (window.testRunner) {
internals.DisableFrequencyCappingForOverlayPopupDetection();
}
async_test(async function(t) {
promise_test(async function(t) {
// After 1500ms, force a layout update so that the interstitial detector
// is aware of the first meaningful paint, and future overlay candidates
// will be considered for pop-ups rather than for prestitials.
......@@ -85,11 +85,7 @@ async_test(async function(t) {
// Expect no kOverlayPopupAd UseCounter as the scroll offset has changed
// since the candidate's appearance.
t.step(function () {
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
});
t.done();
assert_false(internals.isUseCounted(document, kOverlayPopupAd));
}, "Test parallax-ad while scrolling over the page. In this case, we expect no use counter for kOverlayPopupAd.");
</script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment