mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1182120 - Test XMLDocument.load() with fetch interception. r=bkelly
This commit is contained in:
parent
7af5261b56
commit
6866b9f227
@ -117,6 +117,33 @@
|
|||||||
my_ok(this.test_result, "iframe load should be intercepted");
|
my_ok(this.test_result, "iframe load should be intercepted");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gExpected++;
|
||||||
|
var xmlDoc = document.implementation.createDocument(null, null, null);
|
||||||
|
xmlDoc.load('load_cross_origin_xml_document_synthetic.xml');
|
||||||
|
xmlDoc.onload = function(evt) {
|
||||||
|
var content = new XMLSerializer().serializeToString(evt.target);
|
||||||
|
my_ok(!content.includes('parsererror'), "Load synthetic cross origin XML Document should be allowed");
|
||||||
|
finish();
|
||||||
|
};
|
||||||
|
|
||||||
|
gExpected++;
|
||||||
|
var xmlDoc = document.implementation.createDocument(null, null, null);
|
||||||
|
xmlDoc.load('load_cross_origin_xml_document_cors.xml');
|
||||||
|
xmlDoc.onload = function(evt) {
|
||||||
|
var content = new XMLSerializer().serializeToString(evt.target);
|
||||||
|
my_ok(!content.includes('parsererror'), "Load CORS cross origin XML Document should be allowed");
|
||||||
|
finish();
|
||||||
|
};
|
||||||
|
|
||||||
|
gExpected++;
|
||||||
|
var xmlDoc = document.implementation.createDocument(null, null, null);
|
||||||
|
xmlDoc.load('load_cross_origin_xml_document_opaque.xml');
|
||||||
|
xmlDoc.onload = function(evt) {
|
||||||
|
var content = new XMLSerializer().serializeToString(evt.target);
|
||||||
|
my_ok(content.includes('parsererror'), "Load opaque cross origin XML Document should not be allowed");
|
||||||
|
finish();
|
||||||
|
};
|
||||||
|
|
||||||
gExpected++;
|
gExpected++;
|
||||||
var worker = new Worker('nonexistent_worker_script.js');
|
var worker = new Worker('nonexistent_worker_script.js');
|
||||||
worker.onmessage = function(e) {
|
worker.onmessage = function(e) {
|
||||||
|
@ -235,4 +235,37 @@ onfetch = function(ev) {
|
|||||||
// fetch was initiated from a SW.
|
// fetch was initiated from a SW.
|
||||||
ev.respondWith(fetch('redirect_serviceworker.sjs'));
|
ev.respondWith(fetch('redirect_serviceworker.sjs'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (ev.request.url.includes('load_cross_origin_xml_document_synthetic.xml')) {
|
||||||
|
if (ev.request.mode != 'same-origin') {
|
||||||
|
ev.respondWith(Promise.reject());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ev.respondWith(Promise.resolve(
|
||||||
|
new Response("<response>body</response>", { headers: {'Content-Type': 'text/xtml'}})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (ev.request.url.includes('load_cross_origin_xml_document_cors.xml')) {
|
||||||
|
if (ev.request.mode != 'same-origin') {
|
||||||
|
ev.respondWith(Promise.reject());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = 'http://example.com/tests/dom/security/test/cors/file_CrossSiteXHR_server.sjs?status=200&allowOrigin=*';
|
||||||
|
ev.respondWith(fetch(url, { mode: 'cors' }));
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (ev.request.url.includes('load_cross_origin_xml_document_opaque.xml')) {
|
||||||
|
if (ev.request.mode != 'same-origin') {
|
||||||
|
Promise.resolve(
|
||||||
|
new Response("<error>Invalid Request mode</error>", { headers: {'Content-Type': 'text/xtml'}})
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = 'http://example.com/tests/dom/security/test/cors/file_CrossSiteXHR_server.sjs?status=200';
|
||||||
|
ev.respondWith(fetch(url, { mode: 'no-cors' }));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user