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

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: followups through message #33 Created 5 years, 7 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
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..d85b058e7b905dc0e6cd418bf4a44c4a1edd317e 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,55 @@ function waitForAllTabs(callback) {
}
waitForTabs();
}
+
+// Do a c.t.query and return the found tab (or undefined) in a callback
not at google - send to devlin 2015/06/01 20:33:57 Huh, funny, I guess we should support a tabId prop
Jared Sohn 2015/06/02 08:54:38 Yeah, I like that better; updated. On 2015/06/01
+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] : undefined);
not at google - send to devlin 2015/06/01 20:33:57 epic nit but this isn't "undefined", because we kn
Jared Sohn 2015/06/02 08:54:38 Done. (A previous iteration of the code would pass
+ })
+ );
+}
+
+// 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 (queryableAttrib in changeInfo) {
not at google - send to devlin 2015/06/01 20:33:57 use hasOwnProperty, otherwise it will include prop
Jared Sohn 2015/06/02 08:54:38 Done.
+ 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(undefined, tab);
+ onUpdatedCompleted();
+ }));
+ }));
+ }
+ }
+ );
+}

Powered by Google App Engine
This is Rietveld 408576698