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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch.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.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch.php b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch.php
index be0d6ba684bb73dae0734a5c4e680c0b216630e7..b133bf23e3c5261c250e81619338514aadd95db9 100644
--- a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch.php
+++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-fetch.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,71 +14,78 @@ 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 options = {};
-
- if (this.crossoriginValue === 'same-origin') {
+ var settings = this;
+ async_test(test => {
+ var options = {};
+ if (settings.crossorigin_value === 'same-origin') {
options.mode = 'same-origin';
- } else if (this.crossoriginValue === 'anonymous') {
+ } else if (settings.crossorigin_value === 'anonymous') {
options.mode = 'cors';
- } else if (this.crossoriginValue === 'use-credentials') {
+ } else if (settings.crossorigin_value === 'use-credentials') {
options.mode = 'cors';
options.credentials = 'include';
- }
+ }
- var pass = this.pass;
- fetch(this.src, options)
+ var pass = this.pass;
+ fetch(this.src, options)
.then(function(response) {
if (pass) {
- test.step(function() { test.done(); });
+ test.step(function() { test.done(); });
} else {
- test.step(function() { assert_unreached("Bad Fetch succeeded."); test.done(); });
+ test.step(function() {
+ assert_unreached('Bad Fetch succeeded.');
+ test.done();
+ });
}
- })
+ })
.catch(function(error) {
if (pass) {
- test.step(function() { assert_unreached("Good Fetch failed."); test.done(); });
+ test.step(function() {
+ assert_unreached('Good Fetch failed.');
+ test.done();
+ });
} else {
- test.step(function() { test.done(); });
+ test.step(function() { test.done(); });
}
- });
+ });
+ }, settings.name);
};
// Fetch tests
new SuboriginFetchTest(
- false,
- "anonymous, ACAO: " + server,
- xoriginAnonScript(),
- "anonymous").execute();
+ false,
+ 'anonymous, ACAO: ' + server,
+ xoriginAnonScript(),
+ 'anonymous').execute();
new SuboriginFetchTest(
- true,
- "anonymous, ACAO: *",
- xoriginAnonScript('*'),
- "anonymous").execute();
+ true,
+ 'anonymous, ACAO: *',
+ xoriginAnonScript('*'),
+ 'anonymous').execute();
new SuboriginFetchTest(
- false,
- "use-credentials, ACAO: " + server,
- xoriginCredsScript(),
- "use-credentials").execute();
+ false,
+ 'use-credentials, ACAO: ' + server,
+ xoriginCredsScript(),
+ 'use-credentials').execute();
new SuboriginFetchTest(
- false,
- "anonymous, CORS-ineligible resource",
- xoriginIneligibleScript(),
- "anonymous").execute();
+ false,
+ 'anonymous, CORS-ineligible resource',
+ xoriginIneligibleScript(),
+ 'anonymous').execute();
new SuboriginFetchTest(
- false,
- "same-origin, ACAO: * ",
- xoriginAnonScript('*'),
- "same-origin").execute();
+ false,
+ 'same-origin, ACAO: * ',
+ xoriginAnonScript('*'),
+ 'same-origin').execute();
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698