author | Nick Fitzgerald <fitzgen@gmail.com> |
Thu, 23 Oct 2014 15:52:00 +0200 | |
changeset 212444 | d4ed6c1353b50ab5bd27e84859453dfe9751ee88 |
parent 212443 | d7e69b0484eece5b972cf67474074599c81079d7 |
child 212445 | 7ab817145c8d390bc3265adc7cbc2e9ea2bc1465 |
push id | 27711 |
push user | cbook@mozilla.com |
push date | Mon, 27 Oct 2014 14:56:47 +0000 |
treeherder | mozilla-central@20408ad61ce5 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | vporof |
bugs | 1033153 |
milestone | 36.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
|
new file mode 100644 --- /dev/null +++ b/browser/devtools/shared/test/unit/test_VariablesView_getString_promise.js @@ -0,0 +1,75 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const Cu = Components.utils; +const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); +const { VariablesView } = Cu.import("resource:///modules/devtools/VariablesView.jsm", {}); + +const PENDING = { + "type": "object", + "class": "Promise", + "actor": "conn0.pausedobj35", + "extensible": true, + "frozen": false, + "sealed": false, + "promiseState": { + "state": "pending" + }, + "preview": { + "kind": "Object", + "ownProperties": {}, + "ownPropertiesLength": 0, + "safeGetterValues": {} + } +}; + +const FULFILLED = { + "type": "object", + "class": "Promise", + "actor": "conn0.pausedobj35", + "extensible": true, + "frozen": false, + "sealed": false, + "promiseState": { + "state": "fulfilled", + "value": 10 + }, + "preview": { + "kind": "Object", + "ownProperties": {}, + "ownPropertiesLength": 0, + "safeGetterValues": {} + } +}; + +const REJECTED = { + "type": "object", + "class": "Promise", + "actor": "conn0.pausedobj35", + "extensible": true, + "frozen": false, + "sealed": false, + "promiseState": { + "state": "rejected", + "reason": 10 + }, + "preview": { + "kind": "Object", + "ownProperties": {}, + "ownPropertiesLength": 0, + "safeGetterValues": {} + } +}; + +function run_test() { + equal(VariablesView.getString(PENDING, { concise: true }), "Promise"); + equal(VariablesView.getString(PENDING), 'Promise {<state>: "pending"}'); + + equal(VariablesView.getString(FULFILLED, { concise: true }), "Promise"); + equal(VariablesView.getString(FULFILLED), 'Promise {<state>: "fulfilled", <value>: 10}'); + + equal(VariablesView.getString(REJECTED, { concise: true }), "Promise"); + equal(VariablesView.getString(REJECTED), 'Promise {<state>: "rejected", <reason>: 10}'); +}
--- a/browser/devtools/shared/test/unit/xpcshell.ini +++ b/browser/devtools/shared/test/unit/xpcshell.ini @@ -2,8 +2,9 @@ head = tail = firefox-appdir = browser skip-if = toolkit == 'android' || toolkit == 'gonk' [test_bezierCanvas.js] [test_cubicBezier.js] [test_undoStack.js] +[test_VariablesView_getString_promise.js] \ No newline at end of file
--- a/browser/devtools/shared/widgets/VariablesView.jsm +++ b/browser/devtools/shared/widgets/VariablesView.jsm @@ -3570,16 +3570,27 @@ VariablesView.stringifiers.byObjectKind // Stringifier for any kind of object. Object: function(aGrip, {concise}) { if (concise) { return aGrip.class; } let {preview} = aGrip; let props = []; + + if (aGrip.class == "Promise" && aGrip.promiseState) { + let { state, value, reason } = aGrip.promiseState; + props.push("<state>: " + VariablesView.getString(state)); + if (state == "fulfilled") { + props.push("<value>: " + VariablesView.getString(value, { concise: true })); + } else if (state == "rejected") { + props.push("<reason>: " + VariablesView.getString(reason, { concise: true })); + } + } + for (let key of Object.keys(preview.ownProperties || {})) { let value = preview.ownProperties[key]; let valueString = ""; if (value.get) { valueString = "Getter"; } else if (value.set) { valueString = "Setter"; } else {