public void reset(String baseUrl) {
   LOGGER.debug("resetting frame group");
   if (proxyInjectionMode) {
     // shut down all but the primary top level connection
     List<FrameAddress> newOrphans = new LinkedList<FrameAddress>();
     for (String uniqueId : uniqueIdToCommandQueue.keySet()) {
       CommandQueue q = getCommandQueue(uniqueId);
       FrameAddress frameAddress = q.getFrameAddress();
       if (frameAddress.getLocalFrameAddress().equals(DEFAULT_LOCAL_FRAME_ADDRESS)
           && frameAddress.getWindowName().equals(DEFAULT_SELENIUM_WINDOW_NAME)) {
         continue;
       }
       if (frameAddress.getLocalFrameAddress().equals(DEFAULT_LOCAL_FRAME_ADDRESS)) {
         if (LOGGER.isDebugEnabled()) {
           LOGGER.debug("Trying to close " + frameAddress);
         }
         try {
           q.doCommandWithoutWaitingForAResponse("close", "", "");
         } catch (WindowClosedException e) {
           LOGGER.debug("Window was already closed");
         }
       }
       orphanedQueues.add(q);
       newOrphans.add(frameAddress);
     }
     for (FrameAddress frameAddress : newOrphans) {
       uniqueIdToCommandQueue.remove(frameAddress);
     }
   }
   removeTemporaryFiles();
   selectWindow(DEFAULT_SELENIUM_WINDOW_NAME);
   // String defaultUrl = "http://localhost:"
   StringBuilder openUrl = new StringBuilder();
   if (proxyInjectionMode) {
     openUrl.append("http://localhost:");
     openUrl.append(portDriversShouldContact);
     openUrl.append("/selenium-server/core/InjectedRemoteRunner.html");
   } else {
     openUrl.append(LauncherUtils.stripStartURL(baseUrl));
   }
   try {
     doCommand("open", openUrl.toString(), ""); // will close out subframes
   } catch (RemoteCommandException rce) {
     LOGGER.debug("RemoteCommandException in reset: " + rce.getMessage());
   }
 }
 private void setCurrentFrameAddress(String uniqueId) {
   assert uniqueId != null;
   FrameAddress frameAddress = uniqueIdToCommandQueue.get(uniqueId).getFrameAddress();
   this.currentUniqueId = uniqueId;
   this.currentFrameAddress = frameAddress;
   this.currentSeleniumWindowName = frameAddress.getWindowName();
   this.currentLocalFrameAddress = frameAddress.getLocalFrameAddress();
   markWhetherJustLoaded(uniqueId, false);
   if (LOGGER.isDebugEnabled()) {
     LOGGER.debug("Current uniqueId set to " + uniqueId + ", frameAddress = " + frameAddress);
   }
 }
 /**
  * Does uniqueId point at a window that matches 'windowName'/'localFrame'?
  *
  * @param uniqueId
  * @param windowName
  * @param localFrame
  * @return True if the frame addressed by uniqueId is addressable by window name 'windowName' and
  *     local frame address 'localFrame'.
  */
 private boolean matchesFrameAddress(String uniqueId, String windowName, String localFrame) {
   // it's an odd selenium convention: "null" maps to the initial, main window:
   if (windowName == null || windowName.equals("null")) {
     windowName = DEFAULT_SELENIUM_WINDOW_NAME;
   }
   if (localFrame == null) {
     localFrame = "top";
   }
   CommandQueue queue = uniqueIdToCommandQueue.get(uniqueId);
   if (queue.isClosed()) {
     return false;
   }
   boolean windowJustLoaded = justLoaded(uniqueId);
   FrameAddress frameAddress = queue.getFrameAddress();
   if (!frameAddress.getLocalFrameAddress().equals(localFrame)) {
     return false;
   }
   // DGF Windows that have just loaded may not know their true identity
   if (windowJustLoaded) {
     String title;
     try {
       title = getRemoteWindowTitle(queue);
     } catch (WindowClosedException e) {
       return false;
     }
     markWhetherJustLoaded(uniqueId, true);
     if (title.equals(windowName)) {
       return true;
     }
   }
   String actualWindowName = frameAddress.getWindowName();
   if (windowName.equals(actualWindowName)) {
     return true;
   }
   if (windowName.equals("_blank") && actualWindowName.startsWith("selenium_blank")) {
     // DGF the API automatically changed target="_blank" to target="selenium_blank12345"
     return true;
   }
   return uniqueIdToCommandQueue.get(uniqueId).isWindowPointedToByJsVariable(windowName);
 }