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,EAIA,SAAU,SAAS,GACjB,IAAI,EAAO,KAYX,KAAK,UAXS,WACZ,IAAI,EAAW,UAAU,QAAQ,QAQjC,OAPA,EAAK,YAAY,SAAS,GAAM,SAAS,EAAK,GACxC,EACF,EAAS,OAAO,GAEhB,EAAS,QAAQ,KAAK,UAAU,GAEpC,IACO,CACT,GAEF,EAGA,YAAa,WACX,OAAQ,KAAK,aAAa,WAC5B,EAIA,UAAW,WACT,IAAK,KAAK,cACR,MAAM,IAAI,MAAM,oBAElB,GAAI,KAAK,kBACP,MAAM,KAAK,kBAEb,OAAO,KAAK,kBACd,GAGF,EAAK,QAAQ,IAAM,iCACrB,EAiBA,WAAW,UAAU,UAAY,SAAS,GACxC,IAAI,EAAqB,UAAY,gCACrC,KAAK,cAAc,EAAoB,EACzC,EAkBA,WAAW,UAAU,MAAQ,SAAS,GACpC,IAAI,EAAqB,UAAY,kCACrC,KAAK,cAAc,EAAoB,EACzC,EASA,QAAQ,WAAa,SAAS,EAAW,EAAa,GACpD,OAAO,IAAI,WAAW,EAAW,EAAa,EAChD","file":"/npm/protractor-elementor@2.0.0/lib/protractor.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/protractor-elementor@2.0.0/lib/protractor.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var util = require('util');\nvar url = require('url');\nvar webdriver = require('selenium-webdriver');\nvar helper = require('./util');\nvar log = require('./logger.js');\nvar ElementArrayFinder = require('./element').ElementArrayFinder;\nvar ElementFinder = require('./element').ElementFinder;\nvar build$ = require('./element').build$;\nvar build$$ = require('./element').build$$;\n\nvar clientSideScripts = require('./clientsidescripts.js');\nvar ProtractorBy = require('./locators.js').ProtractorBy;\nvar ExpectedConditions = require('./expectedConditions.js');\n\n/* global angular */\n\nvar DEFER_LABEL = 'NG_DEFER_BOOTSTRAP!';\nvar DEFAULT_RESET_URL = 'data:text/html,<html></html>';\nvar DEFAULT_GET_PAGE_TIMEOUT = 10000;\n\n/*\n * Mix in other webdriver functionality to be accessible via protractor.\n */\nfor (var foo in webdriver) {\n  exports[foo] = webdriver[foo];\n}\n\n/**\n * @type {ProtractorBy}\n */\nexports.By = new ProtractorBy();\n\n/**\n * @type {ElementFinder}\n */\nexports.ElementFinder = ElementFinder;\n\n/**\n * @type {ElementArrayFinder}\n */\nexports.ElementArrayFinder = ElementArrayFinder;\n\n/**\n * @type {ExpectedConditions}\n */\nexports.ExpectedConditions = new ExpectedConditions();\n\n/**\n * Mix a function from one object onto another. The function will still be\n * called in the context of the original object.\n *\n * @private\n * @param {Object} to\n * @param {Object} from\n * @param {string} fnName\n * @param {function=} setupFn\n */\nvar mixin = function(to, from, fnName, setupFn) {\n  to[fnName] = function() {\n    if (setupFn) {\n      setupFn();\n    }\n    return from[fnName].apply(from, arguments);\n  };\n};\n\n/**\n * Build the helper 'element' function for a given instance of Protractor.\n *\n * @private\n * @param {Protractor} ptor\n * @return {function(webdriver.Locator): ElementFinder}\n */\nvar buildElementHelper = function(ptor) {\n  var element = function(locator) {\n    return new ElementArrayFinder(ptor).all(locator).toElementFinder_();\n  };\n\n  element.all = function(locator) {\n    return new ElementArrayFinder(ptor).all(locator);\n  };\n\n  return element;\n};\n\n/**\n * @alias browser\n * @constructor\n * @extends {webdriver.WebDriver}\n * @param {webdriver.WebDriver} webdriver\n * @param {string=} opt_baseUrl A base URL to run get requests against.\n * @param {string=} opt_rootElement  Selector element that has an ng-app in\n *     scope.\n */\nvar Protractor = function(webdriverInstance, opt_baseUrl, opt_rootElement) {\n  // These functions should delegate to the webdriver instance, but should\n  // wait for Angular to sync up before performing the action. This does not\n  // include functions which are overridden by protractor below.\n  var methodsToSync = ['getCurrentUrl', 'getPageSource', 'getTitle'];\n\n  // Mix all other driver functionality into Protractor.\n  for (var method in webdriverInstance) {\n    if (!this[method] && typeof webdriverInstance[method] == 'function') {\n      if (methodsToSync.indexOf(method) !== -1) {\n        mixin(this, webdriverInstance, method, this.waitForAngular.bind(this));\n      } else {\n        mixin(this, webdriverInstance, method);\n      }\n    }\n  }\n  var self = this;\n\n  /**\n   * The wrapped webdriver instance. Use this to interact with pages that do\n   * not contain Angular (such as a log-in screen).\n   *\n   * @type {webdriver.WebDriver}\n   */\n  this.driver = webdriverInstance;\n\n  /**\n   * Helper function for finding elements.\n   *\n   * @type {function(webdriver.Locator): ElementFinder}\n   */\n  this.element = buildElementHelper(this);\n\n  /**\n   * Shorthand function for finding elements by css.\n   *\n   * @type {function(string): ElementFinder}\n   */\n  this.$ = build$(this.element, webdriver.By);\n\n  /**\n   * Shorthand function for finding arrays of elements by css.\n   *\n   * @type {function(string): ElementArrayFinder}\n   */\n  this.$$ = build$$(this.element, webdriver.By);\n\n  /**\n   * All get methods will be resolved against this base URL. Relative URLs are =\n   * resolved the way anchor tags resolve.\n   *\n   * @type {string}\n   */\n  this.baseUrl = opt_baseUrl || '';\n\n  /**\n   * The css selector for an element on which to find Angular. This is usually\n   * 'body' but if your ng-app is on a subsection of the page it may be\n   * a subelement.\n   *\n   * @type {string}\n   */\n  this.rootEl = opt_rootElement || 'body';\n\n  /**\n   * If true, Protractor will not attempt to synchronize with the page before\n   * performing actions. This can be harmful because Protractor will not wait\n   * until $timeouts and $http calls have been processed, which can cause\n   * tests to become flaky. This should be used only when necessary, such as\n   * when a page continuously polls an API using $timeout.\n   *\n   * @type {boolean}\n   */\n  this.ignoreSynchronization = false;\n\n  /**\n   * Timeout in milliseconds to wait for pages to load when calling `get`.\n   *\n   * @type {number}\n   */\n  this.getPageTimeout = DEFAULT_GET_PAGE_TIMEOUT;\n\n  /**\n   * An object that holds custom test parameters.\n   *\n   * @type {Object}\n   */\n  this.params = {};\n\n  /**\n   * The reset URL to use between page loads.\n   *\n   * @type {string}\n   */\n  this.resetUrl = DEFAULT_RESET_URL;\n  this.driver.getCapabilities().then(function(caps) {\n    // Internet Explorer does not accept data URLs, which are the default\n    // reset URL for Protractor.\n    // Safari accepts data urls, but SafariDriver fails after one is used.\n    var browserName = caps.get('browserName');\n    if (browserName === 'internet explorer' || browserName === 'safari') {\n      self.resetUrl = 'about:blank';\n    }\n  });\n\n  /**\n   * Information about mock modules that will be installed during every\n   * get().\n   *\n   * @type {Array<{name: string, script: function|string, args: Array.<string>}>}\n   */\n  this.mockModules_ = [];\n\n  this.addBaseMockModules_();\n\n  /**\n   * If specified, start a debugger server at specified port instead of repl\n   * when running element explorer.\n   * @private {number}\n   */\n  this.debuggerServerPort_; \n};\n\n/**\n * The same as {@code webdriver.WebDriver.prototype.executeScript},\n * but with a customized description for debugging.\n *\n * @private\n * @param {!(string|Function)} script The script to execute.\n * @param {string} description A description of the command for debugging.\n * @param {...*} var_args The arguments to pass to the script.\n * @return {!webdriver.promise.Promise.<T>} A promise that will resolve to the\n *    scripts return value.\n * @template T\n */\nProtractor.prototype.executeScript_ = function(script, description) {\n  if (typeof script === 'function') {\n    script = 'return (' + script + ').apply(null, arguments);';\n  }\n\n  return this.driver.schedule(\n      new webdriver.Command(webdriver.CommandName.EXECUTE_SCRIPT).\n          setParameter('script', script).\n          setParameter('args', Array.prototype.slice.call(arguments, 2)),\n      description);\n};\n\n/**\n * The same as {@code webdriver.WebDriver.prototype.executeAsyncScript},\n * but with a customized description for debugging.\n *\n * @private\n * @param {!(string|Function)} script The script to execute.\n * @param {string} description A description for debugging purposes.\n * @param {...*} var_args The arguments to pass to the script.\n * @return {!webdriver.promise.Promise.<T>} A promise that will resolve to the\n *    scripts return value.\n * @template T\n */\nProtractor.prototype.executeAsyncScript_ =\n    function(script, description) {\n      if (typeof script === 'function') {\n        script = 'return (' + script + ').apply(null, arguments);';\n      }\n      return this.driver.schedule(\n          new webdriver.Command(webdriver.CommandName.EXECUTE_ASYNC_SCRIPT).\n              setParameter('script', script).\n              setParameter('args', Array.prototype.slice.call(arguments, 2)),\n          description);\n    };\n\n/**\n * Instruct webdriver to wait until Angular has finished rendering and has\n * no outstanding $http or $timeout calls before continuing.\n * Note that Protractor automatically applies this command before every\n * WebDriver action.\n *\n * @param {string=} opt_description An optional description to be added\n *     to webdriver logs.\n * @return {!webdriver.promise.Promise} A promise that will resolve to the\n *    scripts return value.\n */\nProtractor.prototype.waitForAngular = function(opt_description) {\n  var description = opt_description ? ' - ' + opt_description : '';\n  if (this.ignoreSynchronization) {\n    return webdriver.promise.fulfilled();\n  }\n  return this.executeAsyncScript_(\n      clientSideScripts.waitForAngular,\n      'Protractor.waitForAngular()' + description,\n      this.rootEl).\n      then(function(browserErr) {\n        if (browserErr) {\n          throw 'Error while waiting for Protractor to ' +\n                'sync with the page: ' + JSON.stringify(browserErr);\n        }\n    }).then(null, function(err) {\n      var timeout;\n      if (/asynchronous script timeout/.test(err.message)) {\n        // Timeout on Chrome\n        timeout = /-?[\\d\\.]*\\ seconds/.exec(err.message);\n      } else if (/Timed out waiting for async script/.test(err.message)) {\n        // Timeout on Firefox\n        timeout = /-?[\\d\\.]*ms/.exec(err.message);\n      } else if (/Timed out waiting for an asynchronous script/.test(err.message)) {\n        // Timeout on Safari\n        timeout = /-?[\\d\\.]*\\ ms/.exec(err.message);\n      }\n      if (timeout) {\n        throw 'Timed out waiting for Protractor to synchronize with ' +\n            'the page after ' + timeout + '. Please see ' +\n            'https://github.com/angular/protractor/blob/master/docs/faq.md';\n      } else {\n        throw err;\n      }\n    });\n};\n\n/**\n * Waits for Angular to finish rendering before searching for elements.\n * @see webdriver.WebDriver.findElement\n * @return {!webdriver.WebElement}\n */\nProtractor.prototype.findElement = function(locator) {\n  return this.element(locator).getWebElement();\n};\n\n/**\n * Waits for Angular to finish rendering before searching for elements.\n * @see webdriver.WebDriver.findElements\n * @return {!webdriver.promise.Promise} A promise that will be resolved to an\n *     array of the located {@link webdriver.WebElement}s.\n */\nProtractor.prototype.findElements = function(locator) {\n  return this.element.all(locator).getWebElements();\n};\n\n/**\n * Tests if an element is present on the page.\n * @see webdriver.WebDriver.isElementPresent\n * @return {!webdriver.promise.Promise} A promise that will resolve to whether\n *     the element is present on the page.\n */\nProtractor.prototype.isElementPresent = function(locatorOrElement) {\n  var element = (locatorOrElement.isPresent) ?\n      locatorOrElement : this.element(locatorOrElement);\n  return element.isPresent();\n};\n\n/**\n * Add a module to load before Angular whenever Protractor.get is called.\n * Modules will be registered after existing modules already on the page,\n * so any module registered here will override preexisting modules with the same\n * name.\n *\n * @example\n * browser.addMockModule('modName', function() {\n *   angular.module('modName', []).value('foo', 'bar');\n * });\n *\n * @param {!string} name The name of the module to load or override.\n * @param {!string|Function} script The JavaScript to load the module.\n * @param {...*} varArgs Any additional arguments will be provided to\n *     the script and may be referenced using the `arguments` object.\n */\nProtractor.prototype.addMockModule = function(name, script) {\n  var moduleArgs = Array.prototype.slice.call(arguments, 2);\n\n  this.mockModules_.push({\n    name: name,\n    script: script,\n    args: moduleArgs\n  });\n};\n\n/**\n * Clear the list of registered mock modules.\n */\nProtractor.prototype.clearMockModules = function() {\n  this.mockModules_ = [];\n  this.addBaseMockModules_();\n};\n\n/**\n * Remove a registered mock module.\n *\n * @example\n * browser.removeMockModule('modName');\n *\n * @param {!string} name The name of the module to remove.\n */\nProtractor.prototype.removeMockModule = function(name) {\n  for (var i = 0; i < this.mockModules_.length; ++i) {\n    if (this.mockModules_[i].name == name) {\n      this.mockModules_.splice(i, 1);\n    }\n  }\n};\n\n/**\n * Get a list of the current mock modules.\n *\n * @return {Array.<!string|Function>}\n */\nProtractor.prototype.getRegisteredMockModules = function() {\n  return this.mockModules_.map(function(module) {\n    return module.script;\n  });\n};\n\n/**\n * Add the base mock modules used for all Protractor tests.\n *\n * @private\n */\nProtractor.prototype.addBaseMockModules_ = function() {\n  this.addMockModule('protractorBaseModule_', function() {\n    angular.module('protractorBaseModule_', []).\n        config(['$compileProvider', function($compileProvider) {\n          if ($compileProvider.debugInfoEnabled) {\n            $compileProvider.debugInfoEnabled(true);\n          }\n        }]);\n  });\n};\n\n/**\n * @see webdriver.WebDriver.get\n *\n * Navigate to the given destination and loads mock modules before\n * Angular. Assumes that the page being loaded uses Angular.\n * If you need to access a page which does not have Angular on load, use\n * the wrapped webdriver directly.\n *\n * @example\n * browser.get('https://angularjs.org/');\n * expect(browser.getCurrentUrl()).toBe('https://angularjs.org/');\n *\n * @param {string} destination Destination URL.\n * @param {number=} opt_timeout Number of milliseconds to wait for Angular to\n *     start.\n */\nProtractor.prototype.get = function(destination, opt_timeout) {\n  var timeout = opt_timeout ? opt_timeout : this.getPageTimeout;\n  var self = this;\n\n  destination = this.baseUrl.indexOf('file://') === 0 ?\n    this.baseUrl + destination : url.resolve(this.baseUrl, destination);\n  var msg = function(str) {\n    return 'Protractor.get(' + destination + ') - ' + str;\n  };\n\n  if (this.ignoreSynchronization) {\n    return this.driver.get(destination);\n  }\n\n  this.driver.get(this.resetUrl);\n  this.executeScript_(\n      'window.name = \"' + DEFER_LABEL + '\" + window.name;' +\n      'window.location.replace(\"' + destination + '\");',\n      msg('reset url'));\n\n  // We need to make sure the new url has loaded before\n  // we try to execute any asynchronous scripts.\n  this.driver.wait(function() {\n    return self.executeScript_('return window.location.href;', msg('get url')).\n        then(function(url) {\n          return url !== self.resetUrl;\n        }, function(err) {\n          if (err.code == 13) {\n            // Ignore the error, and continue trying. This is because IE\n            // driver sometimes (~1%) will throw an unknown error from this\n            // execution. See https://github.com/angular/protractor/issues/841\n            // This shouldn't mask errors because it will fail with the timeout\n            // anyway.\n            return false;\n          } else {\n            throw err;\n          }\n        });\n  }, timeout,\n  'waiting for page to load for ' + timeout + 'ms');\n\n  // Make sure the page is an Angular page.\n  self.executeAsyncScript_(clientSideScripts.testForAngular,\n      msg('test for angular'),\n      Math.floor(timeout / 1000)).\n      then(function(angularTestResult) {\n        var hasAngular = angularTestResult[0];\n        if (!hasAngular) {\n          var message = angularTestResult[1];\n          throw new Error('Angular could not be found on the page ' +\n              destination + ' : ' + message);\n        }\n      }, function(err) {\n        throw 'Error while running testForAngular: ' + err.message;\n      });\n\n  // At this point, Angular will pause for us until angular.resumeBootstrap\n  // is called.\n  var moduleNames = [];\n  for (var i = 0; i < this.mockModules_.length; ++i) {\n    var mockModule = this.mockModules_[i];\n    var name = mockModule.name;\n    moduleNames.push(name);\n    var executeScriptArgs = [mockModule.script, msg('add mock module ' + name)].\n        concat(mockModule.args);\n    this.executeScript_.apply(this, executeScriptArgs).\n        then(null, function(err) {\n          throw 'Error while running module script ' + name +\n              ': ' + err.message;\n        });\n  }\n\n  return this.executeScript_(\n      'angular.resumeBootstrap(arguments[0]);',\n      msg('resume bootstrap'),\n      moduleNames);\n};\n\n/**\n * @see webdriver.WebDriver.refresh\n *\n * Makes a full reload of the current page and loads mock modules before\n * Angular. Assumes that the page being loaded uses Angular.\n * If you need to access a page which does not have Angular on load, use\n * the wrapped webdriver directly.\n *\n * @param {number=} opt_timeout Number of seconds to wait for Angular to start.\n */\nProtractor.prototype.refresh = function(opt_timeout) {\n  var timeout = opt_timeout || 10;\n  var self = this;\n\n  if (self.ignoreSynchronization) {\n    return self.driver.navigate().refresh();\n  }\n\n  return self.executeScript_(\n      'return window.location.href',\n      'Protractor.refresh() - getUrl').then(function(href) {\n        return self.get(href, timeout);\n      });\n};\n\n/**\n * Mixin navigation methods back into the navigation object so that\n * they are invoked as before, i.e. driver.navigate().refresh()\n */\nProtractor.prototype.navigate = function() {\n  var nav = this.driver.navigate();\n  mixin(nav, this, 'refresh');\n  return nav;\n};\n\n/**\n * Browse to another page using in-page navigation.\n *\n * @example\n * browser.get('http://angular.github.io/protractor/#/tutorial');\n * browser.setLocation('api');\n * expect(browser.getCurrentUrl())\n *     .toBe('http://angular.github.io/protractor/#/api');\n *\n * @param {string} url In page URL using the same syntax as $location.url()\n * @return {!webdriver.promise.Promise} A promise that will resolve once\n *    page has been changed.\n */\nProtractor.prototype.setLocation = function(url) {\n  this.waitForAngular();\n  return this.executeScript_(clientSideScripts.setLocation,\n    'Protractor.setLocation()', this.rootEl, url).then(function(browserErr) {\n      if (browserErr) {\n        throw 'Error while navigating to \\'' + url + '\\' : ' +\n            JSON.stringify(browserErr);\n      }\n    });\n};\n\n/**\n * Returns the current absolute url from AngularJS.\n *\n * @example\n * browser.get('http://angular.github.io/protractor/#/api');\n * expect(browser.getLocationAbsUrl())\n *     .toBe('http://angular.github.io/protractor/#/api');\n */\nProtractor.prototype.getLocationAbsUrl = function() {\n  this.waitForAngular();\n  return this.executeScript_(clientSideScripts.getLocationAbsUrl,\n      'Protractor.getLocationAbsUrl()', this.rootEl);\n};\n\n/**\n * Adds a task to the control flow to pause the test and inject helper functions\n * into the browser, so that debugging may be done in the browser console.\n *\n * This should be used under node in debug mode, i.e. with\n * protractor debug <configuration.js>\n *\n * @example\n * While in the debugger, commands can be scheduled through webdriver by\n * entering the repl:\n *   debug> repl\n *   Press Ctrl + C to leave rdebug repl\n *   > ptor.findElement(protractor.By.input('user').sendKeys('Laura'));\n *   > ptor.debugger();\n *   debug> c\n *\n * This will run the sendKeys command as the next task, then re-enter the\n * debugger.\n */\nProtractor.prototype.debugger = function() {\n  // jshint debug: true\n  this.driver.executeScript(clientSideScripts.installInBrowser);\n  webdriver.promise.controlFlow().execute(function() { debugger; },\n                                          'add breakpoint to control flow');\n};\n\n/**\n * Helper function to:\n *  1) Set up helper functions for debugger clients to call on (e.g.\n *     getControlFlowText, execute code, get autocompletion).\n *  2) Enter process into debugger mode. (i.e. process._debugProcess).\n *  3) Invoke the debugger client specified by debuggerClientPath.\n *\n * @param {string=} debuggerClientPath Absolute path of debugger client to use\n * @param {number=} opt_debugPort Optional port to use for the debugging process\n */\nProtractor.prototype.initDebugger_ = function(debuggerClientPath, opt_debugPort) {\n  // Patch in a function to help us visualize what's going on in the control\n  // flow.\n  webdriver.promise.ControlFlow.prototype.getControlFlowText = function() {\n    var descriptions = [];\n\n    var getDescriptions = function(frameOrTask, descriptions) {\n      if (frameOrTask.getDescription) {\n        var stacktrace = frameOrTask.snapshot_.getStacktrace();\n        stacktrace = stacktrace ? stacktrace.join('\\n').trim() : '';\n        descriptions.push({\n          description: frameOrTask.getDescription(),\n          stack: helper.filterStackTrace(stacktrace)\n        });\n      } else {\n        for (var i = 0; i < frameOrTask.children_.length; ++i) {\n          getDescriptions(frameOrTask.children_[i], descriptions);\n        }\n      }\n    };\n    if (this.history_.length) {\n      getDescriptions(this.history_[this.history_.length - 1], descriptions);\n    }\n    if (this.activeFrame_.getPendingTask()) {\n      getDescriptions(this.activeFrame_.getPendingTask(), descriptions);\n    }\n    getDescriptions(this.activeFrame_.getRoot(), descriptions);\n    var asString = '-- WebDriver control flow schedule \\n';\n    for (var i = 0; i < descriptions.length; ++i) {\n      asString += ' |- ' + descriptions[i].description;\n      if (descriptions[i].stack) {\n        asString += '\\n |---' + descriptions[i].stack.replace(/\\n/g, '\\n |---');\n      }\n      if (i != (descriptions.length - 1)) {\n        asString += '\\n';\n      }\n    }\n    return asString;\n  };\n\n  if (opt_debugPort) {\n    process.debugPort = opt_debugPort;\n  }\n\n  // Call this private function instead of sending SIGUSR1 because Windows.\n  process._debugProcess(process.pid);\n\n  var flow = webdriver.promise.controlFlow();\n  var self = this;\n  var pausePromise = flow.execute(function() {\n    log.puts('Starting WebDriver debugger in a child process. Pause is ' +\n        'still beta, please report issues at github.com/angular/protractor\\n');\n    var args = [process.debugPort];\n    if (self.debuggerServerPort_) {\n      args.push(self.debuggerServerPort_);\n    }\n    var nodedebug = require('child_process').fork(debuggerClientPath, args);\n    process.on('exit', function() {\n      nodedebug.kill('SIGTERM');\n    });\n  });\n\n  var vm_ = require('vm');\n  var context = { require: require };\n  for (var key in global) {\n    context[key] = global[key];\n  }\n  context.list = function(locator) {\n    /* globals browser */\n    return browser.findElements(locator).then(function(arr) {\n      var found = [];\n      for (var i = 0; i < arr.length; ++i) {\n        arr[i].getText().then(function(text) {\n          found.push(text);\n        });\n      }\n      return found;\n    });\n  };\n  var sandbox = vm_.createContext(context);\n  \n  var browserUnderDebug = this;\n\n  // Helper used only by debuggers at './debugger/modes/*.js' to insert code\n  // into the control flow.\n  // In order to achieve this, we maintain a promise at the top of the control\n  // flow, so that we can insert frames into it.\n  // To be able to simulate callback/asynchronous code, we poll this object\n  // for an result at every run of DeferredExecutor.execute.\n  this.dbgCodeExecutor_ = {\n    execPromise_: pausePromise, // Promise pointing to current stage of flow.\n    execPromiseResult_: undefined, // Return value of promise.\n    execPromiseError_: undefined, // Error from promise.\n\n    // A dummy repl server to make use of its completion function.\n    replServer_: require('repl').start({\n      input: {on: function() {}, resume: function() {}}, // dummy readable stream\n      output: {write: function() {}} // dummy writable stream\n    }),\n\n    // Execute a function, which could yield a value or a promise,\n    // and allow its result to be accessed synchronously\n    execute_: function(execFn_) {\n      var self = this;\n      self.execPromiseResult_ = self.execPromiseError_ = undefined;\n\n      self.execPromise_ = self.execPromise_.\n          then(execFn_).then(function(result) {\n            self.execPromiseResult_ = result;\n          }, function(err) {\n            self.execPromiseError_ = err;\n          });\n\n      // This dummy command is necessary so that the DeferredExecutor.execute\n      // break point can find something to stop at instead of moving on to the\n      // next real command.\n      self.execPromise_.then(function() {\n        return browserUnderDebug.executeScript_('', 'empty debugger hook');\n      });\n    },\n\n    // Execute a piece of code.\n    // Result is a string representation of the evaluation.\n    execute: function(code) {\n      var execFn_ = function() {\n        // Run code through vm so that we can maintain a local scope which is\n        // isolated from the rest of the execution.\n        var res = vm_.runInContext(code, sandbox);\n        if (!webdriver.promise.isPromise(res)) {\n          res = webdriver.promise.fulfilled(res);\n        }\n\n        return res.then(function(res) {\n          if (res === undefined) {\n            return undefined;\n          } else {\n            // The '' forces res to be expanded into a string instead of just\n            // '[Object]'. Then we remove the extra space caused by the '' using \n            // substring. \n            return util.format.apply(this, ['', res]).substring(1);\n          }\n        });        \n      };\n      this.execute_(execFn_);\n    },\n\n    // Autocomplete for a line.\n    // Result is a JSON representation of the autocomplete response.\n    complete: function(line) {\n      var self = this;\n      var execFn_ = function() {\n        var deferred = webdriver.promise.defer();\n        self.replServer_.complete(line, function(err, res) {\n          if (err) {\n            deferred.reject(err);\n          } else {\n            deferred.fulfill(JSON.stringify(res));\n          }\n        });\n        return deferred;\n      };\n      this.execute_(execFn_);\n    },\n\n    // Code finished executing.\n    resultReady: function() {\n      return !this.execPromise_.isPending();\n    },\n\n    // Get asynchronous results synchronously.\n    // This will throw if result is not ready.\n    getResult: function() {\n      if (!this.resultReady()) {\n        throw new Error('Result not ready');\n      }\n      if (this.execPromiseError_) {\n        throw this.execPromiseError_;\n      }\n      return this.execPromiseResult_;\n    }\n  };\n\n  flow.timeout(1000, 'waiting for debugger to attach');\n};\n\n/**\n * Beta (unstable) enterRepl function for entering the repl loop from\n * any point in the control flow. Use browser.enterRepl() in your test.\n * Does not require changes to the command line (no need to add 'debug').\n * Note, if you are wrapping your own instance of Protractor, you must\n * expose globals 'browser' and 'protractor' for pause to work.\n *\n * @example\n * element(by.id('foo')).click();\n * browser.enterRepl();\n * // Execution will stop before the next click action.\n * element(by.id('bar')).click();\n *\n * @param {number=} opt_debugPort Optional port to use for the debugging process\n */\nProtractor.prototype.enterRepl = function(opt_debugPort) {\n  var debuggerClientPath = __dirname + '/debugger/clients/explorer.js';\n  this.initDebugger_(debuggerClientPath, opt_debugPort);\n};\n\n/**\n * Beta (unstable) pause function for debugging webdriver tests. Use\n * browser.pause() in your test to enter the protractor debugger from that\n * point in the control flow.\n * Does not require changes to the command line (no need to add 'debug').\n * Note, if you are wrapping your own instance of Protractor, you must\n * expose globals 'browser' and 'protractor' for pause to work.\n *\n * @example\n * element(by.id('foo')).click();\n * browser.pause();\n * // Execution will stop before the next click action.\n * element(by.id('bar')).click();\n *\n * @param {number=} opt_debugPort Optional port to use for the debugging process\n */\nProtractor.prototype.pause = function(opt_debugPort) {\n  var debuggerClientPath = __dirname + '/debugger/clients/wddebugger.js';\n  this.initDebugger_(debuggerClientPath, opt_debugPort);\n};\n\n/**\n * Create a new instance of Protractor by wrapping a webdriver instance.\n *\n * @param {webdriver.WebDriver} webdriver The configured webdriver instance.\n * @param {string=} opt_baseUrl A URL to prepend to relative gets.\n * @return {Protractor}\n */\nexports.wrapDriver = function(webdriver, opt_baseUrl, opt_rootElement) {\n  return new Protractor(webdriver, opt_baseUrl, opt_rootElement);\n};\n"]}