|
@@ -23,9 +23,9 @@ describe('browser-window module', function () {
|
|
|
|
|
|
before(function (done) {
|
|
|
server = http.createServer(function (req, res) {
|
|
|
- function respond() { res.end(''); }
|
|
|
+ function respond () { res.end('') }
|
|
|
setTimeout(respond, req.url.includes('slow') ? 200 : 0)
|
|
|
- });
|
|
|
+ })
|
|
|
server.listen(0, '127.0.0.1', function () {
|
|
|
server.url = 'http://127.0.0.1:' + server.address().port
|
|
|
done()
|
|
@@ -128,7 +128,7 @@ describe('browser-window module', function () {
|
|
|
'did-get-response-details.html': 'mainFrame',
|
|
|
'logo.png': 'image'
|
|
|
}
|
|
|
- var responses = 0;
|
|
|
+ var responses = 0
|
|
|
w.webContents.on('did-get-response-details', function (event, status, newUrl, oldUrl, responseCode, method, referrer, headers, resourceType) {
|
|
|
responses++
|
|
|
var fileName = newUrl.slice(newUrl.lastIndexOf('/') + 1)
|
|
@@ -290,7 +290,7 @@ describe('browser-window module', function () {
|
|
|
describe('BrowserWindow.setAspectRatio(ratio)', function () {
|
|
|
it('resets the behaviour when passing in 0', function (done) {
|
|
|
var size = [300, 400]
|
|
|
- w.setAspectRatio(1/2)
|
|
|
+ w.setAspectRatio(1 / 2)
|
|
|
w.setAspectRatio(0)
|
|
|
w.once('resize', function () {
|
|
|
var newSize = w.getSize()
|
|
@@ -346,7 +346,7 @@ describe('browser-window module', function () {
|
|
|
if (process.platform === 'darwin') {
|
|
|
app.dock.setIcon(path.join(fixtures, 'assets', 'logo.png'))
|
|
|
}
|
|
|
- w.setProgressBar(.5)
|
|
|
+ w.setProgressBar(0.5)
|
|
|
|
|
|
if (process.platform === 'darwin') {
|
|
|
app.dock.setIcon(null)
|
|
@@ -433,7 +433,7 @@ describe('browser-window module', function () {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe('"enableLargerThanScreen" option', function () {
|
|
|
+ describe('enableLargerThanScreen" option', function () {
|
|
|
if (process.platform === 'linux') {
|
|
|
return
|
|
|
}
|
|
@@ -647,7 +647,7 @@ describe('browser-window module', function () {
|
|
|
w.loadURL('file://' + fixtures + '/api/frame-subscriber.html')
|
|
|
try {
|
|
|
w.webContents.beginFrameSubscription(true, true)
|
|
|
- } catch(e) {
|
|
|
+ } catch (e) {
|
|
|
done()
|
|
|
}
|
|
|
})
|
|
@@ -714,7 +714,7 @@ describe('browser-window module', function () {
|
|
|
|
|
|
describe('loading main frame state', function () {
|
|
|
it('is true when the main frame is loading', function (done) {
|
|
|
- w.webContents.on('did-start-loading', function() {
|
|
|
+ w.webContents.on('did-start-loading', function () {
|
|
|
assert.equal(w.webContents.isLoadingMainFrame(), true)
|
|
|
done()
|
|
|
})
|
|
@@ -722,9 +722,9 @@ describe('browser-window module', function () {
|
|
|
})
|
|
|
|
|
|
it('is false when only a subframe is loading', function (done) {
|
|
|
- w.webContents.once('did-finish-load', function() {
|
|
|
+ w.webContents.once('did-finish-load', function () {
|
|
|
assert.equal(w.webContents.isLoadingMainFrame(), false)
|
|
|
- w.webContents.on('did-start-loading', function() {
|
|
|
+ w.webContents.on('did-start-loading', function () {
|
|
|
assert.equal(w.webContents.isLoadingMainFrame(), false)
|
|
|
done()
|
|
|
})
|
|
@@ -738,9 +738,9 @@ describe('browser-window module', function () {
|
|
|
})
|
|
|
|
|
|
it('is true when navigating to pages from the same origin', function (done) {
|
|
|
- w.webContents.once('did-finish-load', function() {
|
|
|
+ w.webContents.once('did-finish-load', function () {
|
|
|
assert.equal(w.webContents.isLoadingMainFrame(), false)
|
|
|
- w.webContents.on('did-start-loading', function() {
|
|
|
+ w.webContents.on('did-start-loading', function () {
|
|
|
assert.equal(w.webContents.isLoadingMainFrame(), true)
|
|
|
done()
|
|
|
})
|
|
@@ -1000,10 +1000,11 @@ describe('browser-window module', function () {
|
|
|
w.webContents.on('devtools-opened', function () {
|
|
|
var showPanelIntevalId = setInterval(function () {
|
|
|
if (w && w.devToolsWebContents) {
|
|
|
- w.devToolsWebContents.executeJavaScript('(' + (function () {
|
|
|
+ var showLastPanel = function () {
|
|
|
var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
|
|
|
WebInspector.inspectorView.showPanel(lastPanelId)
|
|
|
- }).toString() + ')()')
|
|
|
+ }
|
|
|
+ w.devToolsWebContents.executeJavaScript('(' + showLastPanel.toString() + ')()')
|
|
|
} else {
|
|
|
clearInterval(showPanelIntevalId)
|
|
|
}
|
|
@@ -1075,10 +1076,11 @@ describe('browser-window module', function () {
|
|
|
w.webContents.on('devtools-opened', function () {
|
|
|
var showPanelIntevalId = setInterval(function () {
|
|
|
if (w && w.devToolsWebContents) {
|
|
|
- w.devToolsWebContents.executeJavaScript('(' + (function () {
|
|
|
+ var showLastPanel = function () {
|
|
|
var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
|
|
|
WebInspector.inspectorView.showPanel(lastPanelId)
|
|
|
- }).toString() + ')()')
|
|
|
+ }
|
|
|
+ w.devToolsWebContents.executeJavaScript('(' + showLastPanel.toString() + ')()')
|
|
|
} else {
|
|
|
clearInterval(showPanelIntevalId)
|
|
|
}
|
|
@@ -1127,14 +1129,14 @@ describe('browser-window module', function () {
|
|
|
})
|
|
|
|
|
|
it('works after page load and during subframe load', function (done) {
|
|
|
- w.webContents.once('did-finish-load', function() {
|
|
|
+ w.webContents.once('did-finish-load', function () {
|
|
|
// initiate a sub-frame load, then try and execute script during it
|
|
|
w.webContents.executeJavaScript(`
|
|
|
var iframe = document.createElement('iframe')
|
|
|
iframe.src = '${server.url}/slow'
|
|
|
document.body.appendChild(iframe)
|
|
|
- `, function() {
|
|
|
- w.webContents.executeJavaScript(`console.log('hello')`, function() {
|
|
|
+ `, function () {
|
|
|
+ w.webContents.executeJavaScript('console.log(\'hello\')', function () {
|
|
|
done()
|
|
|
})
|
|
|
})
|
|
@@ -1143,7 +1145,7 @@ describe('browser-window module', function () {
|
|
|
})
|
|
|
|
|
|
it('executes after page load', function (done) {
|
|
|
- w.webContents.executeJavaScript(code, function(result) {
|
|
|
+ w.webContents.executeJavaScript(code, function (result) {
|
|
|
assert.equal(result, expected)
|
|
|
done()
|
|
|
})
|