File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,7 @@ export default class Client {
326326 this . _source = options . source || ( this . _parent && this . _parent . _source ) || window . parent
327327 this . _appGuid = options . appGuid || ( this . _parent && this . _parent . _appGuid )
328328 this . _instanceGuid = options . instanceGuid || this . _appGuid
329+ this . _allowOrigin = options . allowOrigin || false
329330 this . _messageHandlers = { }
330331 this . _repliesPending = { }
331332 this . _instanceClients = { }
@@ -335,7 +336,7 @@ export default class Client {
335336 this . _idleState = null
336337 this . ready = false
337338
338- if ( ! isOriginValid ( this . _origin ) ) {
339+ if ( ! this . _allowOrigin && ! isOriginValid ( this . _origin ) ) {
339340 const originHostname = new URL ( this . _origin ) . hostname
340341 this . postMessage ( '__track__' , {
341342 event_name : 'invalid_sdk_origin' ,
Original file line number Diff line number Diff line change @@ -27,15 +27,17 @@ import { queryParameters } from './utils'
2727 */
2828
2929const ZAFClient = {
30- init : function ( callback , loc ) {
30+ init : function ( callback , loc , options ) {
3131 loc = loc || window . location
32+ options = options || { }
33+ const allowOrigin = options . allowOrigin
3234 const queryParams = queryParameters ( loc . search )
3335 const hashParams = queryParameters ( loc . hash )
3436 const origin = queryParams . origin || hashParams . origin
3537 const appGuid = queryParams . app_guid || hashParams . app_guid
3638 if ( ! origin || ! appGuid ) { return false }
3739
38- const client = new Client ( { origin, appGuid } )
40+ const client = new Client ( { origin, appGuid, allowOrigin } )
3941
4042 if ( typeof callback === 'function' ) {
4143 client . on ( 'app.registered' , callback . bind ( client ) )
Original file line number Diff line number Diff line change @@ -177,6 +177,17 @@ describe('Client', () => {
177177 expect ( ACTUAL_ERROR_MSG ) . to . equal ( EXPECTED_ERROR_MSG )
178178 } )
179179 } )
180+
181+ it ( 'does not clear the iframe and append an error msg when allowOrigin is true' , ( ) => {
182+ const validOriginClient = new Client ( {
183+ origin : 'https://hostmapped.com' ,
184+ appGuid : 'appGuid' ,
185+ source : source ,
186+ allowOrigin : true
187+ } )
188+
189+ expect ( validOriginClient ) . to . exist ( )
190+ } )
180191 } )
181192
182193 describe ( 'initialisation' , ( ) => {
You can’t perform that action at this time.
0 commit comments