mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +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 () => {
|
it("returns early if the script is filling within a sand boxed iframe", async () => {
|
||||||
Object.defineProperty(globalThis, "frameElement", {
|
Object.defineProperty(globalThis, "frameElement", {
|
||||||
value: { hasAttribute: jest.fn(() => true) },
|
value: {
|
||||||
|
getAttribute: jest.fn(() => ""),
|
||||||
|
},
|
||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
jest.spyOn(insertAutofillContentService as any, "userCancelledInsecureUrlAutofill");
|
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.
|
* Determines if the current context is within a sandboxed iframe.
|
||||||
*/
|
*/
|
||||||
export function currentlyInSandboxedIframe(): boolean {
|
export function currentlyInSandboxedIframe(): boolean {
|
||||||
return (
|
if (String(self.origin).toLowerCase() === "null" || globalThis.location.hostname === "") {
|
||||||
String(self.origin).toLowerCase() === "null" ||
|
return true;
|
||||||
globalThis.frameElement?.hasAttribute("sandbox") ||
|
}
|
||||||
globalThis.location.hostname === ""
|
|
||||||
);
|
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