From 2738cdebfb2dc0bf42044244c35cfcb75beeaa44 Mon Sep 17 00:00:00 2001 From: Yuxuan Zhou Date: Thu, 17 Sep 2020 12:04:48 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9D=84=EF=B8=8F=20Attempt=20to=20deflake=20m?= =?UTF-8?q?essaging-handshake=20test=20(#30247)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * attempt to deflake test * decrease timeout time * use default timeout --- .../integration/test-messaging-handshake.js | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/extensions/amp-viewer-integration/0.1/test/integration/test-messaging-handshake.js b/extensions/amp-viewer-integration/0.1/test/integration/test-messaging-handshake.js index f32aefc61c53..83822fe997e2 100644 --- a/extensions/amp-viewer-integration/0.1/test/integration/test-messaging-handshake.js +++ b/extensions/amp-viewer-integration/0.1/test/integration/test-messaging-handshake.js @@ -87,29 +87,7 @@ describes.sandboxed('AmpViewerMessagingIntegration', {}, () => { }); }); - it('should fail if messaging token is wrong', () => { - const params = serializeQueryString({ - origin: getWinOrigin(window), - messagingToken: 'foo', - }); - const ampDocUrl = `${iframeOrigin}${ampDocSrc}#${params}`; - viewerIframe.setAttribute('src', ampDocUrl); - - return Messaging.waitForHandshakeFromDocument( - window, - viewerIframe.contentWindow, - iframeOrigin, - 'bar' - ).then((messaging) => { - const handlerStub = window.sandbox.stub(); - messaging.setDefaultHandler(handlerStub); - expect(handlerStub).to.not.have.been.called; - }); - }); - it('should perform polling handshake', function () { - this.timeout(10000); - const params = serializeQueryString({ origin: getWinOrigin(window), cap: 'handshakepoll', @@ -130,5 +108,25 @@ describes.sandboxed('AmpViewerMessagingIntegration', {}, () => { expect(name).to.equal('documentLoaded'); }); }); + + it('should fail if messaging token is wrong', () => { + const params = serializeQueryString({ + origin: getWinOrigin(window), + messagingToken: 'foo', + }); + const ampDocUrl = `${iframeOrigin}${ampDocSrc}#${params}`; + viewerIframe.setAttribute('src', ampDocUrl); + + return Messaging.waitForHandshakeFromDocument( + window, + viewerIframe.contentWindow, + iframeOrigin, + 'bar' + ).then((messaging) => { + const handlerStub = window.sandbox.stub(); + messaging.setDefaultHandler(handlerStub); + expect(handlerStub).to.not.have.been.called; + }); + }); }); });