diff --git a/lib/clientBuilder.js b/lib/clientBuilder.js index c4d1fdbb4..bb7ecd89b 100644 --- a/lib/clientBuilder.js +++ b/lib/clientBuilder.js @@ -243,11 +243,9 @@ proto.fingerprint = function(options) { return deferred.resolve(msg.fingerprint); } if (msg.type === 'FingerprintServiceReady') { - if (iframe.contentWindow) { - iframe.contentWindow.postMessage(JSON.stringify({ - type: 'GetFingerprint' - }), sdk.options.url); - } + e.source.postMessage(JSON.stringify({ + type: 'GetFingerprint' + }), e.origin); } } oauthUtil.addListener(window, 'message', listener); diff --git a/test/spec/fingerprint.js b/test/spec/fingerprint.js index 680ad9073..0ed7777a1 100644 --- a/test/spec/fingerprint.js +++ b/test/spec/fingerprint.js @@ -25,9 +25,6 @@ define(function(require) { test.iframe = { style: {}, - contentWindow: { - postMessage: postMessageSpy - }, parentElement: { removeChild: jasmine.createSpy('removeChild') } @@ -55,7 +52,10 @@ define(function(require) { data: options.firstMessage || JSON.stringify({ type: 'FingerprintServiceReady' }), - origin: 'http://example.okta.com' + origin: 'http://example.okta.com', + source: { + postMessage: postMessageSpy + } }); }); }); @@ -80,6 +80,7 @@ define(function(require) { expect(test.iframe.style.display).toEqual('none'); expect(test.iframe.src).toEqual('http://example.okta.com/auth/services/devicefingerprint'); expect(document.body.appendChild).toHaveBeenCalledWith(test.iframe); + expect(test.e.source.postMessage).toHaveBeenCalled(); expect(test.iframe.parentElement.removeChild).toHaveBeenCalled(); expect(fingerprint).toEqual('ABCD'); })