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
Conversation
@@ -269,6 +287,8 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A { | |||
|
|||
/** @private {number} */ | |||
this.ifi_ = 0; | |||
|
|||
this.viewer_ = Services.viewerForDoc(this.getAmpDoc()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, updated name
looking... |
There was a problem hiding this 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>} */ ({}); |
There was a problem hiding this comment.
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']) { |
There was a problem hiding this comment.
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
).
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
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