use tab.pendingUrl (#1040)
This commit is contained in:
parent
aa43507478
commit
fa1496ecb8
|
@ -328,7 +328,7 @@ function openManage({options = false, search} = {}) {
|
|||
if (tab) {
|
||||
return Promise.all([
|
||||
activateTab(tab),
|
||||
tab.url !== url && msg.sendTab(tab.id, {method: 'pushState', url})
|
||||
(tab.pendingUrl || tab.url) !== url && msg.sendTab(tab.id, {method: 'pushState', url})
|
||||
.catch(console.error)
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -58,13 +58,13 @@ const contentScripts = (() => {
|
|||
return browser.tabs.query({}).then(tabs => {
|
||||
for (const tab of tabs) {
|
||||
// skip unloaded/discarded/chrome tabs
|
||||
if (!tab.width || tab.discarded || !URLS.supported(tab.url)) continue;
|
||||
if (!tab.width || tab.discarded || !URLS.supported(tab.pendingUrl || tab.url)) continue;
|
||||
// our content scripts may still be pending injection at browser start so it's too early to ping them
|
||||
if (tab.status === 'loading') {
|
||||
trackBusyTab(tab.id, true);
|
||||
} else {
|
||||
injectToTab({
|
||||
url: tab.url,
|
||||
url: tab.pendingUrl || tab.url,
|
||||
tabId: tab.id
|
||||
});
|
||||
}
|
||||
|
|
|
@ -49,8 +49,9 @@ const navigatorUtil = (() => {
|
|||
}
|
||||
return browser.tabs.get(data.tabId)
|
||||
.then(tab => {
|
||||
if (tab.url === 'chrome://newtab/') {
|
||||
data.url = tab.url;
|
||||
const url = tab.pendingUrl || tab.url;
|
||||
if (url === 'chrome://newtab/') {
|
||||
data.url = url;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -67,8 +67,7 @@ const regExpTester = (() => {
|
|||
});
|
||||
const getMatchInfo = m => m && {text: m[0], pos: m.index};
|
||||
browser.tabs.query({}).then(tabs => {
|
||||
const supported = tabs.map(tab => tab.url)
|
||||
.filter(url => URLS.supported(url));
|
||||
const supported = tabs.map(tab => tab.pendingUrl || tab.url).filter(URLS.supported);
|
||||
const unique = [...new Set(supported).values()];
|
||||
for (const rxData of regexps) {
|
||||
const {rx, urls} = rxData;
|
||||
|
|
|
@ -132,7 +132,7 @@ function findExistingTab({url, currentWindow, ignoreHash = true, ignoreSearch =
|
|||
.then(tabs => tabs.find(matchTab));
|
||||
|
||||
function matchTab(tab) {
|
||||
const tabUrl = new URL(tab.url);
|
||||
const tabUrl = new URL(tab.pendingUrl || tab.url);
|
||||
return tabUrl.protocol === url.protocol &&
|
||||
tabUrl.username === url.username &&
|
||||
tabUrl.password === url.password &&
|
||||
|
@ -175,7 +175,7 @@ function openURL({
|
|||
index,
|
||||
openerTabId,
|
||||
// when hash is different we can only set `url` if it has # otherwise the tab would reload
|
||||
url: url !== tab.url && url.includes('#') ? url : undefined,
|
||||
url: url !== (tab.pendingUrl || tab.url) && url.includes('#') ? url : undefined,
|
||||
});
|
||||
}
|
||||
if (newWindow && browser.windows) {
|
||||
|
@ -200,10 +200,9 @@ function openURL({
|
|||
// except when new URL is chrome:// or chrome-extension:// and the empty tab is
|
||||
// in incognito
|
||||
function isTabReplaceable(tab, newUrl) {
|
||||
if (!tab || !URLS.emptyTab.includes(tab.url)) {
|
||||
if (!tab || !URLS.emptyTab.includes(tab.pendingUrl || tab.url)) {
|
||||
return false;
|
||||
}
|
||||
// FIXME: but why?
|
||||
if (tab.incognito && newUrl.startsWith('chrome')) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -106,12 +106,13 @@ self.msg = self.INJECTED === 1 ? self.msg : (() => {
|
|||
.then(tabs => {
|
||||
const requests = [];
|
||||
for (const tab of tabs) {
|
||||
const isExtension = tab.url.startsWith(EXTENSION_URL);
|
||||
const tabUrl = tab.pendingUrl || tab.url;
|
||||
const isExtension = tabUrl.startsWith(EXTENSION_URL);
|
||||
if (
|
||||
tab.discarded ||
|
||||
// FIXME: use `URLS.supported`?
|
||||
!/^(http|ftp|file)/.test(tab.url) &&
|
||||
!tab.url.startsWith('chrome://newtab/') &&
|
||||
!/^(http|ftp|file)/.test(tabUrl) &&
|
||||
!tabUrl.startsWith('chrome://newtab/') &&
|
||||
!isExtension ||
|
||||
isExtension && ignoreExtension ||
|
||||
filter && !filter(tab)
|
||||
|
|
Loading…
Reference in New Issue
Block a user