mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1442425 [wpt PR 9331] - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=181491, a=testonly
Automatic update from web-platform-tests WebKit export of https://bugs.webkit.org/show_bug.cgi?id=181491 Redirected iframe loading with Request.redirect=follow should fail <!-- Reviewable:start --> <!-- Reviewable:end --> wpt-commits: 87cc1e45631c18289d988d205b2243168261cb88 wpt-pr: 9331 reapplied-commits: 370e267e160568862f1fd9ec246ab5bb840f586e, fe4514c84e7ad28e46bad5da93381deb99b177f3, 7806af854343c043a2645a4034fdc7812f65daad, 9ddfd21554293dec5a4bf2e5375ae4f3c9f2ded0, 75f63c4d1ebc949647184fd60972fc7b9fd4affb, 1f3a5b496acd2288cc8cf0c32af86cb35157ea4e, 88b42bd5847abac58a62c4d6b33c1509bfce5f3d, 15c2e4c690700c6c115f8afe5e44ded10d943538, c8d461ef1437641ae7d4ea1d21e1e60cd62910b0, a6088a5f48ee299386a84d2f771902267d7355b1, 0634cd8f08ebe0905a9188fb1398c7b5f889c5dc, c8ee4a012dae506ae06bb5b2ad50942b04c1aaaa, c2c352456a4cf62dcc12f851138b04397675a445, b93a8879555d2fa7e7d4e00a275513a3a6338b35, b86e1331cb36634fd33677043b61fc0c1d8485bc, 44ddf14fd3346658c3223f13652073fafbfa48fa, a1a5840a6bb53e305ba02bcbeb215659342d0edb, 7465cb110ae5ec2e2ca73182caf5293f0efc8fd5, aad5349b3458bc3414e274b33fa86a1123901ff2, eca0907980d2769c449894a6277c60c1a306792f, 38626987c0cfd6e715cfcc6f4f1a1209191a03c5, e4a67f7ddcde6cd99348e9104bd7ed07074da44a, bb3c9990840a0fae2afc840b5952d7874785b112, 042d7adef0bdb9dc80e825c3997ace7519477c42, 99f1ea44fc7915b8b7b33bce4732fa8765fd3ac2
This commit is contained in:
parent
45359f169c
commit
4df02537e2
@ -583651,7 +583651,7 @@
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/fetch-request-redirect.https.html": [
|
||||
"e1ea127e72573e97a4d175c1780bfaae6f537972",
|
||||
"d9df49b76012233e0aeb92f50a0613f90e8b3ee1",
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/fetch-request-resources.https.html": [
|
||||
|
@ -4,19 +4,22 @@
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<script src="/common/media.js"></script>
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
|
||||
var test_scope = ""
|
||||
function assert_resolves(promise, description) {
|
||||
return promise.catch(function(reason) {
|
||||
throw new Error(description + ' - ' + reason.message);
|
||||
});
|
||||
return promise.then(
|
||||
() => test(() => {}, description + " - " + test_scope),
|
||||
(e) => test(() => { throw e; }, description + " - " + test_scope)
|
||||
);
|
||||
}
|
||||
|
||||
function assert_rejects(promise, description) {
|
||||
return promise.then(
|
||||
function() { throw new Error(description); },
|
||||
function() {});
|
||||
return promise.then(
|
||||
() => test(() => { assert_unreached(); }, description + " - " + test_scope),
|
||||
() => test(() => {}, description + " - " + test_scope)
|
||||
);
|
||||
}
|
||||
|
||||
function iframe_test(url, timeout_enabled) {
|
||||
@ -52,11 +55,13 @@ function iframe_test(url, timeout_enabled) {
|
||||
}
|
||||
|
||||
promise_test(function(t) {
|
||||
test_scope = "default";
|
||||
|
||||
var SCOPE = 'resources/fetch-request-redirect-iframe.html';
|
||||
var SCRIPT = 'resources/fetch-rewrite-worker.js';
|
||||
var REDIRECT_URL = base_path() + 'resources/redirect.py?Redirect=';
|
||||
var IMAGE_URL = base_path() + 'resources/square.png';
|
||||
var AUDIO_URL = base_path() + 'resources/silence.oga';
|
||||
var AUDIO_URL = getAudioURI("/media/sound_5");
|
||||
var XHR_URL = base_path() + 'resources/simple.txt';
|
||||
var HTML_URL = base_path() + 'resources/dummy.html';
|
||||
|
||||
@ -73,108 +78,106 @@ promise_test(function(t) {
|
||||
return wait_for_state(t, worker, 'activated');
|
||||
})
|
||||
.then(function() { return with_iframe(SCOPE); })
|
||||
.then(function(f) {
|
||||
frame = f;
|
||||
return Promise.all([
|
||||
.then(async function(f) {
|
||||
frame = f;
|
||||
// XMLHttpRequest tests.
|
||||
assert_resolves(frame.contentWindow.xhr(XHR_URL),
|
||||
'Normal XHR should succeed.'),
|
||||
assert_resolves(frame.contentWindow.xhr(REDIRECT_TO_XHR_URL),
|
||||
'Redirected XHR should succeed.'),
|
||||
assert_resolves(
|
||||
await assert_resolves(frame.contentWindow.xhr(XHR_URL),
|
||||
'Normal XHR should succeed.');
|
||||
await assert_resolves(frame.contentWindow.xhr(REDIRECT_TO_XHR_URL),
|
||||
'Redirected XHR should succeed.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&redirect-mode=follow'),
|
||||
'Redirected XHR with Request.redirect=follow should succeed.'),
|
||||
assert_rejects(
|
||||
'Redirected XHR with Request.redirect=follow should succeed.');
|
||||
await assert_rejects(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&redirect-mode=error'),
|
||||
'Redirected XHR with Request.redirect=error should fail.'),
|
||||
assert_rejects(
|
||||
'Redirected XHR with Request.redirect=error should fail.');
|
||||
await assert_rejects(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&redirect-mode=manual'),
|
||||
'Redirected XHR with Request.redirect=manual should fail.'),
|
||||
'Redirected XHR with Request.redirect=manual should fail.');
|
||||
|
||||
// Image loading tests.
|
||||
assert_resolves(frame.contentWindow.load_image(IMAGE_URL),
|
||||
'Normal image resource should be loaded.'),
|
||||
assert_resolves(
|
||||
await assert_resolves(frame.contentWindow.load_image(IMAGE_URL),
|
||||
'Normal image resource should be loaded.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.load_image(REDIRECT_TO_IMAGE_URL),
|
||||
'Redirected image resource should be loaded.'),
|
||||
assert_resolves(
|
||||
'Redirected image resource should be loaded.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.load_image(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_IMAGE_URL) +
|
||||
'&redirect-mode=follow'),
|
||||
'Loading redirected image with Request.redirect=follow should' +
|
||||
' succeed.'),
|
||||
assert_rejects(
|
||||
' succeed.');
|
||||
await assert_rejects(
|
||||
frame.contentWindow.load_image(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_IMAGE_URL) +
|
||||
'&redirect-mode=error'),
|
||||
'Loading redirected image with Request.redirect=error should ' +
|
||||
'fail.'),
|
||||
assert_rejects(
|
||||
'fail.');
|
||||
await assert_rejects(
|
||||
frame.contentWindow.load_image(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_IMAGE_URL) +
|
||||
'&redirect-mode=manual'),
|
||||
'Loading redirected image with Request.redirect=manual should' +
|
||||
' fail.'),
|
||||
' fail.');
|
||||
|
||||
// Audio loading tests.
|
||||
assert_resolves(frame.contentWindow.load_audio(AUDIO_URL),
|
||||
'Normal audio resource should be loaded.'),
|
||||
assert_resolves(
|
||||
await assert_resolves(frame.contentWindow.load_audio(AUDIO_URL),
|
||||
'Normal audio resource should be loaded.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.load_audio(REDIRECT_TO_AUDIO_URL),
|
||||
'Redirected audio resource should be loaded.'),
|
||||
assert_resolves(
|
||||
'Redirected audio resource should be loaded.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.load_audio(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_AUDIO_URL) +
|
||||
'&redirect-mode=follow'),
|
||||
'Loading redirected audio with Request.redirect=follow should' +
|
||||
' succeed.'),
|
||||
assert_rejects(
|
||||
' succeed.');
|
||||
await assert_rejects(
|
||||
frame.contentWindow.load_audio(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_AUDIO_URL) +
|
||||
'&redirect-mode=error'),
|
||||
'Loading redirected audio with Request.redirect=error should ' +
|
||||
'fail.'),
|
||||
assert_rejects(
|
||||
'fail.');
|
||||
await assert_rejects(
|
||||
frame.contentWindow.load_audio(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_AUDIO_URL) +
|
||||
'&redirect-mode=manual'),
|
||||
'Loading redirected audio with Request.redirect=manual should' +
|
||||
' fail.'),
|
||||
' fail.');
|
||||
|
||||
// Iframe tests.
|
||||
assert_resolves(iframe_test(HTML_URL),
|
||||
'Normal iframe loading should succeed.'),
|
||||
assert_resolves(
|
||||
await assert_resolves(iframe_test(HTML_URL),
|
||||
'Normal iframe loading should succeed.');
|
||||
await assert_resolves(
|
||||
iframe_test(REDIRECT_TO_HTML_URL),
|
||||
'Normal redirected iframe loading should succeed.'),
|
||||
assert_rejects(
|
||||
'Normal redirected iframe loading should succeed.');
|
||||
await assert_rejects(
|
||||
iframe_test(SCOPE + '?url=' +
|
||||
encodeURIComponent(REDIRECT_TO_HTML_URL) +
|
||||
'&redirect-mode=follow',
|
||||
true /* timeout_enabled */),
|
||||
'Redirected iframe loading with Request.redirect=follow should'+
|
||||
' fail.'),
|
||||
assert_rejects(
|
||||
' fail.');
|
||||
await assert_rejects(
|
||||
iframe_test(SCOPE + '?url=' +
|
||||
encodeURIComponent(REDIRECT_TO_HTML_URL) +
|
||||
'&redirect-mode=error',
|
||||
true /* timeout_enabled */),
|
||||
'Redirected iframe loading with Request.redirect=error should '+
|
||||
'fail.'),
|
||||
assert_resolves(
|
||||
'fail.');
|
||||
await assert_resolves(
|
||||
iframe_test(SCOPE + '?url=' +
|
||||
encodeURIComponent(REDIRECT_TO_HTML_URL) +
|
||||
'&redirect-mode=manual',
|
||||
true /* timeout_enabled */),
|
||||
'Redirected iframe loading with Request.redirect=manual should'+
|
||||
' succeed.'),
|
||||
]);
|
||||
' succeed.');
|
||||
})
|
||||
.then(function() {
|
||||
frame.remove();
|
||||
@ -184,6 +187,8 @@ promise_test(function(t) {
|
||||
|
||||
// test for reponse.redirected
|
||||
promise_test(function(t) {
|
||||
test_scope = "redirected";
|
||||
|
||||
var SCOPE = 'resources/fetch-request-redirect-iframe.html';
|
||||
var SCRIPT = 'resources/fetch-rewrite-worker.js';
|
||||
var REDIRECT_URL = base_path() + 'resources/redirect.py?Redirect=';
|
||||
@ -207,35 +212,34 @@ promise_test(function(t) {
|
||||
return wait_for_state(t, worker, 'activated');
|
||||
})
|
||||
.then(function() { return with_iframe(SCOPE); })
|
||||
.then(function(f) {
|
||||
.then(async function(f) {
|
||||
frame = f;
|
||||
return Promise.all([
|
||||
// XMLHttpRequest tests.
|
||||
assert_resolves(
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(XHR_URL) +
|
||||
'&expected_redirected=false' +
|
||||
'&expected_resolves=true'),
|
||||
'Normal XHR should be resolved and response should not be ' +
|
||||
'redirected.'),
|
||||
assert_resolves(
|
||||
'redirected.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&expected_redirected=true' +
|
||||
'&expected_resolves=true'),
|
||||
'Redirected XHR should be resolved and response should be ' +
|
||||
'redirected.'),
|
||||
'redirected.');
|
||||
|
||||
// tests for request's mode = cors
|
||||
assert_resolves(
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(XHR_URL) +
|
||||
'&mode=cors' +
|
||||
'&expected_redirected=false' +
|
||||
'&expected_resolves=true'),
|
||||
'Normal XHR should be resolved and response should not be ' +
|
||||
'redirected even with CORS mode.'),
|
||||
assert_resolves(
|
||||
'redirected even with CORS mode.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&mode=cors' +
|
||||
@ -243,12 +247,12 @@ promise_test(function(t) {
|
||||
'&expected_redirected=true' +
|
||||
'&expected_resolves=true'),
|
||||
'Redirected XHR should be resolved and response.redirected ' +
|
||||
'should be redirected with CORS mode.'),
|
||||
'should be redirected with CORS mode.');
|
||||
|
||||
// tests for request's mode = no-cors
|
||||
// The response.redirect should be false since we will not add
|
||||
// redirected url list when redirect-mode is not follow.
|
||||
assert_rejects(
|
||||
await assert_rejects(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&mode=no-cors' +
|
||||
@ -256,19 +260,18 @@ promise_test(function(t) {
|
||||
'&expected_redirected=false' +
|
||||
'&expected_resolves=false'),
|
||||
'Redirected XHR should be reject and response should be ' +
|
||||
'redirected with NO-CORS mode and redirect-mode=manual.'),
|
||||
'redirected with NO-CORS mode and redirect-mode=manual.');
|
||||
|
||||
// tests for redirecting to a cors
|
||||
assert_resolves(
|
||||
await assert_resolves(
|
||||
frame.contentWindow.load_image(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_CROSS_ORIGIN) +
|
||||
'&mode=no-cors' +
|
||||
'&redirect-mode=follow' +
|
||||
'&expected_redirected=false' +
|
||||
'&expected_resolves=true'),
|
||||
'Redirected COS image should be reject and response should ' +
|
||||
'not be redirected with NO-CORS mode.'),
|
||||
]);
|
||||
'Redirected CORS image should be reject and response should ' +
|
||||
'not be redirected with NO-CORS mode.');
|
||||
})
|
||||
.then(function() {
|
||||
frame.remove();
|
||||
@ -278,6 +281,8 @@ promise_test(function(t) {
|
||||
|
||||
// test for reponse.redirected after cached
|
||||
promise_test(function(t) {
|
||||
test_scope = "cache";
|
||||
|
||||
var SCOPE = 'resources/fetch-request-redirect-iframe.html';
|
||||
var SCRIPT = 'resources/fetch-rewrite-worker.js';
|
||||
var REDIRECT_URL = base_path() + 'resources/redirect.py?Redirect=';
|
||||
@ -301,29 +306,28 @@ promise_test(function(t) {
|
||||
return wait_for_state(t, worker, 'activated');
|
||||
})
|
||||
.then(function() { return with_iframe(SCOPE); })
|
||||
.then(function(f) {
|
||||
.then(async function(f) {
|
||||
frame = f;
|
||||
return Promise.all([
|
||||
// XMLHttpRequest tests.
|
||||
assert_resolves(
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(XHR_URL) +
|
||||
'&expected_redirected=false' +
|
||||
'&expected_resolves=true' +
|
||||
'&cache'),
|
||||
'Normal XHR should be resolved and response should not be ' +
|
||||
'redirected.'),
|
||||
assert_resolves(
|
||||
'redirected.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&expected_redirected=true' +
|
||||
'&expected_resolves=true' +
|
||||
'&cache'),
|
||||
'Redirected XHR should be resolved and response should be ' +
|
||||
'redirected.'),
|
||||
'redirected.');
|
||||
|
||||
// tests for request's mode = cors
|
||||
assert_resolves(
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(XHR_URL) +
|
||||
'&mode=cors' +
|
||||
@ -331,8 +335,8 @@ promise_test(function(t) {
|
||||
'&expected_resolves=true' +
|
||||
'&cache'),
|
||||
'Normal XHR should be resolved and response should not be ' +
|
||||
'redirected even with CORS mode.'),
|
||||
assert_resolves(
|
||||
'redirected even with CORS mode.');
|
||||
await assert_resolves(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&mode=cors' +
|
||||
@ -341,12 +345,12 @@ promise_test(function(t) {
|
||||
'&expected_resolves=true' +
|
||||
'&cache'),
|
||||
'Redirected XHR should be resolved and response.redirected ' +
|
||||
'should be redirected with CORS mode.'),
|
||||
'should be redirected with CORS mode.');
|
||||
|
||||
// tests for request's mode = no-cors
|
||||
// The response.redirect should be false since we will not add
|
||||
// redirected url list when redirect-mode is not follow.
|
||||
assert_rejects(
|
||||
await assert_rejects(
|
||||
frame.contentWindow.xhr(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_XHR_URL) +
|
||||
'&mode=no-cors' +
|
||||
@ -355,10 +359,10 @@ promise_test(function(t) {
|
||||
'&expected_resolves=false' +
|
||||
'&cache'),
|
||||
'Redirected XHR should be reject and response should be ' +
|
||||
'redirected with NO-CORS mode and redirect-mode=manual.'),
|
||||
'redirected with NO-CORS mode and redirect-mode=manual.');
|
||||
|
||||
// tests for redirecting to a cors
|
||||
assert_resolves(
|
||||
await assert_resolves(
|
||||
frame.contentWindow.load_image(
|
||||
'./?url=' + encodeURIComponent(REDIRECT_TO_CROSS_ORIGIN) +
|
||||
'&mode=no-cors' +
|
||||
@ -366,9 +370,8 @@ promise_test(function(t) {
|
||||
'&expected_redirected=false' +
|
||||
'&expected_resolves=true' +
|
||||
'&cache'),
|
||||
'Redirected COS image should be reject and response should ' +
|
||||
'not be redirected with NO-CORS mode.'),
|
||||
]);
|
||||
'Redirected CORS image should be reject and response should ' +
|
||||
'not be redirected with NO-CORS mode.');
|
||||
})
|
||||
.then(function() {
|
||||
frame.remove();
|
||||
|
Loading…
Reference in New Issue
Block a user