Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ad test failures #8969

Merged
merged 5 commits into from
Apr 27, 2017
Merged

Ad test failures #8969

merged 5 commits into from
Apr 27, 2017

Conversation

jridgewell
Copy link
Contributor

3 things:

  • Skips A4A's with multiple slots test (/cc @tdrl)
  • Improves createIframeWithMessageStub so that exact matches are not necessary (callback can be provided to check/assert the message is the intended one)
    • This should help us determine if it's not receiving the embed-size messages, or if it's not getting the exact right string back
  • Fixes the shoddy amp-ad-3p-impl preconnectCallback test

Closes #8965 and competes with #8968.

expectMsg = JSON.stringify(expectMsg);
actualMsg = JSON.stringify(actualMsg);
element.expectMessageFromParent = (type, callback) => {
if (typeof type === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is so confusing... 😖 why can't weseparatee them to two functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's argument reordering, so that you could pass a type, callback, or type and callback.

Copy link
Contributor

@zhouyx zhouyx Apr 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's not very straightforward for people to use in tests. For example I would have to go through the code to figure out what a callback function should look like.
Maybe update the comment for the function description? At least we should document it clearly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. Note: I just found one thing, the callback function is only used for testing expectMessageFromParent function. Do we really need it?

@@ -19,11 +19,12 @@ import {
expectPostMessage,
} from '../../testing/iframe';

describe('test-iframe-createIframeWithMessageStub', () => {
describe.only('test-iframe-createIframeWithMessageStub', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove only

@@ -216,7 +216,8 @@ describes.sandboxed('amp-ad-network-adsense-impl', {}, () => {
});
// Not using arrow function here because otherwise the way closure behaves
// prevents me from calling this.timeout(5000).
it('with multiple slots', function() {
// TODO(@tdrl, #8965): Make this pass reliably on Travis.
it.skip('with multiple slots', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about we only skip it on old chrome?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this to make A4A fix it faster. 😈

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL. so 😈 !

ad3p.buildCallback();
ad3p.preconnectCallback();
setTimeout(() => {
return whenFirstVisible.then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the reason why the test is flaky? I can't see why

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be 1 of two things:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! that's a good catch!!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jridgewell could you further explain what does "setTimeout is throttled" mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chrome throttles weirdly. 🤷‍♂️

win.addEventListener('message', listener);
});
};

function returnTrue() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used?

return 'type' in data && data.type == type;
};
} else if (!callback) {
filter = callbackOrType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when is this get called?

filter = (data) => {
return 'type' in data && data.type == type;
};
} else if (!callback) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops.

@zhouyx
Copy link
Contributor

zhouyx commented Apr 26, 2017

LGTM to @lannka

@jridgewell jridgewell merged commit 1ad7fb4 into ampproject:master Apr 27, 2017
@jridgewell jridgewell deleted the ad-test-failuers branch April 27, 2017 00:50
@jridgewell jridgewell mentioned this pull request Apr 27, 2017
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* Fix amp-ad-3p-impl preconnectCallback

* Fixup createIframeWithMessageStub

* lint

* lint

* Simplfy expectMessageFromParent callback
KenneyE pushed a commit to spotxchange/amphtml that referenced this pull request May 3, 2017
* Fix amp-ad-3p-impl preconnectCallback

* Fixup createIframeWithMessageStub

* lint

* lint

* Simplfy expectMessageFromParent callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants