mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1147699 - Part 11: Add tests for FetchEvent.request.context when intercepting iframes and frames; r=nsm
This commit is contained in:
parent
10f853c059
commit
1853f19f3e
@ -40,6 +40,15 @@ self.addEventListener("fetch", function(event) {
|
||||
respondToServiceWorker(event, "object");
|
||||
} else if (event.request.url.indexOf("font") >= 0) {
|
||||
respondToServiceWorker(event, "font");
|
||||
} else if (event.request.url.indexOf("iframe") >= 0) {
|
||||
if (event.request.context == "iframe") {
|
||||
event.respondWith(fetch("context_test.js"));
|
||||
}
|
||||
} else if (event.request.url.indexOf("frame") >= 0) {
|
||||
// FIXME: Bug 1148044: This should be "frame".
|
||||
if (event.request.context == "iframe") {
|
||||
event.respondWith(fetch("context_test.js"));
|
||||
}
|
||||
}
|
||||
// Fail any request that we don't know about.
|
||||
try {
|
||||
|
@ -158,6 +158,32 @@
|
||||
});
|
||||
}
|
||||
|
||||
function testIFrame() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = "iframe";
|
||||
document.documentElement.appendChild(iframe);
|
||||
// The service worker will respond with an existing document only if the
|
||||
// Request has the correct context, otherwise the Promise will get
|
||||
// rejected and the test will fail.
|
||||
iframe.onload = resolve;
|
||||
iframe.onerror = reject;
|
||||
});
|
||||
}
|
||||
|
||||
function testFrame() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var frame = document.createElement("frame");
|
||||
frame.src = "frame";
|
||||
document.documentElement.appendChild(frame);
|
||||
// The service worker will respond with an existing document only if the
|
||||
// Request has the correct context, otherwise the Promise will get
|
||||
// rejected and the test will fail.
|
||||
frame.onload = resolve;
|
||||
frame.onerror = reject;
|
||||
});
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
testFetch(),
|
||||
testImage(),
|
||||
@ -170,6 +196,8 @@
|
||||
testEmbed(),
|
||||
testObject(),
|
||||
testFont(),
|
||||
testIFrame(),
|
||||
testFrame(),
|
||||
])
|
||||
.then(function() {
|
||||
finish();
|
||||
|
Loading…
Reference in New Issue
Block a user