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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials.js

Issue 2863593003: Add Origin Trial layout tests for IDL bindings (part 2) (Closed)
Patch Set: Rebase Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/origin_trials/sample-api-enabled-header.php » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials.js b/third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials.js
index 51fa814addcf0a6b9e635b71ac928f92fe88bcf3..60dbf45e58aea9c09a970cd47486204f17317e8f 100644
--- a/third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials.js
+++ b/third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials.js
@@ -56,177 +56,55 @@ expect_static_member_fails = (member_name) => {
// These tests verify that any gated parts of the API are not available.
expect_failure = (skip_worker) => {
- tests = [{
- desc: 'Accessing attribute should throw error',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- assert_idl_attribute(testObject, 'throwingAttribute');
- assert_throws("NotSupportedError", () => { testObject.throwingAttribute; },
- 'Accessing attribute should throw error');
- }
- }, {
- desc: 'Attribute should exist and return value, with trial disabled',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- assert_idl_attribute(testObject, 'unconditionalAttribute');
- assert_true(testObject.unconditionalAttribute,
- 'Attribute should return boolean value');
- }
- }, {
- desc: 'Attribute should not exist, with trial disabled',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- assert_false('normalAttribute' in testObject);
- assert_not_exists(testObject, 'normalAttribute');
- assert_equals(testObject['normalAttribute'], undefined);
- }
- }, {
- desc: 'Constant should not exist, with trial disabled',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_false('CONSTANT' in testInterface);
- assert_not_exists(testInterface, 'CONSTANT');
- assert_equals(testInterface['CONSTANT'], undefined);
- }
- }, {
- desc: 'Attribute should not exist on partial interface, with trial disabled',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_not_exists(testObject, 'normalAttributePartial');
- assert_equals(testObject['normalAttributePartial'], undefined);
- }
- }, {
- desc: 'Static attribute should not exist on partial interface, with trial disabled',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_false('staticAttributePartial' in testInterface);
- assert_not_exists(testInterface, 'staticAttributePartial');
- assert_equals(testInterface['staticAttributePartial'], undefined);
- }
- }, {
- desc: 'Constant should not exist on partial interface, with trial disabled',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_false('CONSTANT_PARTIAL' in testInterface);
- assert_not_exists(testInterface, 'CONSTANT_PARTIAL');
- assert_equals(testInterface['CONSTANT_PARTIAL'], undefined);
- }
- }, {
- desc: 'Method should not exist on partial interface, with trial disabled',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- assert_false('methodPartial' in testObject);
- assert_not_exists(testObject, 'methodPartial');
- assert_equals(testObject['methodPartial'], undefined);
- }
- }, {
- desc: 'Static method should not exist on partial interface, with trial disabled',
- code: () => {
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_false('staticMethodPartial' in testInterface);
- assert_not_exists(testInterface, 'staticMethodPartial');
- assert_equals(testInterface['staticMethodPartial'], undefined);
- }
- }];
+
+ test(() => {
+ var testObject = window.internals.originTrialsTest();
+ assert_idl_attribute(testObject, 'throwingAttribute');
+ assert_throws("NotSupportedError", () => { testObject.throwingAttribute; },
+ 'Accessing attribute should throw error');
+ }, 'Accessing attribute should throw error');
+
+ test(() => {
+ expect_member('unconditionalAttribute', (testObject) => {
+ return testObject.unconditionalAttribute;
+ });
+ }, 'Attribute should exist and return value, with trial disabled');
+
+ test(() => {
+ expect_member_fails('normalAttribute');
+ }, 'Attribute should not exist, with trial disabled');
+
+ test(() => {
+ expect_static_member_fails('CONSTANT');
+ }, 'Constant should not exist, with trial disabled');
if (!skip_worker) {
fetch_tests_from_worker(new Worker('resources/disabled-worker.js'));
}
-
- for (var i = 0; i < tests.length; ++i) {
- test(tests[i].code, tests[i].desc);
- }
};
// These tests verify that the API functions correctly with an enabled trial.
expect_success = () => {
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- assert_idl_attribute(testObject, 'throwingAttribute');
- assert_true(testObject.throwingAttribute, 'Attribute should return boolean value');
- }, 'Accessing attribute should return value and not throw exception');
-
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- assert_idl_attribute(testObject, 'normalAttribute');
- assert_true(testObject.normalAttribute, 'Attribute should return boolean value');
- }, 'Attribute should exist and return value');
-
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_exists(testInterface, 'CONSTANT');
- assert_equals(testInterface.CONSTANT, 1, 'Constant should return integer value');
- }, 'Constant should exist on interface and return value');
-
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_exists(testInterface, 'CONSTANT');
- testInterface.CONSTANT = 10;
- assert_equals(testInterface.CONSTANT, 1, 'Constant should not be modifiable');
- }, 'Constant should exist on interface and not be modifiable');
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- assert_idl_attribute(testObject, 'normalAttributePartial');
- assert_true(testObject.normalAttributePartial, 'Attribute should return boolean value');
- }, 'Attribute should exist on partial interface and return value');
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_exists(testInterface, 'staticAttributePartial');
- assert_true(testInterface.staticAttributePartial, 'Static attribute should return boolean value');
- }, 'Static attribute should exist on partial interface and return value');
-
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_exists(testInterface, 'CONSTANT_PARTIAL');
- assert_equals(testInterface.CONSTANT_PARTIAL, 2, 'Constant should return integer value');
- }, 'Constant should exist on partial interface and return value');
-
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- assert_idl_attribute(testObject, 'normalMethodPartial');
- assert_true(testObject.normalMethodPartial(), 'Method should return boolean value');
- }, 'Method should exist on partial interface and return value');
-
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- var testObjectInterface = testObject.constructor;
- assert_exists(testObjectInterface, 'staticMethodPartial');
- assert_true(testObjectInterface.staticMethodPartial(), 'Static method should return boolean value');
- }, 'Static method should exist on partial interface and return value');
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var test_object = window.internals.originTrialsTest();
- assert_idl_attribute(test_object, 'normalAttribute');
- assert_true(test_object.normalAttribute, 'Attribute should return boolean value');
- }, 'Attribute should exist on interface and return value');
-
-test(() => {
- assert_idl_attribute(window.internals, 'originTrialsTest');
- var testObject = window.internals.originTrialsTest();
- var testInterface = testObject.constructor;
- assert_exists(testInterface, 'staticAttribute');
- assert_true(testInterface.staticAttribute, 'Static attribute should return boolean value');
- }, 'Static attribute should exist on interface and return value');
-
-fetch_tests_from_worker(new Worker('resources/enabled-worker.js'));
+
+ test(() => {
+ expect_member('throwingAttribute', (testObject) => {
+ return testObject.throwingAttribute;
+ });
+ }, 'Accessing attribute should return value and not throw exception');
+
+ test(() => {
+ expect_member('normalAttribute', (testObject) => {
+ return testObject.normalAttribute;
+ });
+ }, 'Attribute should exist on object and return value');
+
+ test(() => {
+ expect_constant('CONSTANT', 1, (testObject) => {
+ return testObject.CONSTANT;
+ });
+ }, 'Constant should exist on interface and return value');
+
+ fetch_tests_from_worker(new Worker('resources/enabled-worker.js'));
};
// These tests should pass, regardless of the state of the trial. These are
@@ -350,68 +228,113 @@ expect_success_bindings = (insecure_context) => {
test(() => {
expect_static_member_fails('secureStaticMethodPartial');
}, 'Secure static method should not exist on partial interface');
- } else {
- test(() => {
- expect_member('normalMethod', (testObject) => {
- return testObject.normalMethod();
- });
- }, 'Method should exist and return value');
- test(() => {
- expect_static_member('staticMethod', (testObject) => {
- return testObject.staticMethod();
- });
- }, 'Static method should exist and return value');
+ return;
+ }
- // Tests for combination of [OriginTrialEnabled] and [SecureContext]
- test(() => {
- expect_member('secureAttribute', (testObject) => {
- return testObject.secureAttribute;
- });
- }, 'Secure attribute should exist and return value');
+ test(() => {
+ expect_member('normalAttribute', (testObject) => {
+ return testObject.normalAttribute;
+ });
+ }, 'Attribute should exist and return value');
- test(() => {
- expect_static_member('secureStaticAttribute', (testObject) => {
- return testObject.secureStaticAttribute;
- });
- }, 'Secure static attribute should exist and return value');
+ test(() => {
+ expect_static_member('staticAttribute', (testObject) => {
+ return testObject.staticAttribute;
+ });
+ }, 'Static attribute should exist and return value');
- test(() => {
- expect_member('secureMethod', (testObject) => {
- return testObject.secureMethod();
- });
- }, 'Secure method should exist and return value');
+ test(() => {
+ expect_member('normalMethod', (testObject) => {
+ return testObject.normalMethod();
+ });
+ }, 'Method should exist and return value');
- test(() => {
- expect_static_member('secureStaticMethod', (testObject) => {
- return testObject.secureStaticMethod();
- });
- }, 'Secure static method should exist and return value');
+ test(() => {
+ expect_static_member('staticMethod', (testObject) => {
+ return testObject.staticMethod();
+ });
+ }, 'Static method should exist and return value');
- test(() => {
- expect_member('secureAttributePartial', (testObject) => {
- return testObject.secureAttributePartial;
- });
- }, 'Secure attribute should exist on partial interface and return value');
+ // Tests for [OriginTrialEnabled] on partial interfaces
+ test(() => {
+ expect_member('normalAttributePartial', (testObject) => {
+ return testObject.normalAttributePartial;
+ });
+ }, 'Attribute should exist on partial interface and return value');
- test(() => {
- expect_static_member('secureStaticAttributePartial', (testObject) => {
- return testObject.secureStaticAttributePartial;
- });
- }, 'Secure static attribute should exist on partial interface and return value');
+ test(() => {
+ expect_static_member('staticAttributePartial', (testObject) => {
+ return testObject.staticAttributePartial;
+ });
+ }, 'Static attribute should exist on partial interface and return value');
- test(() => {
- expect_member('secureMethodPartial', (testObject) => {
- return testObject.secureMethodPartial();
- });
- }, 'Secure method should exist on partial interface and return value');
+ test(() => {
+ expect_member('normalMethodPartial', (testObject) => {
+ return testObject.normalMethodPartial();
+ });
+ }, 'Method should exist on partial interface and return value');
- test(() => {
- expect_static_member('secureStaticMethodPartial', (testObject) => {
- return testObject.secureStaticMethodPartial();
- });
- }, 'Secure static method should exist on partial interface and return value');
- }
+ test(() => {
+ expect_static_member('staticMethodPartial', (testObject) => {
+ return testObject.staticMethodPartial();
+ });
+ }, 'Static method should exist on partial interface and return value');
+
+ test(() => {
+ expect_constant('CONSTANT_PARTIAL', 2, (testObject) => {
+ return testObject.CONSTANT_PARTIAL;
+ });
+ }, 'Constant should exist on partial interface and return value');
+
+ // Tests for combination of [OriginTrialEnabled] and [SecureContext]
+ test(() => {
+ expect_member('secureAttribute', (testObject) => {
+ return testObject.secureAttribute;
+ });
+ }, 'Secure attribute should exist and return value');
+
+ test(() => {
+ expect_static_member('secureStaticAttribute', (testObject) => {
+ return testObject.secureStaticAttribute;
+ });
+ }, 'Secure static attribute should exist and return value');
+
+ test(() => {
+ expect_member('secureMethod', (testObject) => {
+ return testObject.secureMethod();
+ });
+ }, 'Secure method should exist and return value');
+
+ test(() => {
+ expect_static_member('secureStaticMethod', (testObject) => {
+ return testObject.secureStaticMethod();
+ });
+ }, 'Secure static method should exist and return value');
+
+ test(() => {
+ expect_member('secureAttributePartial', (testObject) => {
+ return testObject.secureAttributePartial;
+ });
+ }, 'Secure attribute should exist on partial interface and return value');
+
+ test(() => {
+ expect_static_member('secureStaticAttributePartial', (testObject) => {
+ return testObject.secureStaticAttributePartial;
+ });
+ }, 'Secure static attribute should exist on partial interface and return value');
+
+ test(() => {
+ expect_member('secureMethodPartial', (testObject) => {
+ return testObject.secureMethodPartial();
+ });
+ }, 'Secure method should exist on partial interface and return value');
+
+ test(() => {
+ expect_static_member('secureStaticMethodPartial', (testObject) => {
+ return testObject.secureStaticMethodPartial();
+ });
+ }, 'Secure static method should exist on partial interface and return value');
};
@@ -442,6 +365,25 @@ expect_failure_bindings_impl = (insecure_context, description_suffix) => {
// insecure contexts in expect_success_bindings().
return;
}
+
+ // Tests for [OriginTrialEnabled] on partial interfaces
+ test(() => {
+ expect_member_fails('normalAttributePartial');
+ }, 'Attribute should not exist on partial interface, with trial disabled');
+ test(() => {
+ expect_static_member_fails('staticAttributePartial');
+ }, 'Static attribute should not exist on partial interface, with trial disabled');
+ test(() => {
+ expect_member_fails('methodPartial');
+ }, 'Method should not exist on partial interface, with trial disabled');
+ test(() => {
+ expect_static_member_fails('staticMethodPartial');
+ }, 'Static method should not exist on partial interface, with trial disabled');
+ test(() => {
+ expect_static_member_fails('CONSTANT_PARTIAL');
+ }, 'Constant should not exist on partial interface, with trial disabled');
+
+ // Tests for combination of [OriginTrialEnabled] and [SecureContext]
test(() => {
expect_member_fails('secureAttribute');
}, 'Secure attribute should not exist, with trial disabled');
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/origin_trials/sample-api-enabled-header.php » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698