mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
[PM-12619] Passkey script cleanup process triggers breaking behavior in websites (#11304)
This commit is contained in:
@@ -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();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user