Skip to content

Commit

Permalink
Update background.js
Browse files Browse the repository at this point in the history
getLastFocused returns wrong window with Chrome v46, see #312
  • Loading branch information
PiNotEqual3 committed Oct 16, 2015
1 parent 44ba1b8 commit a21202e
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,15 @@ var tgs = (function () {
}

function suspendAllTabs() {
chrome.windows.getLastFocused({populate: true}, function(curWindow) {
curWindow.tabs.forEach(function (tab) {
if (!tab.active) {
requestTabSuspension(tab, true);
}
chrome.tabs.query({ active: true, currentWindow: true }, function(a)
{
var windowID = a[0].windowId;
chrome.windows.get(windowID, {populate: true}, function(curWindow) {
curWindow.tabs.forEach(function (tab) {
if (!tab.active) {
requestTabSuspension(tab, true);
}
});
});
});
}
Expand All @@ -229,12 +233,15 @@ var tgs = (function () {
}

function unsuspendAllTabs() {

chrome.windows.getLastFocused({populate: true}, function(curWindow) {
curWindow.tabs.forEach(function (currentTab) {
if (isSuspended(currentTab)) {
unsuspendTab(currentTab);
}
chrome.tabs.query({ active: true, currentWindow: true }, function(a)
{
var windowID = a[0].windowId;
chrome.windows.get(windowID, {populate: true}, function(curWindow) {
curWindow.tabs.forEach(function (currentTab) {
if (isSuspended(currentTab)) {
unsuspendTab(currentTab);
}
});
});
});
}
Expand Down

0 comments on commit a21202e

Please sign in to comment.