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

Fast Fetch Doubleclick experiment that clears correlator on page pause #10708

Merged
merged 6 commits into from Aug 1, 2017
Merged

Fast Fetch Doubleclick experiment that clears correlator on page pause #10708

merged 6 commits into from Aug 1, 2017

Conversation

keithwrightbos
Copy link
Contributor

Doubleclick Delayed Fetch clears window state when page is swiped between SERP viewer including correlator. However, this is not the case for Fast Fetch as the window state is maintained. Start 2%, client-side diverted experiment which clears correlator on pause page visibility change.

/cc @ampproject/a4a

@@ -269,6 +287,8 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A {

/** @private {number} */
this.ifi_ = 0;

this.viewer_ = Services.viewerForDoc(this.getAmpDoc());
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 only used in buildCallback, can you just make it a const within that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

height: '250',
width: '320',
});
document.body.appendChild(element);
Copy link
Contributor

Choose a reason for hiding this comment

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

You need an afterEach that deletes this element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should have been referencing fixture.doc which requires no cleanup as its within frame

});

it('clears if in experiment', () => {
impl.win.ampAdPageCorrelator = 12345;
Copy link
Contributor

Choose a reason for hiding this comment

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

can delete this line, it's in the beforeEach. I'd just replace with an expect for what it should be.

impl.buildCallback();
expect(onVisibilityChangedHandler).to.be.ok;
onVisibilityChangedHandler();
expect(isInExperiment(element, CORRELATOR_CLEAR_EXP_BRANCHES.CONTROL))
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't actually check the value of impl.win.ampAdPageCorrelator in this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

height: '250',
width: '320',
});
document.body.appendChild(elem2);
Copy link
Contributor

Choose a reason for hiding this comment

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

you also need to delete this at the end of the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified to use fixture document

impl.win.experimentBranches[CORRELATOR_CLEAR_EXP_NAME] === undefined);
});

it('only registers one on viewability change listener', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this testing? is this supposed to be 'only register one onVisibilityChangedHandler' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, updated name

@dvoytenko
Copy link
Contributor

looking...

Copy link
Contributor

@dvoytenko dvoytenko left a comment

Choose a reason for hiding this comment

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

Overall looks good. Some comments below.

// TODO(keithwrightbos,glevitzy) - determine behavior for correlator
// interaction with refresh.
const experimentInfoMap =
/** @type {!Object<string, !ExperimentInfo>} */ ({});
Copy link
Contributor

Choose a reason for hiding this comment

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

Use map()?

/** @override */
buildCallback() {
super.buildCallback();
if (this.win['dbclk_a4a_viz_change']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Overall, I'd prefer an ampdoc service b/c (a) it already supports one-per-doc logic, (b) it extends well to PWA/shadow docs, and (c) could be a good placeholder for other state instead of adding more stuff to global window (e.g. ampCorrelator).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will address in a subsequent PR as this is a larger change. I agree that having a dedicate service for state is a good idea.

expect(onVisibilityChangedHandler).to.be.ok;
onVisibilityChangedHandler();
expect(
impl.win.experimentBranches[CORRELATOR_CLEAR_EXP_NAME] !== undefined);
Copy link
Contributor

Choose a reason for hiding this comment

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

@keithwrightbos

This test has been silently failing, and I commented it out in #13424

Do we actually expect impl.win.experimentBranches[CORRELATOR_CLEAR_EXP_NAME] to be defined here?

(I haven't looked at the code in detail)

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.

None yet

6 participants