fixup! init main frame first
This commit is contained in:
parent
331779ad12
commit
fbf73a2368
|
@ -26,8 +26,8 @@ initTabUrls()
|
||||||
Promise.all([
|
Promise.all([
|
||||||
onDOMready().then(() => initPopup(frames)),
|
onDOMready().then(() => initPopup(frames)),
|
||||||
...frames
|
...frames
|
||||||
.filter(f => !f.isDupe)
|
.filter(f => f.url && !f.isDupe)
|
||||||
.map(({url}) => url && API.getStylesByUrl(url).then(styles => ({styles, url}))),
|
.map(({url}) => API.getStylesByUrl(url).then(styles => ({styles, url}))),
|
||||||
]))
|
]))
|
||||||
.then(([, ...results]) => {
|
.then(([, ...results]) => {
|
||||||
if (results[0]) {
|
if (results[0]) {
|
||||||
|
@ -204,11 +204,12 @@ function initPopup(frames) {
|
||||||
/** @param {chrome.webNavigation.GetAllFrameResultDetails[]} frames */
|
/** @param {chrome.webNavigation.GetAllFrameResultDetails[]} frames */
|
||||||
function sortTabFrames(frames) {
|
function sortTabFrames(frames) {
|
||||||
const unknown = new Map(frames.map(f => [f.frameId, f]));
|
const unknown = new Map(frames.map(f => [f.frameId, f]));
|
||||||
const known = new Map([[0, {frameId: 0}]]);
|
const known = new Map([[0, unknown.get(0) || {frameId: 0, url: ''}]]);
|
||||||
let lastSize = -1;
|
unknown.delete(0);
|
||||||
while (unknown.size && unknown.size !== lastSize) {
|
let lastSize = 0;
|
||||||
|
while (unknown.size !== lastSize) {
|
||||||
for (const [frameId, f] of unknown) {
|
for (const [frameId, f] of unknown) {
|
||||||
if (known.has(f.parentFrameId) || f.parentFrameId < 0) {
|
if (known.has(f.parentFrameId)) {
|
||||||
known.set(frameId, f);
|
known.set(frameId, f);
|
||||||
unknown.delete(frameId);
|
unknown.delete(frameId);
|
||||||
if (f.url === ABOUT_BLANK) f.url = known.get(f.parentFrameId).url;
|
if (f.url === ABOUT_BLANK) f.url = known.get(f.parentFrameId).url;
|
||||||
|
@ -219,7 +220,7 @@ function sortTabFrames(frames) {
|
||||||
const sortedFrames = [...known.values(), ...unknown.values()];
|
const sortedFrames = [...known.values(), ...unknown.values()];
|
||||||
const urls = new Set([ABOUT_BLANK]);
|
const urls = new Set([ABOUT_BLANK]);
|
||||||
for (const f of sortedFrames) {
|
for (const f of sortedFrames) {
|
||||||
f.url = f.url || '';
|
if (!f.url) f.url = '';
|
||||||
f.isDupe = urls.has(f.url);
|
f.isDupe = urls.has(f.url);
|
||||||
urls.add(f.url);
|
urls.add(f.url);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user