| Index: chrome/test/data/extensions/api_test/native_bindings/background.js
|
| diff --git a/chrome/test/data/extensions/api_test/native_bindings/background.js b/chrome/test/data/extensions/api_test/native_bindings/background.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..508dc31f764257d3daeedd6e23acaba0a770ff36
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/api_test/native_bindings/background.js
|
| @@ -0,0 +1,36 @@
|
| +// Copyright 2016 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.
|
| +
|
| +if (!chrome || !chrome.test)
|
| + throw new Error('chrome.test is undefined');
|
| +
|
| +// This is a good end-to-end test for two reasons. The first is obvious - it
|
| +// tests a simple API and makes sure it behaves as expected, as well as testing
|
| +// that other APIs are unavailable.
|
| +// The second is that chrome.test is itself an extension API, and a rather
|
| +// complex one. It requires both traditional bindings (renderer parses args,
|
| +// passes info to browser process, browser process does work and responds, re-
|
| +// enters JS) and custom JS bindings (in order to have our runTests, assert*
|
| +// methods, etc). If any of these stages failed, the test itself would also
|
| +// fail.
|
| +chrome.test.runTests([
|
| + function idleApi() {
|
| + chrome.test.assertTrue(!!chrome.idle);
|
| + chrome.test.assertTrue(!!chrome.idle.queryState);
|
| + chrome.idle.queryState(1000, function(state) {
|
| + // TODO(devlin): Update this to use chrome.idle.IdleState.ACTIVE when we
|
| + // have enums in native bindings.
|
| + chrome.test.assertEq('active', state);
|
| + chrome.test.succeed();
|
| + });
|
| + },
|
| + function nonexistentApi() {
|
| + chrome.test.assertFalse(!!chrome.nonexistent);
|
| + chrome.test.succeed();
|
| + },
|
| + function disallowedApi() {
|
| + chrome.test.assertFalse(!!chrome.power);
|
| + chrome.test.succeed();
|
| + },
|
| +]);
|
|
|