Skip to content

Commit bfe1ddc

Browse files
committed
Work around for unpredictable content script execution order.
1 parent 8169a7f commit bfe1ddc

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/content/staticNS.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@
4141
//, document.domain, document.baseURI, window.isSecureContext // DEV_ONLY
4242
);
4343

44-
if (this.syncFetchPolicy) { // ftp: or file: - no CSP headers yet
45-
this.syncFetchPolicy();
44+
if (/^(ftp|file):/.test(url)) { // ftp: or file: - no CSP headers yet
45+
if (this.syncFetchPolicy) {
46+
this.syncFetchPolicy();
47+
} else { // additional content scripts not loaded yet
48+
log("Waiting for syncFetchPolicy to load...");
49+
this.pendingFetchPolicy = true;
50+
return;
51+
}
4652
} else {
4753
// CSP headers have been already provided by webRequest, we are not in a hurry...
4854
if (/^(javascript|about):/.test(url)) {

src/content/syncFetchPolicy.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,9 @@
143143
error("Background page not ready yet, retrying to fetch policy...")
144144
}
145145
}
146+
};
147+
148+
if (this.ns.pendingSyncFetchPolicy) {
149+
this.ns.pendingSyncFetchPolicy = false;
150+
this.ns.syncFetchPolicy();
146151
}

0 commit comments

Comments
 (0)