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

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

Issue 2808543002: Cleanup expected.txt files for layout tests (Closed)
Patch Set: Remove platform-specific expected.txt file 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials-worker.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials-worker.js b/third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..ec01b9301e3795134ec0be0208bc727882e94a76
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/origin_trials/resources/origintrials-worker.js
@@ -0,0 +1,78 @@
+importScripts('/resources/testharness.js');
+
+get_worker_type = () => {
+ var type = Object.prototype.toString.call(self);
+ if (type.indexOf('ServiceWorkerGlobalScope') !== -1) {
+ return 'service';
+ }
+ if (type.indexOf('SharedWorkerGlobalScope') !== -1) {
+ if (self.name) {
+ return 'shared (' + self.name + ')';
+ }
+ return 'shared';
+ }
+ if (type.indexOf('DedicatedWorkerGlobalScope') !== -1) {
+ return 'dedicated';
+ }
+ return 'unknown';
+}
+
+// Test whether the origin-trial-enabled attributes are *NOT* attached in a
+// worker where the trial is not enabled.
+// This is deliberately just a minimal set of tests to ensure that trials are
+// available in a worker. The full suite of tests are in origintrials.js.
+expect_failure_worker = () => {
+ // Use |worker_type| to make the test descriptions unique when multiple
+ // workers are created in a single test file.
+ var worker_type = get_worker_type();
+ test(() => {
+ var testObject = self.internals.originTrialsTest();
+ assert_idl_attribute(testObject, 'throwingAttribute');
+ assert_throws('NotSupportedError', () => {
+ testObject.throwingAttribute;
+ }, 'Accessing attribute should throw error');
+ }, 'Accessing attribute should throw error in ' + worker_type + ' worker');
+ test(() => {
+ var testObject = self.internals.originTrialsTest();
+ assert_not_exists(testObject, 'normalAttribute');
+ assert_equals(testObject.normalAttribute, undefined);
+ }, 'Attribute should not exist in ' + worker_type + ' worker');
+ test(() => {
+ var testObject = self.internals.originTrialsTest();
+ assert_not_exists(testObject, 'CONSTANT');
+ assert_equals(testObject.CONSTANT, undefined);
+ }, 'Constant should not exist in ' + worker_type + ' worker');
+ done();
+}
+
+// Test whether the origin-trial-enabled attributes are attached in a worker
+// where the trial is enabled.
+// This is deliberately just a minimal set of tests to ensure that trials are
+// available in a worker. The full suite of tests are in origintrials.js.
+expect_success_worker = () => {
+ // Use |worker_type| to make the test descriptions unique when multiple
+ // workers are created in a single test file.
+ var worker_type = get_worker_type();
+ test(() => {
+ var testObject = self.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 in ' + worker_type + ' worker');
+ test(() => {
+ var testObject = self.internals.originTrialsTest();
+ assert_idl_attribute(testObject, 'normalAttribute');
+ assert_true(testObject.normalAttribute, 'Attribute should return boolean value');
+ }, 'Attribute should exist and return value in ' + worker_type + ' worker');
+ test(() => {
+ var testObject = self.internals.originTrialsTest();
+ assert_idl_attribute(testObject, 'CONSTANT');
+ assert_equals(testObject.CONSTANT, 1, 'Constant should return integer value');
+ }, 'Constant should exist and return value in ' + worker_type + ' worker');
+ test(() => {
+ var testObject = self.internals.originTrialsTest();
+ assert_idl_attribute(testObject, 'CONSTANT');
+ testObject.CONSTANT = 10;
+ assert_equals(testObject.CONSTANT, 1, 'Constant should not be modifiable');
+ }, 'Constant should exist and not be modifiable in ' + worker_type + ' worker');
+ done();
+}

Powered by Google App Engine
This is Rietveld 408576698