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

Unified Diff: LayoutTests/http/tests/serviceworker/resources/notificationclick-can-focus.js

Issue 896043004: Tests for WaitUntilObserver and focus/openining windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sw_client_focus_cleanup
Patch Set: Created 5 years, 10 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/serviceworker/resources/notificationclick-can-focus.js
diff --git a/LayoutTests/http/tests/serviceworker/resources/notificationclick-can-focus.js b/LayoutTests/http/tests/serviceworker/resources/notificationclick-can-focus.js
new file mode 100644
index 0000000000000000000000000000000000000000..a7d712a54669d6a0d37447e63eff7999d15855f8
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/resources/notificationclick-can-focus.js
@@ -0,0 +1,42 @@
+var client = null;
+
+function initializeClient() {
+ return self.clients.getAll().then(function(clients) {
+ client = clients[0];
+ });
+}
+
+function testWithClick() {
+ var notification = new Notification('My Notification');
+ notification.addEventListener('show', function() {
+ client.postMessage('click');
+ });
+
+ notification.addEventListener('click', function() {
+ client.focus().catch(function() {
+ client.postMessage('focus() outside of a notificationclick failed');
+ client.postMessage('quit');
+ });
+ });
+
+ notification.addEventListener('error', function() {
+ client.postMessage('quit');
+ });
+
+ client.postMessage('quit');
+}
+
+function testWithNoClick() {
+ client.focus().catch(function() {
+ client.postMessage('focus() outside of a notificationclick failed');
+ testWithClick();
+ });
+}
+
+self.onmessage = function(e) {
+ switch(e.data) {
+ case "start":
+ initializeClient().then(testWithNoClick);
+ break;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698