| Index: LayoutTests/http/tests/serviceworker/chromium/clients-openwindow.html | 
| diff --git a/LayoutTests/http/tests/serviceworker/chromium/clients-openwindow.html b/LayoutTests/http/tests/serviceworker/chromium/clients-openwindow.html | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..e81b49aa71b15a414a21adb438343a122f005705 | 
| --- /dev/null | 
| +++ b/LayoutTests/http/tests/serviceworker/chromium/clients-openwindow.html | 
| @@ -0,0 +1,68 @@ | 
| +<!DOCTYPE html> | 
| +<title>Service Worker: clients.openWindow() tests (using testRunner)</title> | 
| +<script src="../../resources/testharness.js"></script> | 
| +<script src="../../resources/testharnessreport.js"></script> | 
| +<script src="../resources/test-helpers.js"></script> | 
| +<script> | 
| +// This test is using testRunner to grant itself the notification permission and | 
| +// to simulate a click on a notification. A couple of changes would allow it to | 
| +// be run as a manual test by other browser vendors. | 
| +if (window.testRunner) | 
| +    testRunner.grantWebNotificationPermission(location.origin, true); | 
| + | 
| +var t = async_test('clients.openWindow() behaved as expected'); | 
| +t.step(function() { | 
| +    var scope = 'resources/blank.html' | 
| +    service_worker_unregister_and_register( | 
| +        t, 'resources/clients-openwindow.js', scope) | 
| +      .then(function(registration) { | 
| +          return wait_for_state(t, registration.installing, 'activated'); | 
| +        }) | 
| +      .then(function() { return with_iframe(scope); }) | 
| +      .then(function(frame) { | 
| +          var w = frame.contentWindow; | 
| +          w.onmessage = t.step_func(onMessage); | 
| +          w.navigator.serviceWorker.controller.postMessage('start'); | 
| +        }) | 
| +      .catch(unreached_rejection(t)); | 
| + | 
| +    var result = []; | 
| +    var expected = ['openWindow() can\'t open a window without a user interaction', | 
| +                    'openWindow() error is InvalidAccessError', | 
| +                    'openWindow() can\'t open cross origin windows', | 
| +                    'openWindow() error is SecurityError', | 
| +                    'openWindow() can open not controlled windows', | 
| +                    'openWindow() result: null', | 
| +                    'openWindow() can open controlled windows', | 
| +                    'openWindow() result: [object WindowClient]', | 
| +                    ' url: ' + location.origin + '/serviceworker/chromium/resources/blank.html', | 
| +                    ' visibilityState: visible', | 
| +                    ' focused: true', | 
| +                    ' frameType: top-level']; | 
| + | 
| +    // LayoutTests on Mac do not open focused windows. | 
| +    var isMac = navigator.platform.indexOf('Mac') == 0; | 
| +    if (isMac) | 
| +      expected[10] = ' focused: false'; | 
| + | 
| +    function onMessage(e) { | 
| +      var message = e.data; | 
| + | 
| +      if (typeof(message) === 'object') { | 
| +        if (message.type !== 'click') | 
| +          return; | 
| +        if (window.testRunner) | 
| +          testRunner.simulateWebNotificationClick(message.title); | 
| +        return; | 
| +      } | 
| + | 
| +      if (message === 'quit') { | 
| +        assert_array_equals(result, expected, | 
| +                            'Worker should post back expected messages.'); | 
| +        service_worker_unregister_and_done(t, scope); | 
| +      } else { | 
| +        result.push(message); | 
| +      } | 
| +    } | 
| +  }); | 
| +</script> | 
|  |