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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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/imported/wpt/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-matchall-include-uncontrolled.html b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html
similarity index 74%
copy from third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-matchall-include-uncontrolled.html
copy to third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html
index 1398a878ff0ca24558a819e8a21aaec76587c519..9285aef970fc2399a52ccb645f1dab3ce8d2a7c6 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-matchall-include-uncontrolled.html
+++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html
@@ -1,23 +1,29 @@
<!DOCTYPE html>
<title>Service Worker: Clients.matchAll with includeUncontrolled</title>
-<script src="../resources/testharness.js"></script>
-<script src="../resources/testharnessreport.js"></script>
-<script src="resources/test-helpers.js"></script>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.sub.js"></script>
<script>
var base_url = 'resources/blank.html'; // This is out-of-scope.
var scope = base_url + '?clients-matchAll-includeUncontrolled';
+var frames = [];
// Creates 3 iframes, 2 for in-scope and 1 for out-of-scope.
// The frame opened for scope + '#2' is returned via a promise.
-// FIXME: remove iframes when the test finishes.
function create_iframes(scope) {
return with_iframe(base_url)
.then(function(frame0) {
+ frames.push(frame0);
return with_iframe(scope + '#1');
})
.then(function(frame1) {
+ frames.push(frame1);
return with_iframe(scope + '#2');
- });
+ })
+ .then(function(frame2) {
+ frames.push(frame2);
+ return frame2;
+ })
}
var expected_without_include_uncontrolled = [
@@ -28,10 +34,10 @@ var expected_without_include_uncontrolled = [
var expected_with_include_uncontrolled = [
/* visibilityState, focused, url, frameType */
+ ['visible', true, location.href, 'top-level'],
['visible', false, new URL(scope + '#1', location).toString(), 'nested'],
['visible', true, new URL(scope + '#2', location).toString(), 'nested'],
- ['visible', false, new URL(base_url, location).toString(), 'nested'],
- ['visible', true, location.href, 'top-level']
+ ['visible', false, new URL(base_url, location).toString(), 'nested']
];
function test_matchall(frame, expected, query_options) {
@@ -42,10 +48,16 @@ function test_matchall(frame, expected, query_options) {
return new Promise(function(resolve, reject) {
var channel = new MessageChannel();
channel.port1.onmessage = function(e) {
- e.data.sort(function(a, b) { return a[2] > b[2] ? 1 : -1; });
- assert_equals(e.data.length, expected.length);
- for (var i = 0; i < e.data.length; i++)
- assert_array_equals(e.data[i], expected[i]);
+ // Ignore hidden clients which may be coming from background tabs, or
+ // clients unrelated to this test.
+ var data = e.data.filter(function(info) {
+ return info[0] == 'visible' &&
+ info[2].indexOf('service-worker') > -1;
+ });
+ data.sort(function(a, b) { return a[2] > b[2] ? 1 : -1; });
+ assert_equals(data.length, expected.length);
+ for (var i = 0; i < data.length; i++)
+ assert_array_equals(data[i], expected[i]);
resolve(frame);
};
frame.contentWindow.navigator.serviceWorker.controller.postMessage(
@@ -72,6 +84,7 @@ async_test(function(t) {
{includeUncontrolled:true});
})
.then(function() {
+ frames.forEach(function(f) { f.remove() });
service_worker_unregister_and_done(t, scope);
})
.catch(unreached_rejection(t));

Powered by Google App Engine
This is Rietveld 408576698