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

Unified Diff: content/test/data/background_sync/register_sync_sw.js

Issue 1471763003: [BackgroundSync] Only allow SyncManager.register to occur from main frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split
Patch Set: Address comments from PS6 Created 5 years, 1 month 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: content/test/data/background_sync/register_sync_sw.js
diff --git a/content/test/data/background_sync/register_sync_sw.js b/content/test/data/background_sync/register_sync_sw.js
new file mode 100644
index 0000000000000000000000000000000000000000..da7ff4cfc3ea89a961c9338ee0b5ab3d61e447c5
--- /dev/null
+++ b/content/test/data/background_sync/register_sync_sw.js
@@ -0,0 +1,22 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+function sendMessageToClients(message) {
+ clients.matchAll({ includeUncontrolled: true }).then(function(clients) {
+ clients.forEach(function(client) {
+ client.postMessage(message);
+ });
+ });
+}
+
+self.addEventListener('activate', function(event) {
+ registration.sync.register('foo')
+ .then(function () {
+ sendMessageToClients('registration succeeded');
+ }, function(e) {
+ sendMessageToClients('registration failed');
+ });
+});
« no previous file with comments | « content/test/data/background_sync/register_sync.js ('k') | content/test/data/background_sync/service_worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698