Skip to content

Instantly share code, notes, and snippets.

@nikhilm
Created May 19, 2015 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhilm/8ed1b5f4cc69a70b73f4 to your computer and use it in GitHub Desktop.
Save nikhilm/8ed1b5f4cc69a70b73f4 to your computer and use it in GitHub Desktop.
fetch crash
// Does not handle fetch event.
<html>
<body>
Hi there
<script language="javascript">
if (navigator.serviceWorker.controller) {
var fd = new FormData();
fd.append("username", "foo");
fd.append("endpoint", "http://push-here");
var xhr = new XMLHttpRequest();
xhr.open("POST", "/fakeapp");
xhr.send(fd);
} else {
navigator.serviceWorker.register("sw.js", {scope:"."})
.then(function(reg) { console.log("Succeeded", reg); })
.catch(function(e) { console.log("Error", e); });
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment