| 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
|
|
|
|
|