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
AMP Ad Refresh #9535
Merged
+1,113
−133
Merged
AMP Ad Refresh #9535
Changes from all commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
b1f409f
Initial commit.
glevitzky f6ccd65
Work on refresher.
glevitzky 7b0bba6
RefreshManager v0 complete.
glevitzky dc2c128
Tests for refresh-manager.
glevitzky bab9dd8
Modified RefreshManager to support multiple IOs, each configured with…
glevitzky 10290d3
Removed test file.
glevitzky a0eb2b1
Comment update.
glevitzky b2dd090
Added refresh logic to amp-a4a.
glevitzky f52b639
Removed test page.
glevitzky f74863e
Removed test page (for real this time).
glevitzky 7e91124
Fixed issue with loader persisting; no-fills continue to show previou…
glevitzky f524990
Addressing PR feedback: mostly annotation fixes.
glevitzky 5289054
Drastically simplified RefreshManager with analytics' visibility mana…
glevitzky 23b08da
Added config parsing + example page.
glevitzky 7d0a3d8
No longer calling lifecycle methods directly.
glevitzky 6ce28f4
Made adPomise_ private again. Fixed comment.
glevitzky 56a4ab7
No longer calling layoutCallback directly.
glevitzky e1b4d2f
Removed loop from getRefreshConfiguration().
glevitzky fba1588
Removed backup file.
glevitzky fc6facd
Shuffled code around from AmpA4A/doubleclick-impl to refresh-manager.
glevitzky 9a21ca3
Comment.
glevitzky f286d41
Changed how refresh cycle is restarted.
glevitzky e57a1d0
Fixed example page.
glevitzky 2f7ca32
Minor tweaks + moved refresh manager initialization into layoutCallback.
glevitzky bef809f
Restructured getRefreshConfiguration.
glevitzky 9eb4268
Removed unneeded type declaration.
glevitzky ba10f35
Refactored how configs and eligibility is computed.
glevitzky 0cc1f14
Added logic to handle multi-size slots + refresh correctly.
glevitzky aff6548
Fixed doubleclick.js + passing 'strict' to dimension validator.
glevitzky a320baf
refresh-manager refactor + amp-ad container type changes.
glevitzky 38e10c2
Refactors + test coverage expansion.
glevitzky b16be0c
Added test for AmpA4A.refresh().
glevitzky e75ad4a
Added back eligibility check.
glevitzky 4d32f12
Added refresh counter for doubleclick.
glevitzky 00dbb67
Removed dead code + fixed user().warn.
glevitzky 78fe1a0
Added public-facing documentation for refresh feature.
glevitzky 499866f
Minor refactor + more tests.
glevitzky ae7f212
Merges with SRA.
glevitzky 3ccf39b
Minor refresh-manager refactor.
glevitzky a19ded0
Stash.
glevitzky 15e9b2b
Stashing changes while debugging.
glevitzky 9efc75a
Skipping potentially problematic test.
glevitzky c048035
Lint.
glevitzky 29706d9
Isolating another test.
glevitzky 7c1af0b
lint
glevitzky a05e12a
Comment toggle.
glevitzky 05775b5
Fixed test.
glevitzky dcc0a66
Manually triggering scheduler to call layoutcallback.
glevitzky c384695
Fixed test.
glevitzky 0124d03
Uncommented asserts.
glevitzky a1beaa0
Moved line to more relevant spot.
glevitzky 36c9fd3
Moved all DOM-changing code into layoutCallback.
glevitzky 22b81a9
Added REVIEW tag.
glevitzky 2199b45
lint fixes
glevitzky 280be2b
Removed changes from _a4a-config.
glevitzky 4701b08
Fixed test.
glevitzky 804d5ea
schedulePass -> requireLayout
glevitzky c3b8ba3
Duplicate imports from merge.
glevitzky 8438c14
Fixed doubleclick.js test.
glevitzky 3b764ac
Lint fixes.
glevitzky eb3e4ba
Moved more logic from amp-a4a to doubleclick impl.
glevitzky 32da8eb
Reverting changes to iframe-handler.
glevitzky 070ffb7
Missed stray space.
glevitzky 19b965d
Refactors + PR feedback.
glevitzky 9e3afa7
Fixed tests.
glevitzky b67eaee
Skipping problematic test.
glevitzky d8bcbbb
Refactored refresh promise.
glevitzky ad23e2b
Moved doc + using this.mutateElement.
glevitzky 6276560
Using this.mutateElement.
glevitzky ad9f99d
Fixed 1 test, added another.
glevitzky acf6eed
Cleaned up test.
glevitzky 6358656
GH issues.
glevitzky 66c76be
More test fixes + new test.
glevitzky 725abc5
Should have 3 new, green, tests.
glevitzky 1fb489d
Unskipping now passing test for adsense-impl (for ifi/pv).
glevitzky d0b9704
Guarding refresh feature behind experiment flag.
glevitzky 034b7e7
Minor cosmetic changes.
glevitzky b904124
Merges.
glevitzky 448f07b
Reverting RefreshManager to use initial implementation of view manage…
glevitzky dff0d73
min refresh interval 3 -> 30.
glevitzky 16de942
Minor fixes, PR feedback, SRA carveout.
glevitzky e7653bf
Removed duplicate file.
glevitzky 8b2499e
Fixed user().assert
glevitzky ce9e829
Fixed tests.
glevitzky 26d6afe
PR feedback.
glevitzky 2250818
Refresh + SRA test, minor misc fixes.
glevitzky 6220374
Moved container-requirement into doubleclick impl + docs update.
glevitzky 54ce29c
Merges.
glevitzky 03ee809
Post-merge fixes.
glevitzky 932760f
PR feedback.
glevitzky afc635d
Removed superfluous 'REFRESHED' state.
glevitzky de17663
Fixing comments.
glevitzky File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
* Copyright 2017 The AMP HTML Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS-IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {getMultiSizeDimensions} from '../utils'; | ||
|
||
describe('#getMultiSizeDimensions', () => { | ||
|
||
const multiSizes = [ | ||
[300, 300], | ||
[300, 250], | ||
[250, 250], | ||
[250, 200], | ||
[150, 50], | ||
]; | ||
|
||
const multiSizeDataStr = '300x300,300x250,250x250,250x200,150x50'; | ||
|
||
function verifyArray(actual, lower, upper) { | ||
expect(multiSizes.filter((size, index) => index < upper && index >= lower)) | ||
.to.deep.equal(actual); | ||
} | ||
|
||
it('should return all sizes', () => { | ||
const actual = getMultiSizeDimensions(multiSizeDataStr, 300, 300, | ||
/* Ignore lowerbound */ false, | ||
/* Don't drop entire string on error */ false); | ||
verifyArray(actual, 0, multiSizes.length); | ||
}); | ||
|
||
it('should return a smaller array', () => { | ||
const actual = getMultiSizeDimensions(multiSizeDataStr, 300, 250, | ||
/* Ignore lowerbound */ false, | ||
/* Don't drop entire string on error */ false); | ||
verifyArray(actual, 1, multiSizes.length); | ||
}); | ||
|
||
it('should return an even smaller array', () => { | ||
const actual = getMultiSizeDimensions(multiSizeDataStr, 250, 250, | ||
/* Ignore lowerbound */ false, | ||
/* Don't drop entire string on error */ false); | ||
verifyArray(actual, 2, multiSizes.length); | ||
}); | ||
|
||
it('should return an empty array', () => { | ||
const actual = getMultiSizeDimensions(multiSizeDataStr, 100, 50, | ||
/* Ignore lowerbound */ false, | ||
/* Don't drop entire string on error */ false); | ||
verifyArray(actual, 0, 0); | ||
}); | ||
|
||
it('should return a smaller array due to lowerbound', () => { | ||
const actual = getMultiSizeDimensions(multiSizeDataStr, 300, 300, | ||
/* Use lowerbound */ true, | ||
/* Don't drop entire string on error */ false); | ||
|
||
verifyArray(actual, 0, multiSizes.length - 1); | ||
}); | ||
|
||
it('should return a smaller array due to lowerbound + smaller primary size', | ||
() => { | ||
const actual = getMultiSizeDimensions(multiSizeDataStr, 300, 250, | ||
/* Use lowerbound */ true, | ||
/* Don't drop entire string on error */ false); | ||
verifyArray(actual, 1, multiSizes.length - 1); | ||
}); | ||
|
||
it('should return null', () => { | ||
const actual = getMultiSizeDimensions(multiSizeDataStr, 300, 250, | ||
/* Ignore lowerbound */ false, | ||
/* Drop entire string on error */ true); | ||
expect(actual).to.be.null; | ||
}); | ||
|
||
it('should return null due to non-positive argument', () => { | ||
const actual = getMultiSizeDimensions( | ||
'-1x300,' + multiSizeDataStr, 300, 300, | ||
/* Ignore lowerbound */ false, | ||
/* Drop entire string on error */ true); | ||
expect(actual).to.be.null; | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why we have a counter 20 here? Is checking
el.tagName == 'BODY'
better, like what we do in#isAdPositionAllowed
functionThere 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 considered a best practice in the context of ads tagging. Apparently, even though it should by all rights be impossible, there have been reports of JavaScript tags encountering cyclic DOM trees in the wild. If code that traversed the DOM without a loop counter encountered such a cycle, the browser would hang.
That said, I'm not sure AMP really needs to worry about this.