mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
a101af758e
- Bug 967319 - Sort object properties in natural order in the Variables View. r=jaws (e604fc318) - Bug 1023386 - Split and filter properties remotely for objects. r=past (b4889035f) - Bug 1149115 - Make sure source actors are created before breakpoints are reset;r=jlong (76561a3fd) - Bug 1154606 - improve error in debugger when loading source fails r=jsantell (3678eca90) - Bug 1159731 - Move all Addon actor subclasses to a dedicated file. r=ejpbruel (45e012a98) - Bug 1096294 - Display pseudo-arrays like arrays in the console; r=pbrosset (b4b129b3a) - Bug 1169064 - Part 1: Move ObjectActor to object.js r=fitzgen (579cb4f86) - Bug 1169064 - Part 2: Formatted object.js and removed unused protocol request arguments r=fitzgen (4f3178a6a) - Bug 792063 - Add status console shortcut to return the previous command result;r=past (fc1317f9b) - Bug 1169064 - Part 3: Refactor LongStringActor, createValueGrip, stringIsLong and longStripGrip from script.js to object.js r=fitzgen (ecdff41b7) - AltiVec/VMX is 32bit only, use double cast passing uintptr_t to int to fix compilation on PPC64 (93985b589) - Bug 1084525 - Part 7: Expose Promise life time in object grip r=fitzgen (db5000041) - Bug 1084525 - Part 8: Expose Promise time to settle in object grip r=fitzgen (65b7beb26) - Bug 1084525 - Part 9: Implement getDependentPromises method in ObjectClient r=fitzgen (8cc8be31d) - Bug 1148753 - Update browser content toolbox to create a TabSources instance. r=jryans (df6bf505f) - Bug 1050691 - Click on a function on the console should go to the debugger. r=jlongster (e0d225db1) - Bug 1084525 - Part 10: Implement getAllocationStack method in ObjectClient r=fitzgen (199ce4dd9) - Bug 1084525 - Part 12: Fix eslint complaints in promise.js r=fitzgen (7d0a38afe) - Bug 1084525 - Part 13: Add test for asserting the Promise allocation stack in chrome debugging r=fitzgen (60278cf1d) - Bug 1164564 - Refactor Promise-backend.js so it can be required as a CommonJS module on the main thread;r=paolo (7cfe3cdd9) - Bug 1181506 - Define Cc and Ci. r=Yoric (bc3968be3)
102 lines
4.3 KiB
JavaScript
102 lines
4.3 KiB
JavaScript
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
this.EXPORTED_SYMBOLS = [
|
|
"Promise"
|
|
];
|
|
|
|
/**
|
|
* This module implements the "promise" construct, according to the
|
|
* "Promises/A+" proposal as known in April 2013, documented here:
|
|
*
|
|
* <http://promises-aplus.github.com/promises-spec/>
|
|
*
|
|
* A promise is an object representing a value that may not be available yet.
|
|
* Internally, a promise can be in one of three states:
|
|
*
|
|
* - Pending, when the final value is not available yet. This is the only state
|
|
* that may transition to one of the other two states.
|
|
*
|
|
* - Resolved, when and if the final value becomes available. A resolution
|
|
* value becomes permanently associated with the promise. This may be any
|
|
* value, including "undefined".
|
|
*
|
|
* - Rejected, if an error prevented the final value from being determined. A
|
|
* rejection reason becomes permanently associated with the promise. This may
|
|
* be any value, including "undefined", though it is generally an Error
|
|
* object, like in exception handling.
|
|
*
|
|
* A reference to an existing promise may be received by different means, for
|
|
* example as the return value of a call into an asynchronous API. In this
|
|
* case, the state of the promise can be observed but not directly controlled.
|
|
*
|
|
* To observe the state of a promise, its "then" method must be used. This
|
|
* method registers callback functions that are called as soon as the promise is
|
|
* either resolved or rejected. The method returns a new promise, that in turn
|
|
* is resolved or rejected depending on the state of the original promise and on
|
|
* the behavior of the callbacks. For example, unhandled exceptions in the
|
|
* callbacks cause the new promise to be rejected, even if the original promise
|
|
* is resolved. See the documentation of the "then" method for details.
|
|
*
|
|
* Promises may also be created using the "Promise.defer" function, the main
|
|
* entry point of this module. The function, along with the new promise,
|
|
* returns separate methods to change its state to be resolved or rejected.
|
|
* See the documentation of the "Deferred" prototype for details.
|
|
*
|
|
* -----------------------------------------------------------------------------
|
|
*
|
|
* Cu.import("resource://gre/modules/Promise.jsm");
|
|
*
|
|
* // This function creates and returns a new promise.
|
|
* function promiseValueAfterTimeout(aValue, aTimeout)
|
|
* {
|
|
* let deferred = Promise.defer();
|
|
*
|
|
* try {
|
|
* // An asynchronous operation will trigger the resolution of the promise.
|
|
* // In this example, we don't have a callback that triggers a rejection.
|
|
* do_timeout(aTimeout, function () {
|
|
* deferred.resolve(aValue);
|
|
* });
|
|
* } catch (ex) {
|
|
* // Generally, functions returning promises propagate exceptions through
|
|
* // the returned promise, though they may also choose to fail early.
|
|
* deferred.reject(ex);
|
|
* }
|
|
*
|
|
* // We don't return the deferred to the caller, but only the contained
|
|
* // promise, so that the caller cannot accidentally change its state.
|
|
* return deferred.promise;
|
|
* }
|
|
*
|
|
* // This code uses the promise returned be the function above.
|
|
* let promise = promiseValueAfterTimeout("Value", 1000);
|
|
*
|
|
* let newPromise = promise.then(function onResolve(aValue) {
|
|
* do_print("Resolved with this value: " + aValue);
|
|
* }, function onReject(aReason) {
|
|
* do_print("Rejected with this reason: " + aReason);
|
|
* });
|
|
*
|
|
* // Unexpected errors should always be reported at the end of a promise chain.
|
|
* newPromise.then(null, Components.utils.reportError);
|
|
*
|
|
* -----------------------------------------------------------------------------
|
|
*/
|
|
|
|
// These constants must be defined on the "this" object for them to be visible
|
|
// by subscripts in B2G, since "this" does not match the global scope.
|
|
this.Cc = Components.classes;
|
|
this.Ci = Components.interfaces;
|
|
this.Cu = Components.utils;
|
|
this.Cr = Components.results;
|
|
|
|
this.Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
.getService(this.Ci.mozIJSSubScriptLoader)
|
|
.loadSubScript("resource://gre/modules/Promise-backend.js", this);
|