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

Unified Diff: chrome/test/data/extensions/api_test/bindings/api_enums/background.js

Issue 969063002: [Extensions] Expose enums on extension APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: chrome/test/data/extensions/api_test/bindings/api_enums/background.js
diff --git a/chrome/test/data/extensions/api_test/bindings/api_enums/background.js b/chrome/test/data/extensions/api_test/bindings/api_enums/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..c795e4e97b024c9c914c19a04eac655a27d8309d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bindings/api_enums/background.js
@@ -0,0 +1,40 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+chrome.test.runTests([
+ function() {
+ // Test management (backed by a json file) api enums.
+
+ // The enum should be declared on the API object.
+ chrome.test.assertTrue(
+ 'LaunchType' in chrome.management,
+ '"LaunchType" is not present on chrome.management.');
+ // The object should have entries for each enum entry. Note that we don't
+ // test all entries here because we don't want to update this test if the
+ // management api changes.
+ chrome.test.assertTrue(
+ 'OPEN_AS_REGULAR_TAB' in chrome.management.LaunchType,
+ '"OPEN_AS_REGULAR_TAB" is not present on management.LaunchType');
+ // The value of the enum should be its string value.
+ chrome.test.assertEq(chrome.management.LaunchType.OPEN_AS_REGULAR_TAB,
+ 'OPEN_AS_REGULAR_TAB');
+ // There should be more than one value for the enum.
+ chrome.test.assertTrue(
+ Object.keys(chrome.management.LaunchType).length > 1);
+
+ // Perform an analogous test for the notifications api (backed by an idl).
+ chrome.test.assertTrue(
+ 'PermissionLevel' in chrome.notifications,
+ '"PermissionLevel" is not present on chrome.notifications.');
+ chrome.test.assertTrue(
+ 'granted' in chrome.notifications.PermissionLevel,
+ '"granted" is not present on notifications.PermissionLevel');
+ chrome.test.assertEq(chrome.notifications.PermissionLevel.granted,
+ 'granted');
+ chrome.test.assertTrue(
+ Object.keys(chrome.notifications.PermissionLevel).length > 1);
+
+ chrome.test.succeed();
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698