-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Changed amp3pSentinel to sentinel with exp flag #6922
Changed amp3pSentinel to sentinel with exp flag #6922
Conversation
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 definitely requires tests.
if (data.sentinel != win.context.amp3pSentinel) { | ||
if (sentinelNameChange && data.sentinel != win.context.sentinel) { | ||
return; | ||
} else if (data.sentinel != win.context.amp3pSentinel) { |
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 needs to check !sentinelNameChange
. As is, this will always fail when using the sentinel-name-change experiment is enabled.
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.
fixed
@@ -23,6 +23,9 @@ import {adopt} from '../../../../src/runtime'; | |||
import {facebook} from '../../../../3p/facebook'; | |||
import {setDefaultBootstrapBaseUrlForTesting} from '../../../../src/3p-frame'; | |||
import {resetServiceForTesting} from '../../../../src/service'; | |||
import {isExperimentOn} from '../../../../src/experiments'; | |||
|
|||
const sentinelNameChange = isExperimentOn(self, 'sentinel-name-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.
Ditto scenarios.
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
if (event.data.amp3pSentinel) { | ||
var sentinel = event.data.amp3pSentinel; | ||
} else { | ||
var sentinel = event.data.amp3pSentinel; |
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.
Do you mean .sentinel
?
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.
... yes ... >.<
fixed
var sentinel = event.data.is3p ? event.data.amp3pSentinel : 'amp'; | ||
if (event.data.is3p) { | ||
if (event.data.amp3pSentinel) { | ||
var sentinel = event.data.amp3pSentinel; |
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 var needs to be hoisted above the if (event.data.is3p)
.
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
@@ -157,8 +159,13 @@ export function getIframe(parentWindow, parentElement, opt_type, opt_context) { | |||
// Chrome does not reflect the iframe readystate. | |||
this.readyState = 'complete'; | |||
}; | |||
iframe.setAttribute( | |||
'data-amp-3p-sentinel', attributes._context.amp3pSentinel); | |||
if (sentinelNameChange) { |
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.
We can copy the same test from above:
iframe.setAttribute('data-amp-3p-sentinel', attributes._context[sentinelNameChange ? 'sentinel' : 'amp3pSentinel'])
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
@@ -46,6 +46,7 @@ describe('3p-frame', () => { | |||
*/ | |||
const iframeContextInName = isExperimentOn( | |||
window, '3p-frame-context-in-name'); | |||
const sentinelNameChange = isExperimentOn(window, 'sentinel-name-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.
Ditto scenarios.
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
@@ -58,6 +57,7 @@ function getFrameAttributes(parentWindow, element, opt_type, opt_context) { | |||
const width = element.getAttribute('width'); | |||
const height = element.getAttribute('height'); | |||
const type = opt_type || element.getAttribute('type'); | |||
const sentinelNameChange = isExperimentOn(self, 'sentinel-name-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.
This should be parentWindow
, right?
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
@@ -120,6 +120,8 @@ export function getIframe(parentWindow, parentElement, opt_type, opt_context) { | |||
const attributes = | |||
getFrameAttributes(parentWindow, parentElement, opt_type, opt_context); | |||
const iframe = parentWindow.document.createElement('iframe'); | |||
const sentinelNameChange = isExperimentOn(self, 'sentinel-name-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.
Ditto.
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
var sentinel = event.data.is3p ? event.data.amp3pSentinel : 'amp'; | ||
var sentinel; | ||
if (event.data.is3p) { | ||
sentinel = event.data.amp3pSentinel ? event.data.amp3pSentinel : |
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.
Nit: sentinel = event.data.amp3pSentinel || event.data.sentinel
.
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
@@ -34,14 +40,15 @@ | |||
width: event.data.width, | |||
}, '*'); | |||
} else if (event.data.type == 'subscribeToEmbedState') { | |||
var sentinel; | |||
if (event.data.is3p) { | |||
if (event.data.amp3pSentinel) { |
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 we make this a conditional expression too?
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
version: '$internalRuntimeVersion$', | ||
}; | ||
if (sentinelName == 'sentinel') { | ||
toggleExperiment(window, 'sentinel-name-change', true); |
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.
We'll need to toggle off in an afterEach
.
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
@@ -157,8 +161,8 @@ export function getIframe(parentWindow, parentElement, opt_type, opt_context) { | |||
// Chrome does not reflect the iframe readystate. | |||
this.readyState = 'complete'; | |||
}; | |||
iframe.setAttribute( | |||
'data-amp-3p-sentinel', attributes._context.amp3pSentinel); | |||
iframe.setAttribute('data-amp-3p-sentinel', attributes._context[ |
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.
a bad merge?
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.
I'm not sure what your concern is, could you elaborate?
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.
I thought your other PR already removed all the data-amp-3p-sentinel attribute on the iframe, no?
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.
The sentinel refactor one does, but I was under the impression this one should go through first. Hence, this one still has it.
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.
oh i see. nvm
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.
LGTM, defering to @lannka.
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.
LGTM in general.
@@ -25,7 +25,8 @@ export function nonSensitiveDataPostMessage(type, opt_object) { | |||
} | |||
const object = opt_object || {}; | |||
object.type = type; | |||
object.sentinel = window.context.amp3pSentinel; | |||
object.sentinel = window.context.sentinel ? window.context.sentinel : | |||
window.context.amp3pSentinel; |
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.
object.sentinel = window.context.sentinel || window.context.amp3pSentinel;
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
@@ -79,7 +80,10 @@ function startListening(win) { | |||
// Parse JSON only once per message. | |||
const data = /** @type {!Object} */ ( | |||
JSON.parse(event.data.substr(4))); | |||
if (data.sentinel != win.context.amp3pSentinel) { | |||
if (win.context.sentinel && data.sentinel != win.context.sentinel) { |
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.
to make things simple, shall we just do
win.context.sentinel = win.context.sentinel || win.context.amp3pSentinel
during initialization stage.
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
@@ -157,8 +161,8 @@ export function getIframe(parentWindow, parentElement, opt_type, opt_context) { | |||
// Chrome does not reflect the iframe readystate. | |||
this.readyState = 'complete'; | |||
}; | |||
iframe.setAttribute( | |||
'data-amp-3p-sentinel', attributes._context.amp3pSentinel); | |||
iframe.setAttribute('data-amp-3p-sentinel', attributes._context[ |
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.
oh i see. nvm
ping @lannka |
ha, whoops! sorry about the ping! I sent it a split second after your review came through. what are the odds of that? |
@@ -335,6 +337,7 @@ var forbiddenTerms = { | |||
'extensions/amp-analytics/0.1/cid-impl.js', | |||
'src/cookies.js', | |||
'src/experiments.js', | |||
'dist.3p/current/integration.js', |
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.
are changes in this file needed?
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.
I was getting a presubmit failure due to dist.3p/current/integration.js without these.
the PR looks good now. |
compared it against master, seeing all the same errors / warnings. looks fine to me |
* Changed amp3pSentinel to sentinel with exp flag * Fixed flagging all uses of amp3pSentinel to sentinel change * Fixed presubmit issues * Whitelisted dist.3p/current/integration.js for cookie related presubmit stuff * Fixed dependency issue * Properly test both cases of the experiment * Added cleanup issue * Fixed lint issue * Addressed comments to test both cases of experiment * Fixed toggling off exp and using correct win * Removed unneeded complexity * Reverted presubmit-checks
* Changed amp3pSentinel to sentinel with exp flag * Fixed flagging all uses of amp3pSentinel to sentinel change * Fixed presubmit issues * Whitelisted dist.3p/current/integration.js for cookie related presubmit stuff * Fixed dependency issue * Properly test both cases of the experiment * Added cleanup issue * Fixed lint issue * Addressed comments to test both cases of experiment * Fixed toggling off exp and using correct win * Removed unneeded complexity * Reverted presubmit-checks
Changed the use of amp3pSentinel to instead just sentinel, because it is no longer just a 3p use case. Put an experiment flag to make sure this change is easy to revert. Still need to add cleanup issue.