mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
Allow autofilling iframes like samsclub.com (#16560)
* Allow autofilling iframes like samsclub.com * Add back original checks * Remove unused mock
This commit is contained in:
@@ -153,7 +153,9 @@ describe("InsertAutofillContentService", () => {
|
||||
|
||||
it("returns early if the script is filling within a sand boxed iframe", async () => {
|
||||
Object.defineProperty(globalThis, "frameElement", {
|
||||
value: { hasAttribute: jest.fn(() => true) },
|
||||
value: {
|
||||
getAttribute: jest.fn(() => ""),
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
jest.spyOn(insertAutofillContentService as any, "userCancelledInsecureUrlAutofill");
|
||||
|
||||
@@ -499,11 +499,24 @@ export function isInvalidResponseStatusCode(statusCode: number) {
|
||||
* Determines if the current context is within a sandboxed iframe.
|
||||
*/
|
||||
export function currentlyInSandboxedIframe(): boolean {
|
||||
return (
|
||||
String(self.origin).toLowerCase() === "null" ||
|
||||
globalThis.frameElement?.hasAttribute("sandbox") ||
|
||||
globalThis.location.hostname === ""
|
||||
);
|
||||
if (String(self.origin).toLowerCase() === "null" || globalThis.location.hostname === "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
const sandbox = globalThis.frameElement?.getAttribute?.("sandbox");
|
||||
|
||||
// No frameElement or sandbox attribute means not sandboxed
|
||||
if (sandbox === null || sandbox === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// An empty string means fully sandboxed
|
||||
if (sandbox === "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
const tokens = new Set(sandbox.toLowerCase().split(" "));
|
||||
return !["allow-scripts", "allow-same-origin"].every((token) => tokens.has(token));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user