diff --git a/src/child/props.js b/src/child/props.js index e1907747..335a2fc3 100644 --- a/src/child/props.js +++ b/src/child/props.js @@ -87,10 +87,16 @@ export function normalizeChildProps( ? prop.trustedDomains.includes(getDomain(window)) : origin === getDomain(window) || isSameDomain(parentComponentWindow); + // let trustedDomains override sameDomain prop if (prop && prop.sameDomain && !trustedChild) { continue; } + // sameDomain was not set and trusted domains must match + if (prop && prop.trustedDomains && !trustedChild) { + continue; + } + // $FlowFixMe const value = normalizeChildProp(propsDef, props, key, props[key], helpers); diff --git a/src/parent/parent.js b/src/parent/parent.js index 1583e2c6..ba48e244 100644 --- a/src/parent/parent.js +++ b/src/parent/parent.js @@ -383,10 +383,16 @@ export function parentComponent({ ? prop.trustedDomains.includes(initialChildDomain) : matchDomain(initialChildDomain, getDomain(window)); + // let trustedDomains override sameDomain prop if (prop && prop.sameDomain && !trustedChild) { continue; } + // sameDomain was not set and trusted domains must match + if (prop && prop.trustedDomains && !trustedChild) { + continue; + } + result[key] = props[key]; } diff --git a/test/tests/domain.js b/test/tests/domain.js index 38389de9..cb414890 100644 --- a/test/tests/domain.js +++ b/test/tests/domain.js @@ -68,7 +68,7 @@ describe("parent domain check", () => { return component().render(getBody()); }); - it("allowedParentDomains is specified as a regex and parent domian match", () => { + it("allowedParentDomains is specified as a regex and parent domain match", () => { window.__component__ = () => { return zoid.create({ tag: "test-parent-domain-regex", @@ -163,7 +163,7 @@ describe("parent domain check", () => { }); }); - it("xprops.getParentDomain should pass the correct domain", () => { + it("xprops.getParent should pass the correct domain", () => { return wrapPromise(({ expect }) => { window.__component__ = () => { return zoid.create({ diff --git a/test/tests/props.js b/test/tests/props.js index a1ee8e32..6c4324e5 100644 --- a/test/tests/props.js +++ b/test/tests/props.js @@ -802,7 +802,7 @@ describe("zoid props cases", () => { props: { foo: { type: "string", - trustedDomains: ["mock://venmo.com"], + trustedDomains: ["mock://www.child.com"], }, }, }); @@ -817,7 +817,6 @@ describe("zoid props cases", () => { } }), run: () => ` - window.location = "mock://venmo.com"; window.xprops.passProp(window.xprops.foo); `, }); @@ -850,7 +849,6 @@ describe("zoid props cases", () => { } }), run: () => ` - window.location = "mock://venmo.com"; window.xprops.passProp(window.xprops.foo); `, });