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
allow firebase for 3p frames #25092
allow firebase for 3p frames #25092
Conversation
Hi @rsimha and @lannka ! Apologies for the unconventional way of filing what is actually a feature request. I tried to make ads work on firebase demos by prepending a |
Here's a high level question: What does
I think this is due to #24471, where @lannka removed the code that automatically adds |
I forgot about the PR deploy bot! Maybe we should update our documentation in TESTING.md to make the PR Deploy Bot more discoverable, so we can start deprecating the firebase demo deployment once it's gotten more usage across the board. We can start by adding a line referencing it under the Firebase documentation encouraging people to try it out instead. @leafsy is currently using this for iterating on a bug bash. I guess the reality of our current use case is that we may push a lot of small updates to a demo, but not wish to have spam an in Review PR with a lot of small commits and force-pushes. If we start using PR deploy bot for this use case, our repo might begin to have a lot of demo Draft PRs that are not intended for merge. I tried the PR Deploy Bot on this PR, and it seems to suffer from a different issue for ads. None of the ads display on: https://storage.googleapis.com/amp-test-website-1/amp_dist_65323/examples/ads.amp.html |
9a7e034
to
4f7e6f4
Compare
build-system/tasks/helpers.js
Outdated
@@ -75,6 +75,7 @@ const UNMINIFIED_TARGETS = [ | |||
'amp-inabox.js', | |||
'amp-shadow.js', | |||
'amp.js', | |||
'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.
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.
@cathyxz / @lannka: Are we sure we don't want to add this for minified builds as well for consistency between gulp build
and gulp dist
? (The minified equivalent is f.js
.)
I ask because several of our tests are able to switch between --compiled
mode and regular mode, and I'm concerned that this might break some assumptions in code (not sure what they might be).
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.
Got it. I'll add in f.js
for consistency.
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 list is now different from the one used by our internal release scripts. (See cl/269449844.)
@lannka @erwinmombay @jridgewell @danielrozenberg Do we want to change that list too? (I don't fully understand how AMP_CONFIG
is used by the 3p frame.)
Updated the PR description. Could @estherkim, @rsimha and @lannka please take a look? |
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.
Couple comments. I'm approving to unblock.
build-system/tasks/firebase.js
Outdated
const result = data.replace( | ||
'self.AMP_CONFIG={', | ||
'self.AMP_CONFIG={"thirdPartyUrl":location.origin,' | ||
// eslint-disable-next-line prettier/prettier | ||
'self.AMP_CONFIG={"thirdPartyUrl":location.origin,"thirdPartyFrameRegex": "^.*\.firebaseapp\.com$",' |
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 believe you need a double-backslash here for a single-backslash to appear in the AMP_CONFIG
that's written to file.
'self.AMP_CONFIG={"thirdPartyUrl":location.origin,"thirdPartyFrameRegex": "^.*\\.firebaseapp\\.com$",'
If that works, the eslint-disable-next-line prettier/prettier
in the line above will no longer be necessary.
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.
Based on a new approach, I've actually removed this code altogether. Let me know if this approach works better.
build-system/tasks/helpers.js
Outdated
@@ -75,6 +75,7 @@ const UNMINIFIED_TARGETS = [ | |||
'amp-inabox.js', | |||
'amp-shadow.js', | |||
'amp.js', | |||
'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.
This list is now different from the one used by our internal release scripts. (See cl/269449844.)
@lannka @erwinmombay @jridgewell @danielrozenberg Do we want to change that list too? (I don't fully understand how AMP_CONFIG
is used by the 3p frame.)
After some more digging, I found a way that does not need us to modify the prepend targets in our build process. We can just call |
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 think this might be a better approach that won't have these side effects.
It certainly is! LGTM! (Can you update the description to reflect the new approach?)
I think Owners Bot requires @mrjoro to approve the documentation changes. PTAL? |
Updated the PR description and crossed out all the legacy stuff. Pending an LGTM from @mrjoro for documentation changes. |
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.
Doc changed look good!
Thank you! |
* allow firebase for 3p frames * Prepend AMP_CONFIG to integration.js * Add comments * Add f.js for consistency * localize changes to firebase only * Wait for async function * Add documentation
* allow firebase for 3p frames * Prepend AMP_CONFIG to integration.js * Add comments * Add f.js for consistency * localize changes to firebase only * Wait for async function * Add documentation
* allow firebase for 3p frames * Prepend AMP_CONFIG to integration.js * Add comments * Add f.js for consistency * localize changes to firebase only * Wait for async function * Add documentation
Added a
fortesting
option togulp firebase
to enable testing ads on custom domains.Legacy description
The following are outdated descriptions of this PR.
Take 2
This PR does the following:1. Re-addsintegration.js
andf.js
to the list of files that we prependAMP_CONFIG
to.2. Adds code infirebase.js
to addfirebase
to the list of allowed 3rd party urls and 3rd party frame regexes so that ads can work on firebase.Filed:
Take 1
I wanted to make testing
amp-ad
work for firebase deployments. They're currently failing here:amphtml/3p/integration.js
Lines 719 to 740 in 3e6457f
The example that I'm using isexamples/amp-ads.amp.html
.We currently have a section in
firebase.js
that appends"thirdPartyUrl":location.origin
toAMP_CONFIG
. My initial approach here was just to add another modification that would append"thirdPartyFrameRegex": "^.*\.firebaseapp\.com$"
, which would enable it to pass this test:amphtml/3p/integration.js
Line 726 in 3e6457f
However, by inspecting the output ofurls
inintegration.js
andurls
inconfig.js
I'm noticing a race condition. I'm observing that sometimes theurls
object reflects the contents of theAMP_CONFIG
appended toamp.js
, and sometimes it does not (nolocalDev: "true"
, nothirdPartyUrl
, nothirdPartyFrameRegex
). It seems likeintegration.js
is trying to accessurls
beforeconfig.js
has had a chance to read from theAMP_CONFIG
object. I'm wondering if there's a race condition somewhere.I also noted that inenableLocalDev
, there's the option to specify a TEST_HOST with env.AMP_TEST_HOST. Is there a documented way to use this to enable ads on a demo url?amphtml/build-system/tasks/prepend-global/index.js
Lines 181 to 205 in f515760