B2G/gecko/testing/marionette/marionette-listener.js
/**
 * Navigate to URI. Handles the case where we navigate within an iframe.
 * All other navigation is handled by the server (in chrome space).
 */
Navigate to URI. Handles the case where we navigate within an iframe.
All other navigation is handled by the server (in chrome space).
Navigate to URI . Handles the case where we navigate within an iframe . All other navigation is handled by the server ( in chrome space ) .
function goUrl(msg) {
  let command_id = msg.json.command_id;
  let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
  let start = new Date().getTime();
  let end = null;
  function checkLoad(){
    checkTimer.cancel();
    end = new Date().getTime();
    let errorRegex = /about:.+(error)|(blocked)\?/;
    let elapse = end - start;
    if (msg.json.pageTimeout == null || elapse <= msg.json.pageTimeout){
      if (curWindow.document.readyState == "complete"){
        removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
        sendOk(command_id);
      }
      else if (curWindow.document.readyState == "interactive" && errorRegex.exec(curWindow.document.baseURI)){
        removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
        sendError("Error loading page", 13, null, command_id);
      }
      else{
        checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
      }
    }
    else{
      removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
      sendError("Error loading page, timed out (checkLoad)", 21, null, command_id);
    }
  }
  let onDOMContentLoaded = function onDOMContentLoaded(event){
    if (!event.originalTarget.defaultView.frameElement ||
      event.originalTarget.defaultView.frameElement == curWindow.frameElement) {
      checkLoad();
    }
  };
  function timerFunc(){
    removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
    sendError("Error loading page, timed out (onDOMContentLoaded)", 21, null, command_id);
  }
  if (msg.json.pageTimeout != null){
    checkTimer.initWithCallback(timerFunc, msg.json.pageTimeout, Ci.nsITimer.TYPE_ONE_SHOT);
  }
  addEventListener("DOMContentLoaded", onDOMContentLoaded, false);
  curWindow.location = msg.json.value;
}
function goUrl ( msg ) { let command_id = msg . json . command_id ; let checkTimer = Cc [ "@mozilla.org/timer;1" ] . createInstance ( Ci . nsITimer ) ; let start = new Date ( ) . getTime ( ) ; let end = null ; function checkLoad ( ) { checkTimer . cancel ( ) ; end = new Date ( ) . getTime ( ) ; let errorRegex = / about:.+(error)|(blocked)\? / ; let elapse = end - start ; if ( msg . json . pageTimeout == null || elapse <= msg . json . pageTimeout ) { if ( curWindow . document . readyState == "complete" ) { removeEventListener ( "DOMContentLoaded" , onDOMContentLoaded , false ) ; sendOk ( command_id ) ; } else if ( curWindow . document . readyState == "interactive" && errorRegex . exec ( curWindow . document . baseURI ) ) { removeEventListener ( "DOMContentLoaded" , onDOMContentLoaded , false ) ; sendError ( "Error loading page" , 13 , null , command_id ) ; } else { checkTimer . initWithCallback ( checkLoad , 100 , Ci . nsITimer . TYPE_ONE_SHOT ) ; } } else { removeEventListener ( "DOMContentLoaded" , onDOMContentLoaded , false ) ; sendError ( "Error loading page, timed out (checkLoad)" , 21 , null , command_id ) ; } } let onDOMContentLoaded = function onDOMContentLoaded ( event ) { if ( ! event . originalTarget . defaultView . frameElement || event . originalTarget . defaultView . frameElement == curWindow . frameElement ) { checkLoad ( ) ; } } ; function timerFunc ( ) { removeEventListener ( "DOMContentLoaded" , onDOMContentLoaded , false ) ; sendError ( "Error loading page, timed out (onDOMContentLoaded)" , 21 , null , command_id ) ; } if ( msg . json . pageTimeout != null ) { checkTimer . initWithCallback ( timerFunc , msg . json . pageTimeout , Ci . nsITimer . TYPE_ONE_SHOT ) ; } addEventListener ( "DOMContentLoaded" , onDOMContentLoaded , false ) ; curWindow . location = msg . json . value ; }
Navigate to URI.
Navigate to URI .
// Prevent DOMContentLoaded events from frames from invoking this code, // unless the event is coming from the frame associated with the current // window (i.e., someone has used switch_to_frame).