Commit 4d4cfc11 authored by yhirano's avatar yhirano Committed by Commit bot

Split a mixed-content promise test into separate ones.

BUG=None

Review-Url: https://codereview.chromium.org/2543643006
Cr-Commit-Position: refs/heads/master@{#443153}
parent aae2a1b1
...@@ -152,68 +152,48 @@ function size(headers) { ...@@ -152,68 +152,48 @@ function size(headers) {
} }
function testBlockMixedContent(mode) { function testBlockMixedContent(mode) {
promise_test(function(t) { promise_test(t => {
return Promise.resolve() // Must fail: blocked as mixed content.
.then(function() { return fetch(BASE_URL + 'test1-' + mode, {mode: mode})
// Test 1: Must fail: blocked as mixed content. .then(unreached_fulfillment(t), () => {});
return fetch(BASE_URL + 'test1-' + mode, {mode: mode}) }, `Mixed content fetch (${mode}, HTTPS->HTTP)`);
.then(t.unreached_func('Test 1: Must be blocked (' +
mode + ', HTTPS->HTTP)'), promise_test(t => {
function() {}); // Must fail: original fetch is not blocked but redirect is blocked.
}) return fetch(HTTPS_REDIRECT_URL +
.then(function() { encodeURIComponent(BASE_URL + 'test2-' + mode), {mode: mode})
// Block mixed content in redirects. .then(unreached_fulfillment(t), () => {});
// Test 2: Must fail: original fetch is not blocked but }, `Mixed content redirect (${mode}, HTTPS->HTTPS->HTTP)`);
// redirect is blocked.
return fetch(HTTPS_REDIRECT_URL + promise_test(t => {
encodeURIComponent(BASE_URL + 'test2-' + mode), // Must fail: original fetch is blocked.
{mode: mode}) return fetch(REDIRECT_URL +
.then(t.unreached_func('Test 2: Must be blocked (' + encodeURIComponent(HTTPS_BASE_URL + 'test3-' + mode),
mode + ', HTTPS->HTTPS->HTTP)'), {mode: mode}).then(unreached_fulfillment(t), () => {});
function() {}); }, `Mixed content redirect ${mode}, HTTPS->HTTP->HTTPS)`);
})
.then(function() { promise_test(() => {
// Test 3: Must fail: original fetch is blocked. // Must success.
return fetch(REDIRECT_URL + // Test that the mixed contents above are not rejected due to CORS check.
encodeURIComponent(HTTPS_BASE_URL + 'test3-' + mode), return fetch(HTTPS_REDIRECT_URL +
{mode: mode}) encodeURIComponent(HTTPS_BASE_URL + 'test4-' + mode),
.then(t.unreached_func('Test 3: Must be blocked (' + {mode: mode}).then(res => {
mode + ', HTTPS->HTTP->HTTPS)'), assert_equals(res.status, mode === 'no-cors' ? 0 : 200);
function() {}); });
}) }, `Same origin redirect (${mode}, HTTPS->HTTPS->HTTPS)`);
.then(function() {
// Test 4: Must success. promise_test(() => {
// Test that the mixed contents above are not rejected due to // Must success if mode is not 'same-origin'.
return fetch(HTTPS_REDIRECT_URL + // Test that the mixed contents above are not rejected due to CORS check.
encodeURIComponent(HTTPS_BASE_URL + 'test4-' + mode), return fetch(HTTPS_OTHER_REDIRECT_URL +
{mode: mode}) encodeURIComponent(HTTPS_BASE_URL + 'test5-' + mode),
.then(function(res) {assert_equals(res.status, mode == 'no-cors' ? 0 : 200); }, {mode: mode})
t.unreached_func('Test 4: Must success (' + .then(res => {
mode + ', HTTPS->HTTPS->HTTPS)')); assert_not_equals(mode, 'same-origin');
}) }, () => {
.then(function() { assert_equals(mode, 'same-origin');
// Test 5: Must success if mode is not 'same-origin'.
// Test that the mixed contents above are not rejected due to
// CORS check.
return fetch(HTTPS_OTHER_REDIRECT_URL +
encodeURIComponent(HTTPS_BASE_URL + 'test5-' + mode),
{mode: mode})
.then(function(res) {
if (mode === 'same-origin') {
assert_unreached(
'Test 5: Cross-origin HTTPS request must fail: ' +
'mode = ' + mode);
}
},
function() {
if (mode !== 'same-origin') {
assert_unreached(
'Test 5: Cross-origin HTTPS request must success: ' +
'mode = ' + mode);
}
});
}); });
}, 'Block fetch() as mixed content (' + mode + ')'); }, `Cross origin redirect (${mode}, HTTPS->HTTPS->HTTPS`);
} }
function add_referrer_tests(tests, global) { function add_referrer_tests(tests, global) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment