Revert "lint examples #178 (#182)" (#183)

This reverts commit 8c220654e8.
This commit is contained in:
JoelEinbinder 2017-08-02 01:26:02 -07:00 committed by GitHub
parent 8c220654e8
commit 0218960713
10 changed files with 198 additions and 191 deletions

View File

@ -1,2 +1,3 @@
third_party/*
examples/*
utils/doclint/check_public_api/test/

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
let Browser = require('../lib/Browser');
let browser = new Browser();
var Browser = require('../lib/Browser');
var browser = new Browser();
browser.newPage().then(async page => {
await page.setViewport({width: 400, height: 400});
@ -26,7 +26,7 @@ browser.newPage().then(async page => {
});
function drawColorWheel() {
let el = document.getElementById('surface'),
var el = document.getElementById('surface'),
context = el.getContext('2d'),
width = window.innerWidth,
height = window.innerHeight,

View File

@ -14,17 +14,17 @@
* limitations under the License.
*/
let Browser = require('../lib/Browser');
let Downloader = require('../utils/ChromiumDownloader');
var Browser = require('../lib/Browser');
var Downloader = require('../utils/ChromiumDownloader');
let revision = '483012';
var revision = '483012';
console.log('Downloading custom chromium revision - ' + revision);
Downloader.downloadRevision(Downloader.currentPlatform(), revision).then(async () => {
console.log('Done.');
let executablePath = Downloader.revisionInfo(Downloader.currentPlatform(), revision).executablePath;
let browser1 = new Browser({ executablePath });
let browser2 = new Browser();
let [version1, version2] = await Promise.all([
var executablePath = Downloader.revisionInfo(Downloader.currentPlatform(), revision).executablePath;
var browser1 = new Browser({ executablePath });
var browser2 = new Browser();
var [version1, version2] = await Promise.all([
browser1.version(),
browser2.version()
]);

View File

@ -14,21 +14,21 @@
* limitations under the License.
*/
let Browser = require('../lib/Browser');
var Browser = require('../lib/Browser');
if (process.argv.length < 3) {
console.log('Usage: detectsniff.js <some URL>');
return;
}
let address = process.argv[2];
var address = process.argv[2];
console.log('Checking ' + address + '...');
let browser = new Browser();
var browser = new Browser();
browser.newPage().then(async page => {
await page.evaluateOnNewDocument(function() {
(function () {
let userAgent = window.navigator.userAgent,
var userAgent = window.navigator.userAgent,
platform = window.navigator.platform;
window.navigator = {
@ -49,19 +49,19 @@ browser.newPage().then(async page => {
});
})();
});
let success = await page.navigate(address);
var success = await page.navigate(address);
if (!success) {
console.log('FAIL to load the address');
browser.close();
return;
}
setTimeout(async function () {
let sniffed = await page.evaluate(() => navigator.sniffed);
if (sniffed)
var sniffed = await page.evaluate(() => navigator.sniffed);
if (sniffed) {
console.log('The page tried to sniff the user agent.');
else
} else {
console.log('The page did not try to sniff the user agent.');
}
browser.close();
}, 1500);
});

View File

@ -14,12 +14,12 @@
* limitations under the License.
*/
let path = require('path');
let Browser = require('../lib/Browser');
let browser = new Browser();
var path = require('path');
var Browser = require('../lib/Browser');
var browser = new Browser();
browser.newPage().then(async page => {
let modernizrPath = path.join(__dirname, '../third_party/phantomjs/examples/modernizr.js');
var modernizrPath = path.join(__dirname, '../third_party/phantomjs/examples/modernizr.js');
await page.injectFile(modernizrPath);
page.on('console', console.log);
await page.evaluate(detectFeatures);
@ -27,17 +27,17 @@ browser.newPage().then(async page => {
});
function detectFeatures() {
let supported = [], unsupported = [];
var supported = [], unsupported = [];
console.log('Detected features (using Modernizr ' + Modernizr._version + '):');
for (let feature in Modernizr) {
for (var feature in Modernizr) {
if (Modernizr.hasOwnProperty(feature)) {
if (feature[0] !== '_' && typeof Modernizr[feature] !== 'function' &&
feature !== 'input' && feature !== 'inputtypes') {
if (Modernizr[feature])
if (Modernizr[feature]) {
supported.push(feature);
else
} else {
unsupported.push(feature);
}
}
}
}

View File

@ -14,16 +14,16 @@
* limitations under the License.
*/
let Browser = require('../lib/Browser');
var Browser = require('../lib/Browser');
if (process.argv.length < 3) {
console.log('Usage: loadurlwithoutcss.js URL');
return;
}
let address = process.argv[2];
var address = process.argv[2];
let browser = new Browser({headless: false});
var browser = new Browser({headless: false});
browser.newPage().then(async page => {
page.setRequestInterceptor(request => {
if (request.url.endsWith('.css'))
@ -31,7 +31,7 @@ browser.newPage().then(async page => {
else
request.continue();
});
let success = await page.navigate(address);
var success = await page.navigate(address);
if (!success)
console.log('Unable to load the address!');
browser.close();

View File

@ -14,22 +14,24 @@
* limitations under the License.
*/
let Browser = require('../lib/Browser');
var Browser = require('../lib/Browser');
if (process.argv.length < 5) {
console.log('Usage: openurlwithproxy.js <proxyHost> <proxyPort> <URL>');
return;
}
let host = process.argv[2];
let port = process.argv[3];
let address = process.argv[4];
var host = process.argv[2];
var port = process.argv[3];
var address = process.argv[4];
let browser = new Browser({
args: [`--proxy-server=${host}:${port}`]
var browser = new Browser({
args: [
`--proxy-server=${host}:${port}`;
]
});
browser.newPage().then(async page => {
let success = await page.navigate(address);
var success = await page.navigate(address);
if (success) {
console.log('Page title is ' + (await page.title()));
} else {

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
let Browser = require('../lib/Browser');
let browser = new Browser();
var Browser = require('../lib/Browser');
var browser = new Browser();
browser.newPage().then(async page => {
page.on('console', console.log);
@ -23,18 +23,22 @@ browser.newPage().then(async page => {
await page.setInPageCallback('callPhantom', msg => {
console.log("Page is saying: '" + msg + "'");
return 'Hello, page';
return "Hello, page";
});
await page.evaluate(async function() {
// Return-value of the "onCallback" handler arrive here
let callbackResponse = await window.callPhantom('Hello, driver');
var callbackResponse = await window.callPhantom("Hello, driver");
console.log("Driver is saying: '" + callbackResponse + "'");
});
browser.close();
});

View File

@ -19,6 +19,6 @@ const browser = new Browser();
browser.newPage().then(async page => {
await page.navigate('http://example.com');
await page.screenshot({path: 'example.png'});
const screenshot = await page.screenshot({path: 'example.png'});
browser.close();
});

View File

@ -14,14 +14,14 @@
* limitations under the License.
*/
let Browser = require('../lib/Browser');
let browser = new Browser();
var Browser = require('../lib/Browser');
var browser = new Browser();
browser.newPage().then(async page => {
await page.evaluateOnNewDocument(function() {
Math.random = () => 42 / 100;
});
let result = await page.navigate('http://ariya.github.com/js/random/');
var result = await page.navigate('http://ariya.github.com/js/random/');
if (result) {
console.log(await page.evaluate(function () {
return document.getElementById('numbers').textContent;