Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Commit 7844620

Browse files
committed
feat: remove bluebird-q compatibility layer
1 parent 07ac412 commit 7844620

File tree

11 files changed

+88
-96
lines changed

11 files changed

+88
-96
lines changed

lib/browser/camera.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const bluebirdQ = require('bluebird-q');
43
const Image = require('../image');
54
const Promise = require('bluebird');
65
const _ = require('lodash');
@@ -30,7 +29,7 @@ module.exports = class Camera {
3029
}
3130

3231
scroll(x, y) {
33-
return bluebirdQ(this._wdRemote.execute(`window.scrollBy(${x},${y})`));
32+
return this._wdRemote.execute(`window.scrollBy(${x},${y})`);
3433
}
3534

3635
_tryScreenshotMethod(method, page) {
@@ -42,7 +41,7 @@ module.exports = class Camera {
4241
}
4342

4443
_takeScreenshot(page) {
45-
return bluebirdQ(this._wdRemote.takeScreenshot())
44+
return this._wdRemote.takeScreenshot()
4645
.then((base64) => {
4746
const image = Image.fromBase64(base64);
4847
return this._applyCalibration(image);
@@ -51,11 +50,11 @@ module.exports = class Camera {
5150
}
5251

5352
_takeScreenshotWithNativeContext(page) {
54-
return bluebirdQ(this._wdRemote.currentContext())
53+
return this._wdRemote.currentContext()
5554
.then((oldContext) => {
56-
return bluebirdQ(this._wdRemote.context('NATIVE_APP'))
55+
return this._wdRemote.context('NATIVE_APP')
5756
.then(this._takeScreenshot.bind(this, page))
58-
.finally(() => bluebirdQ(this._wdRemote.context(oldContext)));
57+
.finally(() => this._wdRemote.context(oldContext));
5958
});
6059
}
6160

lib/browser/existing-browser.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const Browser = require('./browser');
4-
const bluebirdQ = require('bluebird-q');
54

65
module.exports = class ExistingBrowser extends Browser {
76
static fromObject(serializedObject) {
@@ -22,7 +21,7 @@ module.exports = class ExistingBrowser extends Browser {
2221

2322
attach() {
2423
return this._setHttpTimeout()
25-
.then(() => bluebirdQ(this._wd.attach(this.sessionId)))
26-
.thenReturn(this);
24+
.then(() => this._wd.attach(this.sessionId))
25+
.then(() => this);
2726
}
2827
};

lib/browser/new-browser.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const path = require('path');
4-
const bluebirdQ = require('bluebird-q');
54
const browserify = require('browserify');
65
const debug = require('debug');
76
const chalk = require('chalk');
@@ -74,11 +73,11 @@ module.exports = class NewBrowser extends Browser {
7473
}
7574

7675
_applyWdMethodInContext(method, context, args) {
77-
return bluebirdQ(this._wd.currentContext())
76+
return this._wd.currentContext()
7877
.then((originalContext) => {
79-
return bluebirdQ(this._wd.context(context))
78+
return this._wd.context(context)
8079
.then(() => this._applyWdMethod(method, args))
81-
.finally(() => bluebirdQ(this._wd.context(originalContext)));
80+
.finally(() => this._wd.context(originalContext));
8281
});
8382
}
8483

@@ -153,7 +152,7 @@ module.exports = class NewBrowser extends Browser {
153152

154153
initSession() {
155154
return this._setSessionTimeout(this.config.sessionRequestTimeout)
156-
.then(() => bluebirdQ(this._wd.init(this.capabilities)))
155+
.then(() => this._wd.init(this.capabilities))
157156
.spread((sessionId) => {
158157
this.sessionId = sessionId;
159158
this.log('launched session %o', this);
@@ -168,7 +167,7 @@ module.exports = class NewBrowser extends Browser {
168167
return;
169168
}
170169

171-
return bluebirdQ(this._wd.setWindowSize(size.width, size.height))
170+
return this._wd.setWindowSize(size.width, size.height)
172171
.catch((e) => {
173172
// Its the only reliable way to detect not supported operation
174173
// in legacy operadriver.
@@ -196,20 +195,20 @@ module.exports = class NewBrowser extends Browser {
196195
resetZoom: true
197196
});
198197

199-
return bluebirdQ(this._wd.get(url))
198+
return this._wd.get(url)
200199
.then((url) => {
201200
return params.resetZoom
202-
? this._clientBridge.call('resetZoom').thenReturn(url)
201+
? this._clientBridge.call('resetZoom').then(() => url)
203202
: url;
204203
});
205204
}
206205

207206
injectScript(script) {
208-
return bluebirdQ(this._wd.execute(script));
207+
return this._wd.execute(script);
209208
}
210209

211210
evalScript(script) {
212-
return bluebirdQ(this._wd.eval(script));
211+
return this._wd.eval(script);
213212
}
214213

215214
buildScripts() {
@@ -263,7 +262,7 @@ module.exports = class NewBrowser extends Browser {
263262
reset() {
264263
// We can't use findElement here because it requires page with body tag
265264
return this.evalScript('document.body')
266-
.then(body => bluebirdQ(this._wd.moveTo(body, 0, 0)))
265+
.then(body => this._wd.moveTo(body, 0, 0))
267266
.catch(e => {
268267
return Promise.reject(_.extend(e || {}, {
269268
browserId: this.id,
@@ -293,16 +292,16 @@ module.exports = class NewBrowser extends Browser {
293292
}
294293

295294
_maximize() {
296-
return bluebirdQ(this._wd.windowHandle())
297-
.then((handle) => bluebirdQ(this._wd.maximize(handle)));
295+
return this._wd.windowHandle()
296+
.then((handle) => this._wd.maximize(handle));
298297
}
299298

300299
findElement() {
301300
throw new Error('findElement is called before appropriate locator is chosen');
302301
}
303302

304303
_findElementWd(selector) {
305-
return bluebirdQ(this._wd.elementByCssSelector(selector))
304+
return this._wd.elementByCssSelector(selector)
306305
.catch((error) => {
307306
if (error.status === WdErrors.ELEMENT_NOT_FOUND) {
308307
error.selector = selector;
@@ -341,7 +340,7 @@ module.exports = class NewBrowser extends Browser {
341340
}
342341

343342
return this._setSessionTimeout(this.config.sessionQuitTimeout)
344-
.then(() => bluebirdQ(this._wd.quit()))
343+
.then(() => this._wd.quit())
345344
.then(() => this.log('kill browser %o', this))
346345
.then(() => this._setHttpTimeout())
347346
.catch((err) => this.log(err));

lib/capture-session/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ module.exports = class CaptureSession {
5858
return this.browser.captureViewportImage()
5959
.then((screenImage) => screenImage.save(path))
6060
.then(() => (obj.imagePath = path))
61-
.catch(_.noop).thenReturn(obj);
61+
.catch(_.noop)
62+
.then(() => obj);
6263
}
6364

6465
serialize() {

lib/coverage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ const Coverage = module.exports = inherit({
235235
path.join(this.covDir, 'coverage.json'),
236236
JSON.stringify(data, null, 4),
237237
'utf8'
238-
).thenReturn(data);
238+
).then(() => data);
239239
},
240240

241241
prepareOutputStats: function() {

lib/gemini.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const chalk = require('chalk');
55
const _ = require('lodash');
66
const PassthroughEmitter = require('./passthrough-emitter');
77
const Promise = require('bluebird');
8-
const bluebirdQ = require('bluebird-q');
98
const pluginsLoader = require('plugins-loader');
109
const gracefulFs = require('graceful-fs');
1110

@@ -90,7 +89,7 @@ module.exports = class Gemini extends PassthroughEmitter {
9089
}
9190

9291
_exec(fn) {
93-
return bluebirdQ(this._loadPlugins().then(() => fn()));
92+
return this._loadPlugins().then(() => fn());
9493
}
9594

9695
_loadPlugins() {

0 commit comments

Comments
 (0)