Skip to content

Commit

Permalink
Data URL after redirection are expected to fail (#3769)
Browse files Browse the repository at this point in the history
  • Loading branch information
youennf authored and jdm committed Sep 20, 2016
1 parent e1c9885 commit feeb96c
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions fetch/api/redirect/redirect-to-dataurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,24 @@ var dataURL = "data:text/plain;base64,cmVzcG9uc2UncyBib2R5";
var body = "response's body";
var contentType = "text/plain";

function redirectDataURL(desc, redirectUrl, mode, isOK) {
function redirectDataURL(desc, redirectUrl, mode) {
var url = redirectUrl + "?cors&location=" + encodeURIComponent(dataURL);

var requestInit = {"mode": mode};

promise_test(function(test) {
var promise = fetch(url, requestInit).then(function(response) {
assert_equals(response.type, "opaque", "Response's type should be opaque");
assert_equals(response.url, "", "Response URL is empty");
assert_equals(response.status, 0, "Response's status should be 0");
});
return isOK ? promise : promise_rejects(test, new TypeError(), promise);
return promise_rejects(test, new TypeError(), fetch(url, requestInit));
}, desc);
}

var redirUrl = get_host_info().HTTP_ORIGIN + "/fetch/api/resources/redirect.py";
var corsRedirUrl = get_host_info().HTTP_REMOTE_ORIGIN + "/fetch/api/resources/redirect.py";

redirectDataURL("Testing data URL loading after same-origin redirection (cors mode)", redirUrl, "cors", false);
redirectDataURL("Testing data URL loading after same-origin redirection (no-cors mode)", redirUrl, "no-cors", true);
redirectDataURL("Testing data URL loading after same-origin redirection (same-origin mode)", redirUrl, "same-origin", false);
redirectDataURL("Testing data URL loading after same-origin redirection (cors mode)", redirUrl, "cors");
redirectDataURL("Testing data URL loading after same-origin redirection (no-cors mode)", redirUrl, "no-cors");
redirectDataURL("Testing data URL loading after same-origin redirection (same-origin mode)", redirUrl, "same-origin");

redirectDataURL("Testing data URL loading after cross-origin redirection (cors mode)", corsRedirUrl, "cors", false);
redirectDataURL("Testing data URL loading after cross-origin redirection (no-cors mode)", corsRedirUrl, "no-cors", true);
redirectDataURL("Testing data URL loading after cross-origin redirection (cors mode)", corsRedirUrl, "cors");
redirectDataURL("Testing data URL loading after cross-origin redirection (no-cors mode)", corsRedirUrl, "no-cors");

done();

0 comments on commit feeb96c

Please sign in to comment.