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
self.addEventListener('fetch', evt => { | |
// Fallback for subresource requests or in browsers that do not | |
// support navigation preload. | |
if (evt.request.mode !== "navigate" || !evt.preloadResponse) | |
return; | |
evt.respondWith(async _ => { | |
// Try to get the navigation preload response. | |
let r = await evt.preloadResponse; | |
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
// | |
// nsILoadInfo.idl | |
// | |
interface nsILoadInfo | |
{ | |
// CSP data that was parsed from the LoadInfo's channel. This is purely | |
// for communicating the value back to the client that triggered the | |
// load. This should only be set for non-subresource loads. This | |
// should not be used for enforcing CSP on subresource loads. Instead | |
// use GetClientInfo() and the CSP value there. |
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
<!DOCTYPE html> | |
<html> | |
<script> | |
// self.bar === 'foobar' | |
</script> | |
</html> |
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
self.skipWaiting(); | |
addEventListener('fetch', evt => { | |
evt.respondWith(async function() { | |
try { | |
let response = await fetch(evt.request); | |
console.log(`==> SUCCESS for url:${evt.request.url} integity:${evt.request.integrity}`); | |
return response; | |
} catch(e) { | |
console.log(`==> FAILURE for url:${evt.request.url} integity:${evt.request.integrity}`); |
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
let headers = new Headers(); | |
headers.append('X-Food', 'Candy Corn'); | |
headers.append('X-Drink', 'Cider'); | |
let request = new Request('/order.html'); | |
autoHeaders.put(request, headers); |
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
void | |
AssertAndSuppressCleanupFunc(ErrorResult* aRv) | |
{ | |
aRv->AssertReportedOrSuppressed(); | |
aRv->SuppressException(); | |
} | |
template <typename CleanupFunc = AssertAndSuppressCleanupFunc> | |
class ErrorResult | |
{ |
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
<html> | |
<body> | |
<script> | |
var s = document.createElement('script'); | |
s.src = 'data:text/javascript,console.log("data URI baseURI: " + document.currentScript.baseURI);' | |
document.body.appendChild(s); | |
console.log('### ### script with ' + s.src); | |
</script> | |
</body> | |
</html> |
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
<html> | |
<head></head> | |
<body> | |
<script> | |
navigator.serviceWorker.addEventListener('message', function(evt) { | |
if (evt.data === 'CALL ME') { | |
navigator.serviceWorker.controller.postMessage('RING RING'); | |
} | |
}); | |
navigator.serviceWorker.register('sw.js'); |
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
myStream.read(function handleChunk(chunk) { | |
if (!chunk) { | |
processDone(); | |
return; | |
} | |
processChunk(chunk); | |
myStream.read(handleChunk); | |
}); |
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
var req = new Request('https://example.com' { bodyAsWriter: true }); | |
// throws because writer is not set yet | |
req.bodyWriter.write(/*...*/); | |
// fetch calls setWriter | |
fetch(req).then(/*...*/); | |
req.bodyWriter.write(/*...*/) |
NewerOlder