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

Changed amp3pSentinel to sentinel with exp flag #6922

Merged
merged 13 commits into from
Jan 18, 2017
Merged

Changed amp3pSentinel to sentinel with exp flag #6922

merged 13 commits into from
Jan 18, 2017

Conversation

bradfrizzell
Copy link
Contributor

@bradfrizzell bradfrizzell commented Jan 6, 2017

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.

Copy link
Contributor

@jridgewell jridgewell left a 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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');
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto scenarios.

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

if (event.data.amp3pSentinel) {
var sentinel = event.data.amp3pSentinel;
} else {
var sentinel = event.data.amp3pSentinel;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean .sentinel?

Copy link
Contributor Author

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;
Copy link
Contributor

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).

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

@@ -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) {
Copy link
Contributor

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'])

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

@@ -46,6 +46,7 @@ describe('3p-frame', () => {
*/
const iframeContextInName = isExperimentOn(
window, '3p-frame-context-in-name');
const sentinelNameChange = isExperimentOn(window, 'sentinel-name-change');
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto scenarios.

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

@@ -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');
Copy link
Contributor

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?

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

@@ -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');
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

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

var sentinel = event.data.is3p ? event.data.amp3pSentinel : 'amp';
var sentinel;
if (event.data.is3p) {
sentinel = event.data.amp3pSentinel ? event.data.amp3pSentinel :
Copy link
Contributor

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.

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

@@ -34,14 +40,15 @@
width: event.data.width,
}, '*');
} else if (event.data.type == 'subscribeToEmbedState') {
var sentinel;
if (event.data.is3p) {
if (event.data.amp3pSentinel) {
Copy link
Contributor

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?

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

version: '$internalRuntimeVersion$',
};
if (sentinelName == 'sentinel') {
toggleExperiment(window, 'sentinel-name-change', true);
Copy link
Contributor

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.

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

@@ -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[
Copy link
Contributor

Choose a reason for hiding this comment

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

a bad merge?

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'm not sure what your concern is, could you elaborate?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh i see. nvm

jridgewell
jridgewell previously approved these changes Jan 13, 2017
Copy link
Contributor

@jridgewell jridgewell left a 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.

Copy link
Contributor

@lannka lannka left a 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;
Copy link
Contributor

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;

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

@@ -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) {
Copy link
Contributor

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.

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

@@ -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[
Copy link
Contributor

Choose a reason for hiding this comment

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

oh i see. nvm

@bradfrizzell
Copy link
Contributor Author

ping @lannka

@bradfrizzell
Copy link
Contributor Author

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',
Copy link
Contributor

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?

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 was getting a presubmit failure due to dist.3p/current/integration.js without these.

@lannka
Copy link
Contributor

lannka commented Jan 18, 2017

the PR looks good now.
@bradfrizzell If you can confirm that you tested all the examples in ads.amp.max.html and no new error messages show up in console, I will go ahead and merge.

@bradfrizzell
Copy link
Contributor Author

compared it against master, seeing all the same errors / warnings. looks fine to me

@lannka lannka merged commit fe7e0ae into ampproject:master Jan 18, 2017
@bradfrizzell bradfrizzell deleted the frizz-ac-switch-to-sentinel branch January 19, 2017 16:07
jridgewell pushed a commit to jridgewell/amphtml that referenced this pull request Jan 31, 2017
* 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
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants