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

Unified Diff: chrome/test/data/extensions/management/themes/common.js

Issue 6546072: Clean up how we handle themes in the extensions system and management API.... Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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/management/themes/common.js
===================================================================
--- chrome/test/data/extensions/management/themes/common.js (revision 0)
+++ chrome/test/data/extensions/management/themes/common.js (revision 0)
@@ -0,0 +1,80 @@
+// Copyright (c) 2011 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.
+
+var common = {};
+common.step_index = 0;
+common.fail = false;
+
+var test_steps = [];
+
+function send(msg) {
+ return function() {
+ chrome.test.sendMessage(msg);
+ };
+}
+
+var waiting = false;
+function sendAndWait(msg, expected) {
+ return function() {
+ waiting = true;
+ chrome.test.sendMessage(msg, function(response) {
+ waiting = false;
+ if (common.step_index < test_steps.length) {
+ var current = test_steps[common.step_index];
+ if (typeof(current) == "function") {
+ common.step_index++;
+ current.call();
+ }
+ }
+ });
+ };
+}
+
+function makeListener (event) {
+ return function(info) {
+ if (common.fail || waiting || common.step_index >= test_steps.length)
+ return;
+ var id = (event == "uninstall") ? info : info.id;
+ var expected = test_steps[common.step_index];
+ if (event != expected[0] || id != expected[1]) {
+ console.log("failure: expected " + JSON.stringify(expected) + ", got " +
+ event + " " + id);
+ common.fail = true;
+ return;
+ }
+ common.step_index++;
+
+ while (!waiting && common.step_index < test_steps.length) {
+ // If the next step is a function, call it.
+ var next = test_steps[common.step_index];
+ if (typeof(next) == "function") {
+ common.step_index++;
+ next.call();
+ } else {
+ break;
+ }
+ }
+ };
+}
+
+chrome.management.onInstalled.addListener(makeListener("install"));
+chrome.management.onUninstalled.addListener(makeListener("uninstall"));
+chrome.management.onEnabled.addListener(makeListener("enable"));
+chrome.management.onDisabled.addListener(makeListener("disable"));
+
+function enableTheme1() {
+ chrome.management.setEnabled("iamefpfkojoapidjnbafmgkgncegbkad", true);
+}
+
+function disableTheme1() {
+ chrome.management.setEnabled("iamefpfkojoapidjnbafmgkgncegbkad", false);
+}
+
+function enableTheme2() {
+ chrome.management.setEnabled("pjpgmfcmabopnnfonnhmdjglfpjjfkbf", true);
+}
+
+function disableTheme2() {
+ chrome.management.setEnabled("pjpgmfcmabopnnfonnhmdjglfpjjfkbf", false);
+}
Property changes on: chrome/test/data/extensions/management/themes/common.js
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698