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

Side by Side Diff: chrome/test/data/banners/main.js

Issue 2942513002: Allow banners to trigger on sites which don't register a service worker onload. (Closed)
Patch Set: Fix crashing Android test. Comments Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function initialize() { 5 function initialize() {
6 navigator.serviceWorker.register('service_worker.js'); 6 navigator.serviceWorker.register('service_worker.js');
7 7
8 window.addEventListener('appinstalled', () => { 8 window.addEventListener('appinstalled', () => {
9 window.document.title = 'Got appinstalled'; 9 window.document.title = 'Got appinstalled';
10 }); 10 });
11 } 11 }
12 12
13 function addManifestLinkTag() { 13 function addManifestLinkTag() {
14 var url = window.location.href; 14 var url = window.location.href;
15 var manifestIndex = url.indexOf("?manifest="); 15 var manifestIndex = url.indexOf("?manifest=");
16 var manifestUrl = 16 var manifestUrl =
17 (manifestIndex >= 0) ? url.slice(manifestIndex + 10) : 'manifest.json'; 17 (manifestIndex >= 0) ? url.slice(manifestIndex + 10) : 'manifest.json';
18 var linkTag = document.createElement("link"); 18 var linkTag = document.createElement("link");
19 linkTag.rel = "manifest"; 19 linkTag.rel = "manifest";
20 linkTag.href = manifestUrl; 20 linkTag.href = manifestUrl;
21 document.head.append(linkTag); 21 document.head.append(linkTag);
22 } 22 }
23
24 function getSwDelay() {
25 // Allow the test page to set a custom delay (required since desktop is
26 // faster than Android and hence needs a longer delay).
27 var url = window.location.href;
28 var swDelayIndex = url.indexOf("?swdelay=");
29 return (swDelayIndex >= 0) ? url.slice(swDelayIndex + 9) : 300;
30 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698