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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-static-redirect.html

Issue 2778753002: Import //fetch from Web Platform Tests. (Closed)
Patch Set: Baselines. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Response: redirect static method</title>
6 <meta name="help" href="https://fetch.spec.whatwg.org/#response">
7 <meta name="help" href="https://fetch.spec.whatwg.org/#redirect-status">
8 <meta name="author" title="Canon Research France" href="https://www.crf.cano n.fr">
9 <script src="/resources/testharness.js"></script>
10 <script src="/resources/testharnessreport.js"></script>
11 </head>
12 <body>
13 <script>
14 var url = "http://test.url:1234/";
15 test(function() {
16 redirectResponse = Response.redirect(url);
17 assert_equals(redirectResponse.status, 302, "Default redirect status is 302");
18 assert_equals(redirectResponse.headers.get("Location"), url,
19 "redirected response has Location header with the correct url");
20 }, "Check default redirect response");
21
22 var redirectStatus = [301, 302, 303, 307, 308];
23 redirectStatus.forEach(function(status) {
24 test(function() {
25 redirectResponse = Response.redirect(url, status);
26 assert_equals(redirectResponse.status, status, "Redirect status is " + status);
27 }, "Check response returned by static method redirect(), status = " + st atus);
28 });
29
30 test(function() {
31 var invalidUrl = "http://:This is not an url";
32 assert_throws(new TypeError(), function() { Response.redirect(invalidUrl ); },
33 "Expect TypeError exception");
34 }, "Check error returned when giving invalid url to redirect()");
35
36 var invalidRedirectStatus = [200, 309, 400, 500];
37 invalidRedirectStatus.forEach(function(invalidStatus) {
38 test(function() {
39 assert_throws(new RangeError() , function() { Response.redirect(url, i nvalidStatus); },
40 "Expect RangeError exception");
41 }, "Check error returned when giving invalid status to redirect(), statu s = " + invalidStatus);
42 });
43 </script>
44 </body>
45 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698