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

Unified Diff: chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js

Issue 987583004: Add audible, muted to Tab, c.t.query, c.t.update, and c.t.onUpdated where relevant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch1
Patch Set: rebase Created 5 years, 5 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
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/basics/sinewave.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js b/chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js
index 757cd6b46539e019144ad5639f0ef65675a89c5e..2ee8b07258454de6dca67ac3332e333db47dbcb9 100644
--- a/chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js
+++ b/chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js
@@ -35,10 +35,10 @@ function createWindow(tabUrls, winOptions, callback) {
// zero arguments.
function waitForAllTabs(callback) {
// Wait for all tabs to load.
- function waitForTabs(){
+ function waitForTabs() {
chrome.windows.getAll({"populate": true}, function(windows) {
var ready = true;
- for (var i in windows){
+ for (var i in windows) {
for (var j in windows[i].tabs) {
if (windows[i].tabs[j].status != "complete") {
ready = false;
@@ -56,3 +56,56 @@ function waitForAllTabs(callback) {
}
waitForTabs();
}
+
+// Like chrome.tabs.query, but with the ability to filter by |tabId| as well.
+// Returns the found tab or null
+function queryForTab(tabId, queryInfo, callback) {
+ chrome.tabs.query(queryInfo,
+ pass(function(tabs) {
+ var foundTabs = tabs.filter(function(tab) {
+ return (tab.id == tabId);
+ });
+ if (callback !== null)
+ callback(foundTabs.length ? foundTabs[0] : null);
+ })
+ );
+}
+
+// Check onUpdated for a queryable attribute such as muted or audible
+// and then check that the tab, a query, and changeInfo are consistent
+// with the expected value. Does similar checks for each
+// (nonqueryable attribute, expected value) pair in nonqueryableAttribsDict
+// except it does not check the query.
+function onUpdatedExpect(queryableAttrib, expected, nonqueryableAttribsDict) {
+ var onUpdatedCompleted = chrome.test.listenForever(
+ chrome.tabs.onUpdated,
+ function(tabId, changeInfo, tab) {
+ if (nonqueryableAttribsDict !== null) {
+ var nonqueryableAttribs = Object.keys(nonqueryableAttribsDict);
+ nonqueryableAttribs.forEach(function(nonqueryableAttrib) {
+ if (typeof changeInfo[nonqueryableAttrib] !== "undefined") {
+ assertEq(nonqueryableAttribsDict[nonqueryableAttrib],
+ changeInfo[nonqueryableAttrib]);
+ assertEq(nonqueryableAttribsDict[nonqueryableAttrib],
+ tab[nonqueryableAttrib]);
+ }
+ });
+ }
+ if (changeInfo.hasOwnProperty(queryableAttrib)) {
+ assertEq(expected, changeInfo[queryableAttrib]);
+ assertEq(expected, tab[queryableAttrib]);
+ var queryInfo = {};
+ queryInfo[queryableAttrib] = expected;
+ queryForTab(tabId, queryInfo, pass(function(tab) {
+ assertEq(expected, tab[queryableAttrib]);
+ queryInfo[queryableAttrib] = !expected;
+
+ queryForTab(tabId, queryInfo, pass(function(tab) {
+ assertEq(null, tab);
+ onUpdatedCompleted();
+ }));
+ }));
+ }
+ }
+ );
+}
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/basics/sinewave.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698