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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-script.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-script.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-script.php b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-script.php
index b610ee972aca2fadac293e3280a90bcaf32c16c5..e2e48f8bad1a34abbc6823fe6b093d4207af5a1a 100644
--- a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-script.php
+++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/crossorigin/suborigin-cors-script.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>
@@ -12,29 +13,28 @@ header("Suborigin: foobar");
<body>
<div id="container"></div>
<script>
-var SuboriginScriptTest = function(pass, name, src, crossoriginValue) {
- SuboriginTest.call(this, pass, "Script: " + name, src, crossoriginValue);
+var SuboriginScriptTest = function(pass, name, src, crossorigin_value) {
+ SuboriginTest.call(this, pass, 'Script: ' + name, src, crossorigin_value);
}
SuboriginScriptTest.prototype.execute = function() {
- var test = async_test(this.name);
- var e = document.createElement("script");
- e.src = this.src;
- if (this.crossoriginValue) {
- e.setAttribute("crossorigin", this.crossoriginValue);
- }
- if (this.pass) {
- e.addEventListener("load", function() { test.done(); });
- e.addEventListener("error", function() {
- test.step(function() { assert_unreached("Good load fired error handler."); });
- });
- } else {
- e.addEventListener("load", function() {
- test.step(function() { assert_unreached("Bad load successful.") });
- });
- e.addEventListener("error", function() { test.done(); });
- }
- document.body.appendChild(e);
+ var settings = this;
+ async_test(test => {
+ var e = document.createElement('script');
+ e.src = settings.src;
+ if (settings.crossorigin_value) {
+ e.setAttribute('crossorigin', settings.crossorigin_value);
+ }
+ if (settings.pass) {
+ e.addEventListener('load', test.step_func_done());
+ e.addEventListener(
+ 'error', test.unreached_func('Good load fired error handler.'));
+ } else {
+ e.addEventListener('load', test.unreached_func('Bad load successful.'));
+ e.addEventListener('error', test.step_func_done());
+ }
+ document.body.appendChild(e);
+ }, settings.name);
}
// This is unused but required by cors-script.php.
@@ -42,28 +42,28 @@ window.result = false;
// Script tests
new SuboriginScriptTest(
- false,
- "<crossorigin='anonymous'>, ACAO: " + server,
- xoriginAnonScript(),
- "anonymous").execute();
+ false,
+ '<crossorigin=\'anonymous\'>, ACAO: ' + server,
+ xoriginAnonScript(),
+ 'anonymous').execute();
new SuboriginScriptTest(
- true,
- "<crossorigin='anonymous'>, ACAO: *",
- xoriginAnonScript('*'),
- "anonymous").execute();
+ true,
+ '<crossorigin=\'anonymous\'>, ACAO: *',
+ xoriginAnonScript('*'),
+ 'anonymous').execute();
new SuboriginScriptTest(
- false,
- "<crossorigin='use-credentials'>, ACAO: " + server,
- xoriginCredsScript(),
- "use-credentials").execute();
+ false,
+ '<crossorigin=\'use-credentials\'>, ACAO: ' + server,
+ xoriginCredsScript(),
+ 'use-credentials').execute();
new SuboriginScriptTest(
- false,
- "<crossorigin='anonymous'>, CORS-ineligible resource",
- xoriginIneligibleScript(),
- "anonymous").execute();
+ false,
+ '<crossorigin=\'anonymous\'>, CORS-ineligible resource',
+ xoriginIneligibleScript(),
+ 'anonymous').execute();
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698