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