Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: LayoutTests/http/tests/fetch/resources/fetch-test-helpers.js

Issue 921673003: [Fetch] Split layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/fetch/script-tests/block-mixed-content.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/fetch/resources/fetch-test-helpers.js
diff --git a/LayoutTests/http/tests/fetch/resources/fetch-test-helpers.js b/LayoutTests/http/tests/fetch/resources/fetch-test-helpers.js
index 4958ac0c0afd5af7c798a2bf1e5ed35357c70f70..9664a0150f79f624db3bd02213f77ad8b62ddb48 100644
--- a/LayoutTests/http/tests/fetch/resources/fetch-test-helpers.js
+++ b/LayoutTests/http/tests/fetch/resources/fetch-test-helpers.js
@@ -126,3 +126,68 @@ var VALID_REASON_PHRASE = [
// Valid strings.
'', '0123456789', '404 Not Found', 'HTTP/1.1 404 Not Found', 'AZ\u00ffaz',
'x'.repeat(100000)];
+
+function testBlockMixedContent(mode) {
+ promise_test(function(t) {
+ return Promise.resolve()
+ .then(function() {
+ // Test 1: Must fail: blocked as mixed content.
+ return fetch(BASE_URL + 'test1-' + mode, {mode: mode})
+ .then(t.unreached_func('Test 1: Must be blocked (' +
+ mode + ', HTTPS->HTTP)'),
+ function() {});
+ })
+ .then(function() {
+ // Block mixed content in redirects.
+ // Test 2: Must fail: original fetch is not blocked but
+ // redirect is blocked.
+ return fetch(HTTPS_REDIRECT_URL +
+ encodeURIComponent(BASE_URL + 'test2-' + mode),
+ {mode: mode})
+ .then(t.unreached_func('Test 2: Must be blocked (' +
+ mode + ', HTTPS->HTTPS->HTTP)'),
+ function() {});
+ })
+ .then(function() {
+ // Test 3: Must fail: original fetch is blocked.
+ return fetch(REDIRECT_URL +
+ encodeURIComponent(HTTPS_BASE_URL + 'test3-' + mode),
+ {mode: mode})
+ .then(t.unreached_func('Test 3: Must be blocked (' +
+ mode + ', HTTPS->HTTP->HTTPS)'),
+ function() {});
+ })
+ .then(function() {
+ // Test 4: Must success.
+ // Test that the mixed contents above are not rejected due to
+ return fetch(HTTPS_REDIRECT_URL +
+ encodeURIComponent(HTTPS_BASE_URL + 'test4-' + mode),
+ {mode: mode})
+ .then(function(res) {assert_equals(res.status, 200); },
+ t.unreached_func('Test 4: Must success (' +
+ mode + ', HTTPS->HTTPS->HTTPS)'));
+ })
+ .then(function() {
+ // 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 + ')');
+}
« no previous file with comments | « no previous file | LayoutTests/http/tests/fetch/script-tests/block-mixed-content.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698