| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var testTabId_; | 5 var testTabId_; |
| 6 | 6 |
| 7 chrome.test.runTests([ | 7 chrome.test.runTests([ |
| 8 function setupWindow() { | 8 function setupWindow() { |
| 9 chrome.tabs.getCurrent(pass(function(tab) { | 9 chrome.tabs.getCurrent(pass(function(tab) { |
| 10 testTabId_ = tab.id; | 10 testTabId_ = tab.id; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 })); | 23 })); |
| 24 })); | 24 })); |
| 25 }, | 25 }, |
| 26 | 26 |
| 27 function makeMuted() { | 27 function makeMuted() { |
| 28 onUpdatedExpect("muted", true, {mutedCause: chrome.runtime.id}); | 28 onUpdatedExpect("muted", true, {mutedCause: chrome.runtime.id}); |
| 29 chrome.tabs.update(testTabId_, {muted: true}, pass()); | 29 chrome.tabs.update(testTabId_, {muted: true}, pass()); |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 function testStaysMutedAfterChangingWindow() { | 32 function testStaysMutedAfterChangingWindow() { |
| 33 chrome.windows.create({}, pass(function(window) | 33 chrome.windows.create({}, pass(function(window) { |
| 34 { | |
| 35 chrome.tabs.move(testTabId_, {windowId: window.id, index: -1}, | 34 chrome.tabs.move(testTabId_, {windowId: window.id, index: -1}, |
| 36 pass(function(tab) { | 35 pass(function(tab) { |
| 37 assertEq(true, tab.muted); | 36 assertEq(true, tab.muted); |
| 38 })); | 37 })); |
| 39 })); | 38 })); |
| 40 }, | 39 }, |
| 41 | 40 |
| 42 function makeNotMuted() { | 41 function makeNotMuted() { |
| 43 onUpdatedExpect("muted", false, {mutedCause: chrome.runtime.id}); | 42 onUpdatedExpect("muted", false, {mutedCause: chrome.runtime.id}); |
| 44 chrome.tabs.update(testTabId_, {muted: false}, pass()); | 43 chrome.tabs.update(testTabId_, {muted: false}, pass()); |
| 44 }, |
| 45 |
| 46 // Prior tests in this file have already toggled the muted state twice. |
| 47 // We update a third (and final) time before rate limiting kicks in. |
| 48 // (except rate limiting is ignored when we set muted/mutedCause to |
| 49 // the same values.) |
| 50 function frequentRequestsRateLimited() { |
| 51 chrome.tabs.update(testTabId_, {muted: true}, pass()); |
| 52 chrome.tabs.update(testTabId_, {muted: true}, pass()); // ignored |
| 53 chrome.tabs.update(testTabId_, {muted: false}, function(tab) { |
| 54 var errMsg = "Rate limit exceeded when updating mute state for tab " + |
| 55 testTabId_ + "."; |
| 56 chrome.test.assertLastError(errMsg); |
| 57 }); |
| 45 } | 58 } |
| 46 ]); | 59 ]); |
| OLD | NEW |