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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch-preflight.php

Issue 2370843003: Suborigin LayoutTest formatting and refactoring (Closed)
Patch Set: Created 4 years, 3 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
Index: third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch-preflight.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch-preflight.php b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch-preflight.php
index c001159a644b3309b9f5dba796b5039a829a1d74..3582c92124a8e804819a6bfb3d1a649773f501ad 100644
--- a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch-preflight.php
+++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch-preflight.php
@@ -4,6 +4,7 @@ header("Suborigin: foobar");
<!DOCTYPE html>
<html>
<head>
+<meta charset="utf-8">
<title>Allow suborigin in HTTP header</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
@@ -13,86 +14,99 @@ header("Suborigin: foobar");
<div id="container"></div>
<script>
// Fetch tests
-var SuboriginFetchTest = function(pass, name, src, crossoriginValue) {
- SuboriginTest.call(this, pass, "Fetch: " + name, src, crossoriginValue);
+var SuboriginFetchTest = function(pass, name, src, crossorigin_value) {
+ SuboriginTest.call(this, pass, 'Fetch: ' + name, src, crossorigin_value);
}
SuboriginFetchTest.prototype.execute = function() {
- var test = async_test(this.name);
- var headers = new Headers();
- // Set a custom header to force a preflight. Even though the
- // scheme/host/port of the source and destination origins are the same, the
- // Suborigin should cause the request to be treated as cross-origin.
- headers.append("x-custom-header", "foobar");
- var options = {
- method: "GET",
+ var settings = this;
+ async_test(test => {
+ var headers = new Headers();
+ // Set a custom header to force a preflight. Even though the
+ // scheme/host/port of the source and destination origins are the same,
+ // the Suborigin should cause the request to be treated as cross-origin.
+ headers.append('x-custom-header', 'foobar');
+ var options = {
+ method: 'GET',
headers: headers,
- credentials: (this.crossoriginValue === 'use-credentials') ? 'include' : 'exclude',
+ credentials: (settings.crossorigin_value === 'use-credentials') ?
+ 'include' :
+ 'exclude',
mode: 'cors'
- }
+ }
- var response_func;
- var error_func;
- if (this.pass) {
+ var response_func;
+ var error_func;
+ if (settings.pass) {
response_func = test.step_func_done();
- error_func = test.unreached_func("Good Fetch fired error handler.");
- } else {
- response_func = test.unreached_func("Bad Fetch successful.");
+ error_func = test.unreached_func('Good Fetch fired error handler.');
+ } else {
+ response_func = test.unreached_func('Bad Fetch successful.');
error_func = test.step_func_done();
- }
- fetch(this.src, options).then(response_func).catch(error_func);
+ }
+ fetch(settings.src, options)
+ .then(response_func)
+ .catch(error_func);
+ }, settings.name);
};
-var xorigin_preflight_script = "http://127.0.0.1:8000/security/resources/cors-script.php";
+var xorigin_preflight_script =
+ 'http://127.0.0.1:8000/security/resources/cors-script.php';
// Fetch preflight tests
new SuboriginFetchTest(
- false,
- "Complex anonymous Fetch preflight, no AC for custom header",
- xorigin_preflight_script + "?cors=http-so://foobar.127.0.0.1:8000",
- "anonymous").execute();
+ false,
+ 'Complex anonymous Fetch preflight, no AC for custom header',
+ xorigin_preflight_script + '?cors=http-so://foobar.127.0.0.1:8000',
+ 'anonymous').execute();
new SuboriginFetchTest(
- true,
- "Complex anonymous Fetch preflight, has AC for custom header",
- xorigin_preflight_script + "?cors=http-so://foobar.127.0.0.1:8000&custom=x-custom-header",
- "anonymous").execute();
+ true,
+ 'Complex anonymous Fetch preflight, has AC for custom header',
+ xorigin_preflight_script +
+ '?cors=http-so://foobar.127.0.0.1:8000&custom=x-custom-header',
+ 'anonymous').execute();
new SuboriginFetchTest(
- false,
- "Complex anonymous Fetch preflight with '*' ACAO, no AC for custom header",
- xorigin_preflight_script + "?cors=*",
- "anonymous").execute();
+ false,
+ 'Complex anonymous Fetch preflight with \'*\' ACAO, no AC for custom header',
+ xorigin_preflight_script + '?cors=*',
+ 'anonymous').execute();
new SuboriginFetchTest(
- true,
- "Complex anonymous Fetch preflight with '*' ACAO, has AC for custom header",
- xorigin_preflight_script + "?cors=*&custom=x-custom-header",
- "anonymous").execute();
+ true,
+ 'Complex anonymous Fetch preflight with \'*\' ACAO, has AC for custom header',
+ xorigin_preflight_script + '?cors=*&custom=x-custom-header',
+ 'anonymous').execute();
new SuboriginFetchTest(
- false,
- "Complex Fetch with credentials preflight, no AC for custom header",
- xorigin_preflight_script + "?cors=http-so://foobar.127.0.0.1:8000&credentials=true",
- "use-credentials").execute();
+ false,
+ 'Complex Fetch with credentials preflight, no AC for custom header',
+ xorigin_preflight_script +
+ '?cors=http-so://foobar.127.0.0.1:8000&credentials=true',
+ 'use-credentials').execute();
new SuboriginFetchTest(
- true,
- "Complex Fetch with credentials preflight, has AC for custom header",
- xorigin_preflight_script + "?cors=http-so://foobar.127.0.0.1:8000&credentials=true&custom=x-custom-header",
- "use-credentials").execute();
+ true,
+ 'Complex Fetch with credentials preflight, has AC for custom header',
+ xorigin_preflight_script +
+ '?cors=http-so://foobar.127.0.0.1:8000&credentials=true&' +
+ 'custom=x-custom-header',
+ 'use-credentials').execute();
new SuboriginFetchTest(
- false,
- "Complex Fetch with credentials preflight with '*' ACAO, no AC for custom header",
- xorigin_preflight_script + "?cors=*&credentials=true",
- "use-credentials").execute();
+ false,
+ 'Complex Fetch with credentials preflight with \'*\' ACAO, ' +
+ 'no AC for custom header',
+ xorigin_preflight_script + '?cors=*&credentials=true',
+ 'use-credentials').execute();
new SuboriginFetchTest(
- false,
- "Complex Fetch with credentials preflight with '*' ACAO, has AC for custom header",
- xorigin_preflight_script + "?cors=*&credentials=true&custom=x-custom-header",
- "use-credentials").execute();
+ false,
+ 'Complex Fetch with credentials preflight with \'*\' ACAO, ' +
+ 'has AC for custom header',
+ xorigin_preflight_script + '?cors=*&credentials=true&custom=x-custom-header',
+ 'use-credentials').execute();
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698