Skip to content

Commit

Permalink
❄️ Attempt to deflake messaging-handshake test (#30247)
Browse files Browse the repository at this point in the history
* attempt to deflake test

* decrease timeout time

* use default timeout
  • Loading branch information
zhouyx committed Sep 17, 2020
1 parent 7fc4261 commit 2738cde
Showing 1 changed file with 20 additions and 22 deletions.
Expand Up @@ -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',
Expand All @@ -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;
});
});
});
});

0 comments on commit 2738cde

Please sign in to comment.