[PM-12619] Passkey script cleanup process triggers breaking behavior in websites (#11304)

This commit is contained in:
Cesar Gonzalez 2024-10-01 07:27:07 -05:00 committed by GitHub
parent 0846c2c822
commit 7108a34ac0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 0 additions and 25 deletions

View File

@ -57,19 +57,4 @@ describe("FIDO2 page-script for manifest v2", () => {
); );
expect(createdScriptElement.src).toBe(`chrome-extension://id/${Fido2ContentScript.PageScript}`); expect(createdScriptElement.src).toBe(`chrome-extension://id/${Fido2ContentScript.PageScript}`);
}); });
it("removes the appended `page-script.js` file after the script has triggered a load event", () => {
createdScriptElement = document.createElement("script");
jest.spyOn(window.document, "createElement").mockImplementation((element) => {
return createdScriptElement;
});
require("./fido2-page-script-append.mv2");
jest.spyOn(createdScriptElement, "remove");
createdScriptElement.dispatchEvent(new Event("load"));
jest.runAllTimers();
expect(createdScriptElement.remove).toHaveBeenCalled();
});
}); });

View File

@ -9,13 +9,8 @@
const script = globalContext.document.createElement("script"); const script = globalContext.document.createElement("script");
script.src = chrome.runtime.getURL("content/fido2-page-script.js"); script.src = chrome.runtime.getURL("content/fido2-page-script.js");
script.addEventListener("load", removeScriptOnLoad);
const scriptInsertionPoint = const scriptInsertionPoint =
globalContext.document.head || globalContext.document.documentElement; globalContext.document.head || globalContext.document.documentElement;
scriptInsertionPoint.prepend(script); scriptInsertionPoint.prepend(script);
function removeScriptOnLoad() {
globalThis.setTimeout(() => script?.remove(), 5000);
}
})(globalThis); })(globalThis);

View File

@ -9,7 +9,6 @@
const script = globalContext.document.createElement("script"); const script = globalContext.document.createElement("script");
script.src = chrome.runtime.getURL("content/fido2-page-script.js"); script.src = chrome.runtime.getURL("content/fido2-page-script.js");
script.addEventListener("load", removeScriptOnLoad);
// We are ensuring that the script injection is delayed in the event that we are loading // We are ensuring that the script injection is delayed in the event that we are loading
// within an iframe element. This prevents an issue with web mail clients that load content // within an iframe element. This prevents an issue with web mail clients that load content
@ -29,8 +28,4 @@
globalContext.document.head || globalContext.document.documentElement; globalContext.document.head || globalContext.document.documentElement;
scriptInsertionPoint.prepend(script); scriptInsertionPoint.prepend(script);
} }
function removeScriptOnLoad() {
globalThis.setTimeout(() => script?.remove(), 5000);
}
})(globalThis); })(globalThis);