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.

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

mercurial