Skip to content

Commit

Permalink
Merge branch 'master' into responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiaming-X committed May 12, 2020
2 parents c12d66f + 411a877 commit a926929
Show file tree
Hide file tree
Showing 160 changed files with 3,277 additions and 1,645 deletions.
10 changes: 5 additions & 5 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ codecov:
ci:
- 'travis.org'
max_report_age: 24
require_ci_to_pass: yes
require_ci_to_pass: no
notify:
wait_for_ci: yes
wait_for_ci: no

# Pull request comments disabled because they were too noisy
# See https://docs.codecov.io/docs/pull-request-comments
Expand All @@ -18,19 +18,19 @@ comment: false
coverage:
precision: 2
round: down
range: '80...100'
range: '75...100'
status:
project:
default:
base: auto
if_not_found: success
only_pulls: true
target: 80%
target: 75%
threshold: 1%
patch:
default:
base: auto
if_not_found: success
only_pulls: true
target: 80%
target: 75%
threshold: 1%
4 changes: 2 additions & 2 deletions 3p/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ export function twitter(global, data) {
return;
}

resize(el);
resize(/** @type {!Element} */ (el));
twttr.events.bind('resize', (event) => {
// To be safe, make sure the resize event was triggered for the widget we
// created below.
if (el === event.target) {
resize(el);
resize(/** @type {!Element} */ (el));
}
});
}
Expand Down
5 changes: 0 additions & 5 deletions ads/inabox/inabox-host.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ Main workflow:
1. The ads tag creates an iframe, and set the response content
to the iframe using `srcdoc`.

Note that this friendly iframe approach right now is in an experimental
stage. Put the following meta tag in the head of the ad HTML to opt-in
the experiment:
`<meta name="amp-experiments-opt-in" content="inabox-viewport-friendly">`.

###### Security assurance

In case that the AMPHTML ad is generated by a 3rd party, to ensure it's
Expand Down
18 changes: 15 additions & 3 deletions build-system/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,22 @@ const ROOT_DIR = path.resolve(__dirname, '../../');
/**
* Cleans and builds binaries with --fortesting flag and
* overriden config.
*
* @param {boolean} minified
*/
function buildMinifiedRuntime() {
// TODO(gh/amphtml/28312): Directly call dist() or build()
// instead of spwaning a new process.
function buildRuntime(minified = true) {
execOrDie('gulp clean');
execOrDie(`gulp dist --fortesting --config ${argv.config}`);

let command = minified ? `gulp dist --fortesting` : `gulp build --fortesting`;
if (argv.core_runtime_only) {
command += ` --core_runtime_only`;
} else if (argv.extensions) {
command += ` --extensions=${argv.extensions}`;
}

execOrDie(command);
}

/**
Expand Down Expand Up @@ -157,7 +169,7 @@ function installPackages(dir) {
}

module.exports = {
buildMinifiedRuntime,
buildRuntime,
getFilesChanged,
getFilesFromArgv,
getFilesToCheck,
Expand Down
2 changes: 1 addition & 1 deletion build-system/compile/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function compile(
compilation_level: options.compilationLevel || 'SIMPLE_OPTIMIZATIONS',
// Turns on more optimizations.
assume_function_wrapper: true,
language_in: 'ECMASCRIPT_2018',
language_in: 'ECMASCRIPT_2020',
// Do not transpile down to ES5 if running with `--esm`, since we do
// limited transpilation in Babel.
language_out: argv.esm ? 'NO_TRANSPILE' : 'ECMASCRIPT5',
Expand Down
2 changes: 1 addition & 1 deletion build-system/compile/single-pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ exports.getFlags = function (config) {
// accessing the symbol, we remedy this by attaching all public exports
// to `_` and everything imported across modules is is accessed through `_`.
rename_prefix_namespace: '_',
language_in: 'ECMASCRIPT_2018',
language_in: 'ECMASCRIPT_2020',
language_out: config.esm
? 'NO_TRANSPILE'
: config.language_out || 'ECMASCRIPT5',
Expand Down
6 changes: 1 addition & 5 deletions build-system/global-configs/canary-config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"allow-doc-opt-in": [
"amp-next-page",
"inabox-viewport-friendly",
"analytics-chunks"
],
"allow-doc-opt-in": ["amp-next-page", "analytics-chunks"],
"allow-url-opt-in": ["pump-early-frame"],
"canary": 1,
"a4aProfilingRate": 0.01,
Expand Down
9 changes: 1 addition & 8 deletions build-system/global-configs/experiments-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
"expirationDateUTC": "2020-05-31",
"defineExperimentConstant": "INTERSECTION_OBSERVER_POLYFILL"
},
"experimentB": {
"name": "MOVE_FIXED_LAYER",
"environment": "AMP",
"command": "gulp dist --define_experiment_constant=MOVE_FIXED_LAYER",
"issue": "",
"expiration_date_utc": "2020-12-31",
"define_experiment_constant": "MOVE_FIXED_LAYER"
},
"experimentB": {},
"experimentC": {}
}
10 changes: 4 additions & 6 deletions build-system/global-configs/prod-config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"allow-doc-opt-in": [
"amp-next-page",
"inabox-viewport-friendly",
"analytics-chunks"
],
"allow-doc-opt-in": ["amp-next-page", "analytics-chunks"],
"allow-url-opt-in": ["pump-early-frame"],
"canary": 0,
"a4aProfilingRate": 0.01,
Expand Down Expand Up @@ -37,5 +33,7 @@
"random-subdomain-for-safeframe": 0.02,
"swg-gpay-api": 1,
"swg-gpay-native": 1,
"version-locking": 1
"version-locking": 1,
"amp-ad-no-center-css": 0.05,
"analytics-chunks": 1
}
6 changes: 1 addition & 5 deletions build-system/pr-check/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
{
rules: [
{
owners: [
{name: 'ampproject/wg-infra'},
{name: 'estherkim', notify: true},
{name: 'rsimha', notify: true},
],
owners: [{name: 'ampproject/wg-infra'}, {name: 'rsimha', notify: true}],
},
],
}
6 changes: 6 additions & 0 deletions build-system/pr-check/build-targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ const targetMatchers = {
'PACKAGE_UPGRADE': (file) => {
return file == 'package.json' || file == 'yarn.lock';
},
'RUNTIME': (file) => {
if (isOwnersFile(file)) {
return false;
}
return file.startsWith('src/');
},
'SERVER': (file) => {
if (isOwnersFile(file)) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions build-system/pr-check/e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function main() {
if (!isTravisPullRequestBuild()) {
downloadDistOutput(FILENAME);
timedExecOrDie('gulp update-packages');
timedExecOrDie('gulp e2e --nobuild --headless');
timedExecOrDie('gulp e2e --nobuild --headless --compiled');
} else {
printChangeSummary(FILENAME);
const buildTargets = determineBuildTargets(FILENAME);
Expand All @@ -53,7 +53,7 @@ async function main() {
) {
downloadDistOutput(FILENAME);
timedExecOrDie('gulp update-packages');
timedExecOrDie('gulp e2e --nobuild --headless');
timedExecOrDie('gulp e2e --nobuild --headless --compiled');
} else {
console.log(
`${FILELOGPREFIX} Skipping`,
Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/experiment-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function build_(config) {

function test_() {
timedExecOrDie('gulp integration --nobuild --compiled --headless');
timedExecOrDie('gulp e2e --nobuild --headless');
timedExecOrDie('gulp e2e --nobuild --compiled --headless');
}

function main() {
Expand Down
4 changes: 1 addition & 3 deletions build-system/server/routes/a4a-envelopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ app.use('/inabox-(friendly|safeframe)', (req, res) => {
fs.promises
.readFile(process.cwd() + templatePath, 'utf8')
.then((template) => {
let url;
const url = getInaboxUrl(req);
if (req.baseUrl == '/inabox-friendly') {
url = getInaboxUrl(req, 'inabox-viewport-friendly');
template = template
.replace('SRCDOC_ATTRIBUTE', 'srcdoc="BODY"')
.replace('INABOX_ADS_TAG_INTEGRATION', '');
} else {
url = getInaboxUrl(req);
template = template
.replace(
/NAME/g,
Expand Down
3 changes: 2 additions & 1 deletion build-system/tasks/e2e/functional-test-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ class FunctionalTestController {
* {@link https://www.w3.org/TR/webdriver1/#find-element}
*
* @param {string} unusedSelector
* @param {number=} unusedTimeout
* @return {!Promise<!ElementHandle>}
*/
async findElement(unusedSelector) {}
async findElement(unusedSelector, unusedTimeout) {}

/**
* The Find Elements command is used to find all elements matching the
Expand Down
16 changes: 10 additions & 6 deletions build-system/tasks/e2e/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const log = require('fancy-log');
const Mocha = require('mocha');
const path = require('path');
const {
buildMinifiedRuntime,
buildRuntime,
getFilesFromArgv,
installPackages,
} = require('../../common/utils');
Expand All @@ -39,11 +39,11 @@ const PORT = 8000;
const SLOW_TEST_THRESHOLD_MS = 2500;
const TEST_RETRIES = isTravisBuild() ? 2 : 0;

async function launchWebServer_() {
async function launchWebServer_(minified) {
await startServer(
{host: HOST, port: PORT},
{quiet: !argv.debug},
{compiled: true}
{compiled: minified}
);
}

Expand Down Expand Up @@ -84,11 +84,11 @@ async function e2e() {

// build runtime
if (!argv.nobuild) {
buildMinifiedRuntime();
buildRuntime(/* minified */ !!argv.compiled);
}

// start up web server
await launchWebServer_();
await launchWebServer_(/* minified */ argv.compiled);

// run tests
if (!argv.watch) {
Expand Down Expand Up @@ -150,7 +150,11 @@ e2e.flags = {
'`chrome`, `firefox`, `safari`.',
'config':
' Sets the runtime\'s AMP_CONFIG to one of "prod" (default) or "canary"',
'nobuild': ' Skips building the runtime via `gulp dist --fortesting`',
'core_runtime_only': ' Builds only the core runtime.',
'nobuild':
' Skips building the runtime via `gulp (build|dist) --fortesting`',
'extensions': ' Builds only the listed extensions.',
'compiled': ' Runs the tests using minified js',
'files': ' Run tests found in a specific path (ex: **/test-e2e/*.js)',
'testnames': ' Lists the name of each test being run',
'watch': ' Watches for changes in files, runs corresponding test(s)',
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@babel/register": "7.9.0",
"babel-regenerator-runtime": "6.5.0",
"chromedriver": "81.0.0",
"puppeteer": "3.0.2",
"puppeteer": "3.0.4",
"geckodriver": "1.19.1",
"selenium-webdriver": "4.0.0-alpha.7"
},
Expand Down
5 changes: 3 additions & 2 deletions build-system/tasks/e2e/puppeteer-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,18 @@ class PuppeteerController {

/**
* @param {string} selector
* @param {number=} timeout
* @return {!Promise<!ElementHandle<!PuppeteerHandle>>}
* @override
*/
async findElement(selector) {
async findElement(selector, timeout = DEFAULT_WAIT_TIMEOUT) {
const frame = await this.getCurrentFrame_();
const root = await this.getRoot_();
const jsHandle = await frame.waitForFunction(
(root, selector) => {
return root./*OK*/ querySelector(selector);
},
{timeout: DEFAULT_WAIT_TIMEOUT},
{timeout},
root,
selector
);
Expand Down
5 changes: 3 additions & 2 deletions build-system/tasks/e2e/selenium-webdriver-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ class SeleniumWebDriverController {
* until.js#elementLocated
* {@link https://github.com/SeleniumHQ/selenium/blob/6a717f20/javascript/node/selenium-webdriver/lib/until.js#L237}
* @param {string} selector
* @param {number=} timeout
* @return {!Promise<!ElementHandle<!WebElement>>}
* @override
*/
async findElement(selector) {
async findElement(selector, timeout = ELEMENT_WAIT_TIMEOUT) {
const bySelector = By.css(selector);

const label = 'for element to be located ' + selector;
Expand All @@ -139,7 +140,7 @@ class SeleniumWebDriverController {
throw e;
}
});
const webElement = await this.driver.wait(condition, ELEMENT_WAIT_TIMEOUT);
const webElement = await this.driver.wait(condition, timeout);
return new ElementHandle(webElement, this);
}

Expand Down
27 changes: 4 additions & 23 deletions build-system/tasks/e2e/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/mime-types@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@types/mime-types/-/mime-types-2.1.0.tgz#9ca52cda363f699c69466c2a6ccdaad913ea7a73"
integrity sha1-nKUs2jY/aZxpRmwqbM2q2RPqenM=

"@types/minimatch@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
Expand Down Expand Up @@ -662,18 +657,6 @@ micromatch@^4.0.2:
braces "^3.0.1"
picomatch "^2.0.5"

[email protected]:
version "1.43.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.43.0.tgz#0a12e0502650e473d735535050e7c8f4eb4fae58"
integrity sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==

mime-types@^2.1.25:
version "2.1.26"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.26.tgz#9c921fc09b7e149a65dfdc0da4d20997200b0a06"
integrity sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==
dependencies:
mime-db "1.43.0"

mime@^2.0.3:
version "2.4.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.0.tgz#e051fd881358585f3279df333fe694da0bcffdd6"
Expand Down Expand Up @@ -882,17 +865,15 @@ pump@^3.0.0:
end-of-stream "^1.1.0"
once "^1.3.1"

[email protected].2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-3.0.2.tgz#1d08cdb7c0c2666f5e743221b1cb1946fea493f0"
integrity sha512-5jS/POFVDW9fqb76O8o0IBpXOnq+Na8ocGMggYtnjCRBRqmAFvX0csmwgLOHkYnQ/vCBcBPYlOq0Pp60z1850Q==
[email protected].4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-3.0.4.tgz#f445aae0a6732c65bbb90e963dcd6fd8fde0d780"
integrity sha512-1QEb4tJXXbNId7WSHlcDkS3B4GklTIebKn8Y9D6B7tAdUjQncb+8QlTjbQsAgGX5dhRG32Qycuk5XKzJgLs0sg==
dependencies:
"@types/mime-types" "^2.1.0"
debug "^4.1.0"
extract-zip "^2.0.0"
https-proxy-agent "^4.0.0"
mime "^2.0.3"
mime-types "^2.1.25"
progress "^2.0.1"
proxy-from-env "^1.0.0"
rimraf "^3.0.2"
Expand Down
Loading

0 comments on commit a926929

Please sign in to comment.