services/sync/tps/extensions/mozmill/resource/modules/stack.js

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 var EXPORTED_SYMBOLS = ['findCallerFrame'];
michael@0 6
michael@0 7
michael@0 8 /**
michael@0 9 * @namespace Defines utility methods for handling stack frames
michael@0 10 */
michael@0 11
michael@0 12 /**
michael@0 13 * Find the frame to use for logging the test result. If a start frame has
michael@0 14 * been specified, we walk down the stack until a frame with the same filename
michael@0 15 * as the start frame has been found. The next file in the stack will be the
michael@0 16 * frame to use for logging the result.
michael@0 17 *
michael@0 18 * @memberOf stack
michael@0 19 * @param {Object} [aStartFrame=Components.stack] Frame to start from walking up the stack.
michael@0 20 * @returns {Object} Frame of the stack to use for logging the result.
michael@0 21 */
michael@0 22 function findCallerFrame(aStartFrame) {
michael@0 23 let frame = Components.stack;
michael@0 24 let filename = frame.filename.replace(/(.*)-> /, "");
michael@0 25
michael@0 26 // If a start frame has been specified, walk up the stack until we have
michael@0 27 // found the corresponding file
michael@0 28 if (aStartFrame) {
michael@0 29 filename = aStartFrame.filename.replace(/(.*)-> /, "");
michael@0 30
michael@0 31 while (frame.caller &&
michael@0 32 frame.filename && (frame.filename.indexOf(filename) == -1)) {
michael@0 33 frame = frame.caller;
michael@0 34 }
michael@0 35 }
michael@0 36
michael@0 37 // Walk even up more until the next file has been found
michael@0 38 while (frame.caller &&
michael@0 39 (!frame.filename || (frame.filename.indexOf(filename) != -1)))
michael@0 40 frame = frame.caller;
michael@0 41
michael@0 42 return frame;
michael@0 43 }

mercurial