Index: chrome/test/data/extensions/api_test/tabs/basics/audible.js |
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/audible.js b/chrome/test/data/extensions/api_test/tabs/basics/audible.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cce7c3fa2b7cf682193132cb142f3a7c2d957f39 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/tabs/basics/audible.js |
@@ -0,0 +1,67 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
not at google - send to devlin
2015/05/26 23:09:48
2015
Jared Sohn
2015/05/27 14:52:02
Done (also changed muted.js, sinewave.js, and disa
not at google - send to devlin
2015/05/28 23:04:42
Correct.
not at google - send to devlin
2015/06/01 20:33:56
btw we also now leave the (c) out, for the record.
Jared Sohn
2015/06/02 08:54:38
Updated in new files.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+var testTabId_; |
+ |
+function injectScriptIntoOnlyTab(filename) |
+{ |
not at google - send to devlin
2015/05/26 23:09:48
Open brace should be on same line as function name
Jared Sohn
2015/05/27 14:52:02
Done.
|
+ var views = chrome.extension.getViews({type: "tab"}); |
+ assertEq(1, views.length); |
+ var scriptElem = views[0].document.createElement("script"); |
+ scriptElem.type = "text/javascript"; |
+ scriptElem.src = filename; |
+ views[0].document.body.appendChild(scriptElem); |
not at google - send to devlin
2015/05/26 23:09:48
Instead of this you should be able to do something
Jared Sohn
2015/05/27 14:52:02
Would doing this match your suggestion?
-- create
not at google - send to devlin
2015/05/28 23:04:42
Sounds good to me.
|
+} |
+ |
+chrome.test.runTests([ |
+ function setupWindow() { |
+ chrome.tabs.getCurrent(pass(function(tab) { |
+ testTabId_ = tab.id; |
miu
2015/05/26 21:28:47
kalman@'s more familiar with the JS extension test
not at google - send to devlin
2015/05/26 23:09:47
Very confusingly, callbackPass (which pass is alia
Jared Sohn
2015/05/27 14:52:02
Correct. I am using pass here to be consistent wit
|
+ })); |
+ }, |
+ |
+ function audibleStartsFalse() { |
+ chrome.tabs.get(testTabId_, pass(function(tab) { |
+ assertEq(false, tab.audible); |
+ checkQuery(testTabId_, "audible", false, true, null); |
+ checkQuery(testTabId_, "audible", true, false, null); |
+ })); |
+ }, |
+ |
+ function audibleUpdateAttempt() { |
miu
2015/05/26 21:28:46
naming nit: How about audibleUpdateAttemptShouldFa
Jared Sohn
2015/05/27 14:52:02
Done.
|
+ var error_msg = "Invalid value for argument 2. Property 'audible': " + |
+ "Unexpected property."; |
+ |
+ try |
+ { |
+ chrome.tabs.update(testTabId_, {audible: true}, function(tab) { |
+ chrome.test.fail("Updated audible property via chrome.tabs.update"); |
+ }); |
+ } catch (e) |
+ { |
+ assertEq(error_msg, e.message); |
+ chrome.test.succeed(); |
+ } |
+ }, |
+ |
+ function makeAudible() { |
+ onUpdatedExpect("audible", true, null); |
+ injectScriptIntoOnlyTab("sinewave.js"); |
+ }, |
+ |
+ function testStaysAudibleAfterChangingWindow() { |
miu
2015/05/26 21:28:46
Not sure if it's necessary to test the state after
Jared Sohn
2015/05/27 14:52:02
The intention behind this test is because this pat
miu
2015/05/27 20:10:14
Okay. Sounds good to me. :)
|
+ chrome.windows.create({}, pass(function(window) |
+ { |
+ chrome.tabs.move(testTabId_, {windowId: window.id, index: -1}, |
+ pass(function(tab) { |
+ assertEq(true, tab.audible); |
+ })); |
+ })); |
+ }, |
+ |
+ function makeNotAudible() { |
+ onUpdatedExpect("audible", false, null); |
+ injectScriptIntoOnlyTab("disable_sinewave.js"); |
+ } |
+]); |