Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / serviceworker / serviceworkerglobalscope-scope.html
index f2d9f1f..5467eaa 100644 (file)
@@ -6,7 +6,7 @@
 <script>
 function scope_test(name, scope) {
   var t = async_test('Verify the scope property: ' + name);
-  t.step(function() {
+  return new Promise(function(test_finished) {
       var expectedScope, options;
       if (scope) {
         expectedScope = new URL(scope, document.location).toString();
@@ -15,25 +15,17 @@ function scope_test(name, scope) {
       }
 
       var registration;
-      service_worker_unregister_and_register(
-          t, 'resources/serviceworkerglobalscope-scope-worker.js', scope)
+      var script = 'resources/serviceworkerglobalscope-scope-worker.js';
+      var options = scope ? { scope: scope } : {};
+      service_worker_unregister(t, scope)
+        .then(function() {
+            return navigator.serviceWorker.register(script, options);
+          })
         .then(function(r) {
             registration = r;
-            assert_equals(registration.waiting, null,
-                          'registration.waiting should be null');
-            assert_equals(registration.active, null,
-                          'registration.active should be null');
-            assert_equals(registration.installing, null,
-                          'registration.installing should be null');
             return wait_for_update(t, registration);
           })
         .then(function(worker) {
-            assert_equals(registration.waiting, null,
-                          'registration.waiting should be null');
-            assert_equals(registration.active, null,
-                          'registration.active should be null');
-            assert_equals(registration.installing, worker,
-                          'registration.installing should not be null');
             return new Promise(function(resolve) {
                 var messageChannel = new MessageChannel();
                 messageChannel.port1.onmessage = resolve;
@@ -46,14 +38,23 @@ function scope_test(name, scope) {
                           'Worker should see the scope on eval.');
             assert_equals(message.currentScope, expectedScope,
                           'Worker scope should not change.');
-            service_worker_unregister_and_done(t, scope);
+            return registration.unregister();
+          })
+        .then(function() {
+            t.done();
+            test_finished();
           })
-        .catch(unreached_rejection(t));
+        .catch(function(error) {
+            unreached_rejection(t)(error);
+            test_finished();
+          });
     });
 }
 
-scope_test('default');
-scope_test('relative path', '/a/b/c/');
-scope_test('absolute url', 'http://127.0.0.1:8000/');
+// 'default' and 'absolute url' are the same scope, so don't let the tests
+// run concurrently.
+scope_test('default')
+  .then(scope_test('relative path', '/a/b/c/'))
+  .then(scope_test('absolute url', 'http://127.0.0.1:8000/'));
 
 </script>