author | Andreas Tolfsen <ato@mozilla.com> |
Thu, 02 Feb 2017 16:09:14 +0000 | |
changeset 341025 | 589a01fb47900ae737c74f6b288d3245cece847e |
parent 341024 | 2c9ed54ef2e183336c4903c84d853dc0ff0a38ee |
child 341026 | c93a410adde07a4393778b1cbec7257bed7ef39e |
push id | 86615 |
push user | kwierso@gmail.com |
push date | Tue, 07 Feb 2017 01:52:08 +0000 |
treeherder | mozilla-inbound@f0453084d86e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | maja_zf |
bugs | 1336124 |
milestone | 54.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
testing/marionette/assert.js | file | annotate | diff | comparison | revisions | |
testing/marionette/test_assert.js | file | annotate | diff | comparison | revisions |
--- a/testing/marionette/assert.js +++ b/testing/marionette/assert.js @@ -17,16 +17,36 @@ this.EXPORTED_SYMBOLS = ["assert"]; const isFennec = () => AppConstants.platform == "android"; const isB2G = () => AppConstants.MOZ_B2G; const isFirefox = () => Services.appinfo.name == "Firefox"; /** Shorthands for common assertions made in Marionette. */ this.assert = {}; /** + * Asserts that Marionette has a session. + * + * @param {GeckoDriver} driver + * Marionette driver instance. + * @param {string=} msg + * Custom error message. + * + * @return {string} + * Session ID. + * + * @throws {InvalidSessionIdError} + * If |driver| does not have a session ID. + */ +assert.session = function (driver, msg = "") { + assert.that(sessionID => sessionID, + msg, InvalidSessionIdError)(driver.sessionId); + return driver.sessionId; +}; + +/** * Asserts that the current browser is Firefox Desktop. * * @param {string=} msg * Custom error message. * * @throws {UnsupportedOperationError} * If current browser is not Firefox. */
--- a/testing/marionette/test_assert.js +++ b/testing/marionette/test_assert.js @@ -4,16 +4,25 @@ "use strict"; const {utils: Cu} = Components; Cu.import("chrome://marionette/content/assert.js"); Cu.import("chrome://marionette/content/error.js"); +add_test(function test_session() { + assert.session({sessionId: "foo"}); + for (let typ of [null, undefined, ""]) { + Assert.throws(() => assert.session({sessionId: typ}), InvalidSessionIdError); + } + + run_next_test(); +}); + add_test(function test_platforms() { // at least one will fail let raised; for (let fn of [assert.firefox, assert.fennec, assert.b2g, assert.mobile]) { try { fn(); } catch (e) { raised = e;