Skip to content

Commit

Permalink
Added support for tab.pendingUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
deanoemcke committed May 23, 2020
1 parent b8b7fdf commit e01643d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
10 changes: 3 additions & 7 deletions src/js/gsTabCheckManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,11 @@ var gsTabCheckManager = (function() {

// If tab is a file:// tab and file is blocked then unsuspend tab
if (!gsSession.isFileUrlsAccessAllowed()) {
const originalUrl = gsUtils.getOriginalUrl(tab.url);
const url = tab.url || tab.pendingUrl;
const originalUrl = gsUtils.getOriginalUrl(url);
if (originalUrl && originalUrl.indexOf('file') === 0) {
gsUtils.log(tab.id, QUEUE_ID, 'Unsuspending blocked local file tab.');
await unsuspendSuspendedTab(tab);
await gsChrome.tabsUpdate(tab.id, { url: originalUrl });
requeue(DEFAULT_TAB_CHECK_REQUEUE_DELAY, { refetchTab: true });
return;
}
Expand Down Expand Up @@ -351,11 +352,6 @@ var gsTabCheckManager = (function() {
return reloadOk;
}

async function unsuspendSuspendedTab(tab) {
const originalUrl = gsUtils.getOriginalUrl(tab.url);
await gsChrome.tabsUpdate(tab.id, { url: originalUrl });
}

function ensureSuspendedTabVisible(tabView) {
if (!tabView) {
return false;
Expand Down
20 changes: 12 additions & 8 deletions src/js/gsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ var gsUtils = {

//tests for non-standard web pages. does not check for suspended pages!
isSpecialTab: function(tab) {
var url = tab.url;

if (gsUtils.isSuspendedUrl(url, true)) {
const url = tab.url || tab.pendingUrl;
if (gsUtils.isSuspendedTab(tab, true)) {
return false;
}
// Careful, suspended urls start with "chrome-extension://"
Expand All @@ -150,7 +149,8 @@ var gsUtils = {
},

isFileTab: function(tab) {
if (tab.url.indexOf('file') === 0) {
const url = tab.url || tab.pendingUrl;
if (url.indexOf('file') === 0) {
return true;
}
return false;
Expand All @@ -167,9 +167,10 @@ var gsUtils = {

//does not include suspended pages!
isInternalTab: function(tab) {
const url = tab.url || tab.pendingUrl;
var isLocalExtensionPage =
tab.url.indexOf('chrome-extension://' + chrome.runtime.id) === 0;
return isLocalExtensionPage && !gsUtils.isSuspendedUrl(tab.url);
url.indexOf('chrome-extension://' + chrome.runtime.id) === 0;
return isLocalExtensionPage && !gsUtils.isSuspendedTab(tab);
},

isProtectedPinnedTab: function(tab) {
Expand Down Expand Up @@ -202,11 +203,14 @@ var gsUtils = {
},

isSuspendedTab: function(tab, looseMatching) {
return gsUtils.isSuspendedUrl(tab.url, looseMatching);
const url = tab.url || tab.pendingUrl;
return gsUtils.isSuspendedUrl(url, looseMatching);
},

isSuspendedUrl: function(url, looseMatching) {
if (looseMatching) {
if (!url) {
return false;
} else if (looseMatching) {
return url.indexOf('suspended.html') > 0;
} else {
return url.indexOf(chrome.extension.getURL('suspended.html')) === 0;
Expand Down
9 changes: 5 additions & 4 deletions src/js/recovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@

for (var i = 0; i < childLinks.length; i++) {
const element = childLinks[i];
const url = gsUtils.isSuspendedTab(tabToRemove)
? gsUtils.getOriginalUrl(tabToRemove.url)
: tabToRemove.url;
const url = tabToRemove.url || tabToRemove.pendingUrl;
const originalUrl = gsUtils.isSuspendedUrl(url)
? gsUtils.getOriginalUrl(url)
: url;

if (
element.getAttribute('data-url') === url ||
element.getAttribute('data-url') === originalUrl ||
element.getAttribute('data-tabId') == tabToRemove.id
) {
// eslint-disable-line eqeqeq
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_ext_extension_name__",
"description": "__MSG_ext_extension_description__",
"version": "7.1.5",
"version": "7.1.6",
"default_locale": "en",
"permissions": [
"tabs",
Expand Down

0 comments on commit e01643d

Please sign in to comment.