dojo/robotx.js

  • Provides:

    • dojo.robotx
  • dojo.config.debugContainerId

    • summary
  • dojo.config.debugHeight

    • summary
  • iframe.scrolling

    • summary
  • doh.robot._run

    • type
      Function
    • parameters:
      • frame: (typeof )
    • source: [view]
      define("dojo/robotx", ["dojo", "dojo/robot"], function(dojo) {


      dojo.experimental("dojo.robotx");


      // loads an external app into an iframe and points dojo.doc to the iframe document, allowing the robot to control it
      // to use: set robotURL in djConfig to the URL you want to load
      // dojo.require this file


      (function(){


      var iframe = null;


      var groupStarted=dojo.connect(doh, '_groupStarted', function(){
       dojo.disconnect(groupStarted);
       iframe.style.visibility="visible";
      });


      var attachIframe = function(){
       dojo.addOnLoad(function(){
        var emptyStyle = {
         overflow: dojo.isWebKit? 'hidden' : 'visible',
         margin: '0px',
         borderWidth: '0px',
         height: '100%',
         width: '100%'
        };
        dojo.style(document.documentElement, emptyStyle);
        dojo.style(document.body, emptyStyle);
        document.body.appendChild(iframe);
        var base=document.createElement('base');
        base.href=iframe.src;
        document.getElementsByTagName("head")[0].appendChild(base);
       });
      };


      // Prevent race conditions between iframe loading and robot init.
      // If iframe is allowed to load while the robot is typing, sync XHRs can prevent the robot from completing its initialization.
      var robotReady=false;
      var robotFrame=null;
      var _run=doh.robot._run;
      doh.robot._run=function(frame){
       // Called from robot when the robot completed its initialization.
       robotReady = true;
       robotFrame = frame;
       doh.robot._run=_run;
       // If initRobot was already called, then attach the iframe.
       if(iframe.src){ attachIframe(); }
    • summary
  • doh.robot._updateDocument

    • type
      Function
    • source: [view]
        dojo.setContext(iframe.contentWindow, iframe.contentWindow.document);
        var win = dojo.global;
        if(win["dojo"]){
         // allow the tests to subscribe to topics published by the iframe
         dojo._topics = win.dojo._topics;
        }
    • summary
  • doh.robot.initRobot

    • type
      Function
    • parameters:
      • url: (typeof String)
        URL to open. Any of the test's dojo.doc calls (e.g. dojo.byId()), and any dijit.registry calls (e.g. dijit.byId()) will point to elements and widgets inside this application.
    • source: [view]
        iframe.src=url;
        // see above note about race conditions
        if(robotReady){
         attachIframe();

         
        }
    • summary
      Opens the application at the specified URL for testing, redirecting dojo to point to the application environment instead of the test environment.
  • doh.robot.waitForPageToLoad

    • type
      Function
    • parameters:
      • submitActions: (typeof Function)
        The doh.robot will execute the actions the test passes into the submitActions argument (like clicking the submit button),
        expecting these actions to create a page change (like a form submit).
        After these actions execute and the resulting page loads, the next test will start.
    • source: [view]
        var d = new doh.Deferred();
        // create iframe event handler to track submit progress
        onIframeLoad = function(){
         onIframeLoad = null;
         // set dojo.doc on every page change to point to the iframe doc so the robot works
         doh.robot._updateDocument();
         d.callback(true);
        };
        submitActions();
        return d;
    • summary
      Notifies DOH that the doh.robot is about to make a page change in the application it is driving,
      returning a doh.Deferred object the user should return in their runTest function as part of a DOH test.
    • description
      Notifies DOH that the doh.robot is about to make a page change in the application it is driving,
      returning a doh.Deferred object the user should return in their runTest function as part of a DOH test.
      Example:
      runTest:function(){
      return waitForPageLoad(function(){ doh.robot.keyPress(dojo.keys.ENTER, 500); });
      }
  • dojo.robotx

    • type
      Object
    • summary
  • dojo

    • type
      Object
    • summary