B2G/gecko/dom/plugins/test/unit/test_bug471245.js
// Creates a fake ProfDS directory key, copied from do_get_profile
Creates a fake ProfDS directory key, copied from do_get_profile
Creates a fake ProfDS directory key copied from do_get_profile
function do_get_profile_startup() {
  let env = Components.classes["@mozilla.org/process/environment;1"]
                      .getService(Components.interfaces.nsIEnvironment);
  let profd = env.get("XPCSHELL_TEST_PROFILE_DIR");
  let file = Components.classes["@mozilla.org/file/local;1"]
                       .createInstance(Components.interfaces.nsILocalFile);
  file.initWithPath(profd);
  let dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                         .getService(Components.interfaces.nsIProperties);
  let provider = {
    getFile: function(prop, persistent) {
      persistent.value = true;
      if (prop == "ProfDS") {
        return file.clone();
      }
      throw Components.results.NS_ERROR_FAILURE;
    },
    QueryInterface: function(iid) {
      if (iid.equals(Components.interfaces.nsIDirectoryServiceProvider) ||
          iid.equals(Components.interfaces.nsISupports)) {
        return this;
      }
      throw Components.results.NS_ERROR_NO_INTERFACE;
    }
  };
  dirSvc.QueryInterface(Components.interfaces.nsIDirectoryService)
        .registerProvider(provider);
  return file.clone();
}
function do_get_profile_startup ( ) { let env = Components . classes [ "@mozilla.org/process/environment;1" ] . getService ( Components . interfaces . nsIEnvironment ) ; let profd = env . get ( "XPCSHELL_TEST_PROFILE_DIR" ) ; let file = Components . classes [ "@mozilla.org/file/local;1" ] . createInstance ( Components . interfaces . nsILocalFile ) ; file . initWithPath ( profd ) ; let dirSvc = Components . classes [ "@mozilla.org/file/directory_service;1" ] . getService ( Components . interfaces . nsIProperties ) ; let provider = { getFile : function ( prop , persistent ) { persistent . value = true ; if ( prop == "ProfDS" ) { return file . clone ( ) ; } throw Components . results . NS_ERROR_FAILURE ; } , QueryInterface : function ( iid ) { if ( iid . equals ( Components . interfaces . nsIDirectoryServiceProvider ) || iid . equals ( Components . interfaces . nsISupports ) ) { return this ; } throw Components . results . NS_ERROR_NO_INTERFACE ; } } ; dirSvc . QueryInterface ( Components . interfaces . nsIDirectoryService ) . registerProvider ( provider ) ; return file . clone ( ) ; }
Creates a fake ProfDS directory key, copied from do_get_profile
Creates a fake ProfDS directory key copied from do_get_profile
// the python harness sets this in the environment for us