Fix comments on WebPage.js (#97)

This patch fixes bad indentation in WebPage comments
This commit is contained in:
JoelEinbinder 2017-07-19 14:44:47 -07:00 committed by Andrey Lushnikov
parent febd747c5b
commit 2fb1d9afca

View File

@ -24,10 +24,10 @@ let noop = function() { };
class WebPage { class WebPage {
/** /**
* @param {!Browser} browser * @param {!Browser} browser
* @param {string} scriptPath * @param {string} scriptPath
* @param {!Object=} options * @param {!Object=} options
*/ */
constructor(browser, scriptPath, options) { constructor(browser, scriptPath, options) {
this._page = await(browser.newPage()); this._page = await(browser.newPage());
this.settings = new WebPageSettings(this._page); this.settings = new WebPageSettings(this._page);
@ -212,22 +212,22 @@ class WebPage {
} }
/** /**
* @return {?function(!Object, !Request)} * @return {?function(!Object, !Request)}
*/ */
get onResourceRequested() { get onResourceRequested() {
return this._onResourceRequestedCallback; return this._onResourceRequestedCallback;
} }
/** /**
* @return {?function(!Object, !Request)} callback * @return {?function(!Object, !Request)} callback
*/ */
set onResourceRequested(callback) { set onResourceRequested(callback) {
this._onResourceRequestedCallback = callback; this._onResourceRequestedCallback = callback;
this._page.setRequestInterceptor(callback ? resourceInterceptor : null); this._page.setRequestInterceptor(callback ? resourceInterceptor : null);
/** /**
* @param {!InterceptedRequest} request * @param {!InterceptedRequest} request
*/ */
function resourceInterceptor(request) { function resourceInterceptor(request) {
let requestData = new RequestData(request); let requestData = new RequestData(request);
let phantomRequest = new PhantomRequest(request); let phantomRequest = new PhantomRequest(request);
@ -254,37 +254,37 @@ class WebPage {
} }
/** /**
* @param {string} url * @param {string} url
* @param {function()} callback * @param {function()} callback
*/ */
includeJs(url, callback) { includeJs(url, callback) {
this._page.addScriptTag(url).then(callback); this._page.addScriptTag(url).then(callback);
} }
/** /**
* @return {!{width: number, height: number}} * @return {!{width: number, height: number}}
*/ */
get viewportSize() { get viewportSize() {
return this._page.viewport(); return this._page.viewport();
} }
/** /**
* @return {!Object} * @return {!Object}
*/ */
get customHeaders() { get customHeaders() {
return this._page.httpHeaders(); return this._page.httpHeaders();
} }
/** /**
* @param {!Object} value * @param {!Object} value
*/ */
set customHeaders(value) { set customHeaders(value) {
await(this._page.setHTTPHeaders(value)); await(this._page.setHTTPHeaders(value));
} }
/** /**
* @param {string} filePath * @param {string} filePath
*/ */
injectJs(filePath) { injectJs(filePath) {
if (!fs.existsSync(filePath)) if (!fs.existsSync(filePath))
filePath = path.resolve(this.libraryPath, filePath); filePath = path.resolve(this.libraryPath, filePath);
@ -295,29 +295,29 @@ class WebPage {
} }
/** /**
* @return {string} * @return {string}
*/ */
get plainText() { get plainText() {
return await(this._page.plainText()); return await(this._page.plainText());
} }
/** /**
* @return {string} * @return {string}
*/ */
get title() { get title() {
return await(this._page.title()); return await(this._page.title());
} }
/** /**
* @return {(function()|undefined)} * @return {(function()|undefined)}
*/ */
get onError() { get onError() {
return this._onError; return this._onError;
} }
/** /**
* @param {(function()|undefined)} handler * @param {(function()|undefined)} handler
*/ */
set onError(handler) { set onError(handler) {
if (typeof handler !== 'function') if (typeof handler !== 'function')
handler = undefined; handler = undefined;
@ -325,15 +325,15 @@ class WebPage {
} }
/** /**
* @return {(function()|undefined)} * @return {(function()|undefined)}
*/ */
get onConfirm() { get onConfirm() {
return this._onConfirmCallback; return this._onConfirmCallback;
} }
/** /**
* @param {function()} handler * @param {function()} handler
*/ */
set onConfirm(handler) { set onConfirm(handler) {
if (typeof handler !== 'function') if (typeof handler !== 'function')
handler = undefined; handler = undefined;
@ -341,15 +341,15 @@ class WebPage {
} }
/** /**
* @return {(function()|undefined)} * @return {(function()|undefined)}
*/ */
get onAlert() { get onAlert() {
return this._onAlertCallback; return this._onAlertCallback;
} }
/** /**
* @param {function()} handler * @param {function()} handler
*/ */
set onAlert(handler) { set onAlert(handler) {
if (typeof handler !== 'function') if (typeof handler !== 'function')
handler = undefined; handler = undefined;
@ -357,8 +357,8 @@ class WebPage {
} }
/** /**
* @param {!Dialog} dialog * @param {!Dialog} dialog
*/ */
_onDialog(dialog) { _onDialog(dialog) {
if (dialog.type === 'alert' && this._onAlertCallback) { if (dialog.type === 'alert' && this._onAlertCallback) {
this._onAlertCallback.call(null, dialog.message()); this._onAlertCallback.call(null, dialog.message());
@ -370,15 +370,15 @@ class WebPage {
} }
/** /**
* @return {string} * @return {string}
*/ */
get url() { get url() {
return await(this._page.url()); return await(this._page.url());
} }
/** /**
* @param {string} html * @param {string} html
*/ */
set content(html) { set content(html) {
await(this._page.setContent(html)); await(this._page.setContent(html));
} }
@ -450,9 +450,9 @@ class WebPage {
} }
/** /**
* @param {string} html * @param {string} html
* @param {function()=} callback * @param {function()=} callback
*/ */
open(url, callback) { open(url, callback) {
console.assert(arguments.length <= 2, 'WebPage.open does not support METHOD and DATA arguments'); console.assert(arguments.length <= 2, 'WebPage.open does not support METHOD and DATA arguments');
this._deferEvaluate = true; this._deferEvaluate = true;
@ -483,16 +483,16 @@ class WebPage {
} }
/** /**
* @param {!{width: number, height: number}} options * @param {!{width: number, height: number}} options
*/ */
set viewportSize(options) { set viewportSize(options) {
await(this._page.setViewport(options)); await(this._page.setViewport(options));
} }
/** /**
* @param {function()} fun * @param {function()} fun
* @param {!Array<!Object>} args * @param {!Array<!Object>} args
*/ */
evaluate(fun, ...args) { evaluate(fun, ...args) {
if (this._deferEvaluate) if (this._deferEvaluate)
return await(this._page.evaluateOnInitialized(fun, ...args)); return await(this._page.evaluateOnInitialized(fun, ...args));
@ -500,8 +500,8 @@ class WebPage {
} }
/** /**
* {string} fileName * {string} fileName
*/ */
render(fileName) { render(fileName) {
if (fileName.endsWith('pdf')) { if (fileName.endsWith('pdf')) {
let options = {}; let options = {};
@ -539,22 +539,22 @@ class WebPage {
class WebPageSettings { class WebPageSettings {
/** /**
* @param {!Page} page * @param {!Page} page
*/ */
constructor(page) { constructor(page) {
this._page = page; this._page = page;
} }
/** /**
* @param {string} value * @param {string} value
*/ */
set userAgent(value) { set userAgent(value) {
await(this._page.setUserAgent(value)); await(this._page.setUserAgent(value));
} }
/** /**
* @return {string} * @return {string}
*/ */
get userAgent() { get userAgent() {
return this._page.userAgent(); return this._page.userAgent();
} }
@ -632,8 +632,8 @@ class RequestData {
// helping to overcome the issue. // helping to overcome the issue.
class AsyncEmitter extends EventEmitter { class AsyncEmitter extends EventEmitter {
/** /**
* @param {!Page} page * @param {!Page} page
*/ */
constructor(page) { constructor(page) {
super(); super();
this._page = page; this._page = page;