This repository has been archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from PolymerElements/fix-flaky-test
Don't run tests until the page is under SW control
- Loading branch information
Showing
5 changed files
with
30 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Provides an equivalent to navigator.serviceWorker.ready that waits for the page to be controlled, | ||
// as opposed to waiting for the active service worker. | ||
// See https://github.com/slightlyoff/ServiceWorker/issues/799 | ||
window._controlledPromise = new Promise(function(resolve) { | ||
// Resolve with the registration, to match the .ready promise's behavior. | ||
var resolveWithRegistration = function() { | ||
navigator.serviceWorker.getRegistration().then(function(registration) { | ||
resolve(registration); | ||
}); | ||
}; | ||
|
||
if (navigator.serviceWorker.controller) { | ||
resolveWithRegistration(); | ||
} else { | ||
navigator.serviceWorker.addEventListener('controllerchange', resolveWithRegistration); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters