diff --git a/types/slimerjs/index.d.ts b/types/slimerjs/index.d.ts index b45d6d9495..327f2ac4b8 100644 --- a/types/slimerjs/index.d.ts +++ b/types/slimerjs/index.d.ts @@ -112,14 +112,14 @@ interface IWebPage { // evaluate(callback: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: T3): Promise; // evaluate(callback: (...args: any[]) => R, ...args: any[]): Promise; evaluate(callback: () => R, ...args: any[]): R; - evaluateAsync(fn: Function): void; + evaluateAsync(fn: () => void): void; evaluateJavaScript(str: string): any; // :TODO: elaborate this when documentation improves getPage(windowName: string): IWebPage; go(index: number): void; goBack(): void; goForward(): void; includeJs(url: string): Promise; - includeJs(url: string, callback: Function): void; + includeJs(url: string, callback: () => void): void; injectJs(filename: string): Promise; injectJs(filename: string): boolean; open(url: string): Promise; @@ -153,7 +153,7 @@ interface IWebPage { // Callbacks onAlert: (msg: string) => any; - onCallback: Function; // EXPERIMENTAL + onCallback: () => void; // EXPERIMENTAL onClosing: (closingPage: IWebPage) => any; onConfirm: (msg: string) => boolean; onConsoleMessage: (msg: string, lineNum?: number, sourceId?: string) => any; diff --git a/types/slimerjs/slimerjs-tests.ts b/types/slimerjs/slimerjs-tests.ts index f3de79d963..3e11b5174b 100644 --- a/types/slimerjs/slimerjs-tests.ts +++ b/types/slimerjs/slimerjs-tests.ts @@ -5,18 +5,18 @@ let vUrl = 'https://www.w3c.org'; let vUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8' page.settings.userAgent = vUserAgent; -page.onConsoleMessage = function(vMsg) { +page.onConsoleMessage = (vMsg) => { }; -page.onAlert = function(vMsg) { +page.onAlert = (vMsg) => { }; -page.onLoadStarted = function() { +page.onLoadStarted = () => { }; page.captureContent = [ /json/ ] -page.onResourceReceived = function(oResponse) { +page.onResourceReceived = (oResponse) => { oResponse.id; oResponse.bodySize; oResponse.body; @@ -24,7 +24,7 @@ page.onResourceReceived = function(oResponse) { oResponse.headers; }; -page.onResourceRequested = function(oRequestData, oNetworkRequest) { +page.onResourceRequested = (oRequestData, oNetworkRequest) => { oRequestData.headers; oRequestData.id; oRequestData.method; @@ -33,31 +33,31 @@ page.onResourceRequested = function(oRequestData, oNetworkRequest) { }; -page.onLoadFinished = function(vStatus) { +page.onLoadFinished = (vStatus) => { phantom.exit(); }; -page.onInitialized = function() { +page.onInitialized = () => { }; -page.onPageCreated = function(oPage) { +page.onPageCreated = (oPage) => { let oCookie: ICookie oPage.addCookie(oCookie); }; page.open(vUrl) // loads a page - .then(function(){ // executed after loading - page.viewportSize = { width:414, height:736 }; + .then(() => { // executed after loading + page.viewportSize = { width: 414, height: 736 }; let vFilename = `../data/page01.png`; - page.render(vFilename, {onlyViewport:true}) + page.render(vFilename, {onlyViewport: true}) // then open a second page return page.open('http://'); }) - .then(function(){ + .then(() => { // click somewhere on the second page page.sendEvent("click", 5, 5, 'left', 0); slimer.exit()