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

Unified Diff: LayoutTests/http/tests/navigatorconnect/resources/connect-tests.js

Issue 1198653004: Update client side navigator.connect API to use ServicePortCollection [3/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@serviceport-part2
Patch Set: rebase Created 5 years, 6 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: LayoutTests/http/tests/navigatorconnect/resources/connect-tests.js
diff --git a/LayoutTests/http/tests/navigatorconnect/resources/connect-tests.js b/LayoutTests/http/tests/navigatorconnect/resources/connect-tests.js
index e3891915e1db674e10589c65b8c1b981314c2f1e..f0c9d3b2a59dad5fccf5ef79ce67dc2c50766dd2 100644
--- a/LayoutTests/http/tests/navigatorconnect/resources/connect-tests.js
+++ b/LayoutTests/http/tests/navigatorconnect/resources/connect-tests.js
@@ -53,7 +53,8 @@ function run_connect_tests(connect_method) {
return connect_method(t, scope + '/service');
})
.then(function(port) {
- assert_class_string(port, 'MessagePort');
+ var targetURL = new URL(port.targetURL);
+ assert_equals(targetURL.pathname, base_path() + scope + '/service');
return service_worker_unregister(t, scope);
});
}, 'Connection succeeds if service worker accepts connection event.');
@@ -84,8 +85,28 @@ function run_connect_tests(connect_method) {
return connect_method(t, scope + '/service?accept');
})
.then(function(port) {
- assert_class_string(port, 'MessagePort');
+ var targetURL = new URL(port.targetURL);
+ assert_equals(targetURL.pathname, base_path() + scope + '/service');
return service_worker_unregister(t, scope);
});
}, 'Connection succeeds if service worker accepts connection event async.');
+
+ promise_test(function(t) {
+ var scope = sw_scope + '/accepting';
+ var sw_url = 'resources/accepting-worker.js';
+ return service_worker_unregister_and_register(t, sw_url, scope)
+ .then(function(registration) {
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(function() {
+ return connect_method(t, scope + '/service', {name: 'somename', data: 'somedata'});
+ })
+ .then(function(port) {
+ var targetURL = new URL(port.targetURL);
+ assert_equals(targetURL.pathname, base_path() + scope + '/service');
+ assert_equals(port.name, 'somename');
+ assert_equals(port.data, 'somedata');
+ return service_worker_unregister(t, scope);
+ });
+ }, 'Returned port has correct name and data fields');
}

Powered by Google App Engine
This is Rietveld 408576698