public class

BrowserManagerServer

extends UnicastRemoteObject
implements BrowserManager
java.lang.Object
   ↳ java.rmi.server.RemoteObject
     ↳ java.rmi.server.RemoteServer
       ↳ java.rmi.server.UnicastRemoteObject
         ↳ com.google.gwt.junit.remote.BrowserManagerServer

Class Overview

Manages instances of a web browser as child processes. This class is experimental and unsupported. An instance of this class can create browser windows using one specific shell-level command. It performs process management (baby sitting) on behalf of a remote client. This can be useful for running a GWTTestCase on a browser that cannot be run on the native platform. For example, a GWTTestCase test running on Linux could use a remote call to a Windows machine to test with Internet Explorer.

Calling main(String[]) can instantiate and register multiple instances of this class at given RMI namespace locations.

This system has been tested on Internet Explorer 6 & 7. Firefox does not work in the general case; if an existing Firefox process is already running, new processes simply delegate to the existing process and terminate, which breaks the model. A shell script that sets MOZNOREMOTE=1 and cleans up locks/sessions is needed. Safari on MacOS requires very special treatment given Safari's poor command line support, but that is beyond the scope of this documentation.

TODO(scottb): We technically need a watchdog thread to slurp up stdout and stderr from the child processes, or they might block. However, most browsers never write to stdout and stderr, so this is low priority. (There is now a thread that is spawned for each task to wait for an exit value - this might be adapted for that purpose one day.)

This class is not actually serializable as-is, because timer is not serializable.

see http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4062587

Summary

[Expand]
Inherited Fields
From class java.rmi.server.RemoteObject
Public Methods
void keepAlive(int token, long keepAliveMs)
Keeps the browser process represented by token alive for keepAliveMs, starting now.
void killBrowser(int token)
Forceably kills the browser process represented by token, disregarding any previous calls to keepAlive(int, long).
int launchNewBrowser(String url, long keepAliveMs)
Launches a new browser window for the specified URL.
static void main(String[] args)
Starts up and registers one or more browser servers.
[Expand]
Inherited Methods
From class java.rmi.server.UnicastRemoteObject
From class java.rmi.server.RemoteServer
From class java.rmi.server.RemoteObject
From class java.lang.Object
From interface com.google.gwt.junit.remote.BrowserManager

Public Methods

public void keepAlive (int token, long keepAliveMs)

Keeps the browser process represented by token alive for keepAliveMs, starting now.

Parameters
token an opaque token representing the browser window
keepAliveMs the number of milliseconds to let the browser process live; if roughly keepAliveMs milliseconds elapse without a subsequent call to this method, the browser process associated with token will be forceably terminated

public void killBrowser (int token)

Forceably kills the browser process represented by token, disregarding any previous calls to keepAlive(int, long). If the process has already terminated, this method completes normally.

Parameters
token an opaque token representing the browser window process
See Also

public int launchNewBrowser (String url, long keepAliveMs)

Launches a new browser window for the specified URL.

Parameters
url the URL to browse to
keepAliveMs the initial number of milliseconds to let the browser process live; if roughly keepAliveMs milliseconds expire without a subsequent call to keepAlive(int, long), the browser process will be forceably terminated
Returns
  • a positive integer that serves an an opaque token representing the new browser window.

public static void main (String[] args)

Starts up and registers one or more browser servers. Command-line entry point.

Throws
Exception