*/
-package org.mozilla.webclient;
+package org.mozilla.mcp;
/*
* RandomHTMLInputStream.java
*/
-import org.mozilla.util.Assert;
-import org.mozilla.util.ParameterCheck;
-
+import java.io.BufferedReader;
import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.Random;
/**
@@ -41,7 +40,7 @@ import java.util.Random;
*/
-public class RandomHTMLInputStream extends InputStream
+class RandomHTMLInputStream extends InputStream
{
//
@@ -49,6 +48,11 @@ public class RandomHTMLInputStream extends InputStream
//
private static final int MAX_AVAILABLE = 4096;
+private static final int MIN_AVAILABLE = 71;
+
+private static final String HTML_START = "START Random Data\n";
+private static final String HTML_END = "\nEND Random Data
\n";
+
/**
@@ -101,16 +105,24 @@ static {
public RandomHTMLInputStream(int yourNumReads, boolean yourRandomExceptions)
{
- ParameterCheck.greaterThan(yourNumReads, 1);
+ this(yourNumReads, -1, yourRandomExceptions);
+}
+
+public RandomHTMLInputStream(int yourNumReads, int size, boolean yourRandomExceptions)
+{
randomExceptions = yourRandomExceptions;
random = new Random(1234);
- Assert.assert_it(null != random);
isClosed = false;
firstRead = true;
numReads = yourNumReads;
- available = random.nextInt(MAX_AVAILABLE);
+ if (-1 == size) {
+ available = MAX_AVAILABLE;
+ }
+ else {
+ available = size;
+ }
}
public int available() throws IOException
@@ -120,7 +132,7 @@ public int available() throws IOException
throw new IOException("It's time for an IOException!");
}
if (isClosed) {
- result = -1;
+ result = 0;
}
else {
result = available;
@@ -154,107 +166,84 @@ public int read(byte[] b, int off, int len) throws IOException
byte [] bytes;
int i = 0;
int max = 0;
- int numRead = -1;
+ int numRead = 0;
- // write case 0, no more reads left
- if (0 == numReads || isClosed) {
+ // base write case, the stream has been closed
+ if (isClosed) {
return -1;
}
- if (len <= available) {
- max = len;
+ // write case 0, no more reads left
+ if (0 == numReads) {
+ available = 0;
+ return -1;
}
- else {
- max = available;
- }
-
if (firstRead) {
- String htmlHead = "START Random Data";
- numRead = htmlHead.length();
-
+ maybeSleep();
// write case 1, yes enough length to write htmlHead
- if (numRead < len && len <= available) {
- bytes = htmlHead.getBytes();
- for (i = 0; i < numRead; i++) {
+ max = HTML_START.length();
+ if (numRead < len) {
+ bytes = HTML_START.getBytes();
+ for (i = 0; i < max; i++) {
b[off+i] = bytes[i];
}
- available -= numRead;
- }
- else {
- // write case 2, not enough length to write htmlHead
- for (i = 0; i < max; i++) {
- b[off+i] = (byte) random.nextInt(8);
- }
- numRead = max;
+ numRead += max;
available -= max;
}
firstRead = false;
}
else {
- // if this is the last read
+ // If this is the last read...
if (1 == numReads) {
- String htmlTail = "\nEND Random Data";
- numRead = htmlTail.length();
- // write case 3, yes enough length to write htmlTail
- if (numRead < len && len <= available) {
- bytes = htmlTail.getBytes();
- for (i = 0; i < numRead; i++) {
- b[off+i] = bytes[i];
- }
- available -= numRead;
- }
- else {
- // write case 4, not enough length to write htmlTail
- for (i = 0; i < max; i++) {
- b[off+i] = (byte) random.nextInt(8);
- }
- numRead = max;
- available -= max;
- }
- try {
- synchronized(this) {
- this.notify();
- }
- }
- catch (Exception e) {
- throw new IOException("RandomHTMLInputStream: Can't notify listeners");
- }
- available = -1;
- return numRead;
+ numRead = writeHTMLEnd(b, off, len);
}
else {
-
- // if it's time to block
- if (random.nextBoolean()) {
- try {
- System.out.println("RandomHTMLInputStream:: sleeping");
- System.out.flush();
- Thread.sleep(3000);
- }
- catch (Exception e) {
- throw new IOException(e.getMessage());
- }
- }
-
- // write case 5, write some random bytes to fit length
-
- // this is not the first or the last read, just cough up
- // some random bytes.
-
- bytes = new byte[max];
- for (i = 0; i < max; i++) {
- if (0 == (i % 78)) {
- b[off+i] = (byte) '\n';
+ // If we have more bytes than HTML_END.length...
+ if (HTML_END.length() <= available) {
+ // Write some random stuff.
+ // If what we have is greater than or equal to what was asked for...
+ if (len <= available) {
+ // If both len and available are less than or equal to HTML_END...
+ if ((len - HTML_END.length()) <= 0) {
+ // just write HTML_END.
+ numRead = writeHTMLEnd(b, off, len);
+ numReads = 0;
+ return numRead;
+ }
+ else {
+ // otherwise, write some filler
+ max = len - HTML_END.length();
+ }
}
else {
- b[off+i] = CHARSET[random.nextInt(CHARSET.length)];
+ // otherwise, write some filler
+ max = available - HTML_END.length();
+ if (0 == max) {
+ // just write HTML_END.
+ numRead = writeHTMLEnd(b, off, len);
+ numReads = 0;
+ return numRead;
+ }
}
+ maybeSleep();
+ bytes = new byte[max];
+ for (i = 0; i < max; i++) {
+ if (0 == (i % 78)) {
+ b[off+i] = (byte) '\n';
+ }
+ else {
+ b[off+i] = CHARSET[random.nextInt(CHARSET.length)];
+ }
+ }
+ numRead += max;
+ available -= max;
+ }
+ else {
+ // Otherwise, just write HTML_END
+ writeHTMLEnd(b, off, len);
}
- numRead = max;
- available -= max;
}
}
- available = random.nextInt(MAX_AVAILABLE);
numReads--;
return numRead;
}
@@ -275,6 +264,58 @@ public void close() throws IOException
}
}
+private int writeHTMLEnd(byte [] b, int off, int len) {
+ int numRead = -1;
+ byte [] bytes = HTML_END.getBytes();
+ int i, max = 0;
+
+ // Determine how many bytes of HTML_END to write.
+
+ // If we have enough space to write out HTML_END,...
+ if (bytes.length <= available) {
+ // verify the caller can handle all of HTML_END...
+ if (bytes.length <= len) {
+ // write out the whole HTML_END.
+ max = bytes.length;
+ }
+ // if not, write out only the first len bytes of HTML_END
+ else {
+ max = len;
+ }
+ }
+ else {
+ // We do not have enough space to write out HTML_END.
+ if (available <= len) {
+ // If what we have is less than or equal to what the caller asked for...
+ max = available;
+ }
+ else {
+ // What we have is more than the caller asked for.
+ max = len;
+ }
+ }
+ for (i = 0; i < max; i++) {
+ b[off+i] = bytes[i];
+ }
+ numRead = max;
+ available -= max;
+
+ return numRead;
+}
+
+private void maybeSleep() throws IOException {
+ if (random.nextBoolean()) {
+ try {
+ System.out.println("RandomHTMLInputStream:: sleeping");
+ System.out.flush();
+ Thread.sleep(3000);
+ }
+ catch (Exception e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+}
+
private boolean shouldThrowException()
{
if (!randomExceptions) {
@@ -290,4 +331,5 @@ private boolean shouldThrowException()
return result;
}
+
}
diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/mcp/THTTPD.java b/mozilla/java/webclient/classes_spec/org/mozilla/mcp/THTTPD.java
index 3104ccfe08f..6755e8aaa7d 100755
--- a/mozilla/java/webclient/classes_spec/org/mozilla/mcp/THTTPD.java
+++ b/mozilla/java/webclient/classes_spec/org/mozilla/mcp/THTTPD.java
@@ -1,5 +1,5 @@
/*
- * $Id: THTTPD.java,v 1.1 2007-05-04 17:10:17 edburns%acm.org Exp $
+ * $Id: THTTPD.java,v 1.2 2007-06-13 16:57:17 edburns%acm.org Exp $
*/
/*
@@ -27,6 +27,7 @@
package org.mozilla.mcp;
import java.io.File;
+import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.FileInputStream;
@@ -34,7 +35,8 @@ import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
-import java.io.BufferedWriter;
+import java.net.SocketException;
+import java.util.logging.Level;
// THTTPD.java
@@ -43,6 +45,22 @@ public class THTTPD extends Object {
public final static int PORT = 5243;
+ public static InputStream newRandomHtmlInputStream(int yourNumReads,
+ boolean yourRandomExceptions) {
+ InputStream result = new RandomHTMLInputStream(yourNumReads,
+ yourRandomExceptions);
+ return result;
+ }
+
+ public static InputStream newRandomHtmlInputStream(int yourNumReads,
+ int yourSize,
+ boolean yourRandomExceptions) {
+ InputStream result = new RandomHTMLInputStream(yourNumReads,
+ yourSize,
+ yourRandomExceptions);
+ return result;
+ }
+
public static class ServerThread extends Thread {
protected File root = null;
@@ -55,7 +73,7 @@ public class THTTPD extends Object {
public final static int REQUEST_POST = 3;
protected StringBuffer requestData = null;
-
+
public ServerThread(String name, File root,
int maxRequests) {
super(name);
@@ -96,7 +114,7 @@ public class THTTPD extends Object {
responseReader = null,
requestReader = null;
InputStream socketInputStream = null;
- BufferedWriter
+ OutputStreamWriter
responseWriter = null;
String
requestLine = null,
@@ -139,19 +157,37 @@ public class THTTPD extends Object {
System.out.println("THTTPD: POST");
// intentional fall through!
case REQUEST_GET:
- responseWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
- if (null !=
- (responseFile = getFileForRequestURI(getRequestURI(requestLine)))) {
- curLine = "HTTP/1.0 200 OK\r\n";
+ responseWriter = new OutputStreamWriter(socket.getOutputStream(), "US-ASCII");
+ curLine = "HTTP/1.0 200 OK\r\nServer: THTTPD\r\n";
+ responseWriter.write(curLine, 0, curLine.length());
+ String requestURI = getRequestURI(requestLine);
+ responseReader = null;
+ if (requestURI.equals("/randomHtml")) {
+ curLine = "Content-type: text/html\r\n\r\n";
responseWriter.write(curLine, 0,
curLine.length());
+ RandomHTMLInputStream instance = new RandomHTMLInputStream(100, 65380, false);
+ InputStreamReader isr = new InputStreamReader(instance,
+ "US-ASCII");
+ int n;
+ char [] line = new char[2048];
+ while (-1 != (n = isr.read(line, 0, 2048))) {
+ curLine = new String(line, 0, n);
+ responseWriter.write(curLine, 0, curLine.length());
+ responseWriter.flush();
+ }
+ if (-1 == n) {
+ responseWriter.close();
+ }
+
+ } else if (null != (responseFile =
+ getFileForRequestURI(requestURI))) {
responseReader = new BufferedReader(new InputStreamReader(new FileInputStream(responseFile)));
- responseString = new StringBuffer();
+ responseString = new StringBuffer();
while (null != (curLine = responseReader.readLine())) {
responseString.append(curLine);
}
- curLine = "Server: THTTPD\r\n" +
- "Content-type: " +
+ curLine = "Content-type: " +
getContentTypeForFile(responseFile) +
"\r\nContent-Length: " +
responseString.length() + "\r\n\r\n";
@@ -168,9 +204,30 @@ public class THTTPD extends Object {
socket.close();
serverSocket.close();
}
+ catch (SocketException se) {
+ if (MCP.LOGGER.isLoggable(Level.SEVERE)) {
+ MCP.LOGGER.log(Level.SEVERE,
+ "Error while writing response", se);
+ }
+ try {
+ socket.close();
+ serverSocket.close();
+ } catch (IOException ex) {
+ if (MCP.LOGGER.isLoggable(Level.SEVERE)) {
+ MCP.LOGGER.log(Level.SEVERE,
+ "Error while trying to clean up after SocketException. Exiting Server.",
+ ex);
+ }
+ stopRunning();
+ }
+
+ }
catch (Exception e) {
- System.out.println("Exception: " + e + " " +
- e.getMessage());
+ if (MCP.LOGGER.isLoggable(Level.SEVERE)) {
+ MCP.LOGGER.log(Level.SEVERE,
+ "Error serving response. Exiting Server.",
+ e);
+ }
stopRunning();
}
}
diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java
index 7ac6c6e6a9e..4f6578ce05a 100644
--- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java
+++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java
@@ -44,6 +44,7 @@ import javax.swing.*;
import java.util.Enumeration;
import java.util.Properties;
import java.util.*;
+import org.mozilla.mcp.RandomHTMLInputStream;
import org.mozilla.webclient.*;
import org.mozilla.util.Assert;
@@ -59,7 +60,7 @@ import java.io.FileInputStream;
* This is a test application for using the BrowserControl.
*
- * @version $Id: EMWindow.java,v 1.45 2004-09-09 20:17:16 edburns%acm.org Exp $
+ * @version $Id: EMWindow.java,v 1.46 2007-06-13 16:57:17 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/RandomHTMLInputStream.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/RandomHTMLInputStream.java
deleted file mode 100644
index 091a1d5d59a..00000000000
--- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/RandomHTMLInputStream.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * The contents of this file are subject to the Mozilla Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * The Original Code is RaptorCanvas.
- *
- * The Initial Developer of the Original Code is Kirk Baker and
- * Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
- * Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
- * Rights Reserved.
- *
- * Contributor(s): Ed Burns
- */
-
-package org.mozilla.webclient.test;
-
-/*
- * RandomHTMLInputStream.java
- */
-
-import org.mozilla.util.Assert;
-import org.mozilla.util.ParameterCheck;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.util.Random;
-
-/**
-
- * This class simulates a nasty, misbehavin' InputStream.
-
- * It randomly throws IOExceptions, blocks on read, and is bursty.
-
- */
-
-public class RandomHTMLInputStream extends InputStream
-{
-
-//
-// Class variables
-//
-
-private static final int MAX_AVAILABLE = 4096;
-
-/**
-
- * This makes it so only when we get a random between 0 and 100 number
- * that evenly divides by three do we throw an IOException
-
- */
-
-private static final int EXCEPTION_DIVISOR = 179;
-
-private static final byte [] CHARSET;
-
-//
-// relationship ivars
-//
-
-private Random random;
-
-//
-// attribute ivars
-//
-
-private boolean isClosed;
-
-private boolean firstRead;
-
-/**
-
- * the number of times that read(bytearray) can be called and still get
- * data.
-
- */
-
-private int numReads;
-
-private int available;
-
-/**
-
- * @param yourNumReads must be at least 2
-
- */
-
-static {
- String charSet = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890[]{}";
- CHARSET = charSet.getBytes();
-}
-
-public RandomHTMLInputStream(int yourNumReads)
-{
- ParameterCheck.greaterThan(yourNumReads, 1);
-
- random = new Random();
- Assert.assert_it(null != random);
-
- isClosed = false;
- firstRead = true;
- numReads = yourNumReads;
- available = random.nextInt(MAX_AVAILABLE);
-}
-
-public int available() throws IOException
-{
- int result;
- if (shouldThrowException()) {
- throw new IOException("It's time for an IOException!");
- }
- if (isClosed) {
- result = -1;
- }
- else {
- result = available;
- }
- return result;
-}
-
-public int read() throws IOException
-{
- int result = 0;
- if (shouldThrowException()) {
- throw new IOException("It's time for an IOException!");
- }
-
- if (0 < available) {
- result = (int) 'a';
- available--;
- }
- else {
- result = -1;
- }
- return result;
-}
-
-public int read(byte[] b, int off, int len) throws IOException
-{
- if (shouldThrowException()) {
- throw new IOException("It's time for an IOException!");
- }
-
- byte [] bytes;
- int i = 0;
- int max = 0;
- int numRead = -1;
-
- // write case 0, no more reads left
- if (0 == numReads || isClosed) {
- return -1;
- }
- if (len <= available) {
- max = len;
- }
- else {
- max = available;
- }
-
-
- if (firstRead) {
- String htmlHead = "START Random Data";
- numRead = htmlHead.length();
-
- // write case 1, yes enough length to write htmlHead
- if (numRead < len && len <= available) {
- bytes = htmlHead.getBytes();
- for (i = 0; i < numRead; i++) {
- b[off+i] = bytes[i];
- }
- available -= numRead;
- }
- else {
- // write case 2, not enough length to write htmlHead
- for (i = 0; i < max; i++) {
- b[off+i] = (byte) random.nextInt(8);
- }
- numRead = max;
- available -= max;
- }
- firstRead = false;
- }
- else {
- // if this is the last read
- if (1 == numReads) {
- String htmlTail = "\nEND Random Data";
- numRead = htmlTail.length();
- // write case 3, yes enough length to write htmlTail
- if (numRead < len && len <= available) {
- bytes = htmlTail.getBytes();
- for (i = 0; i < numRead; i++) {
- b[off+i] = bytes[i];
- }
- available -= numRead;
- }
- else {
- // write case 4, not enough length to write htmlTail
- for (i = 0; i < max; i++) {
- b[off+i] = (byte) random.nextInt(8);
- }
- numRead = max;
- available -= max;
- }
- }
- else {
-
- // if it's time to block
- if (random.nextBoolean()) {
- try {
- System.out.println("RandomHTMLInputStream:: sleeping");
- Thread.sleep(3000);
- }
- catch (Exception e) {
- throw new IOException(e.getMessage());
- }
- }
-
- // write case 5, write some random bytes to fit length
-
- // this is not the first or the last read, just cough up
- // some random bytes.
-
- bytes = new byte[max];
- for (i = 0; i < max; i++) {
- if (0 == (i % 78)) {
- b[off+i] = (byte) '\n';
- }
- else {
- b[off+i] = CHARSET[random.nextInt(CHARSET.length)];
- }
- }
- numRead = max;
- available -= max;
- }
- }
- available = random.nextInt(MAX_AVAILABLE);
- numReads--;
- return numRead;
-}
-
-public void close() throws IOException
-{
- if (shouldThrowException()) {
- throw new IOException("It's time for an IOException!");
- }
- isClosed = true;
-}
-
-private boolean shouldThrowException()
-{
- int nextInt = random.nextInt(10000);
-
- boolean result = false;
-
- if (nextInt > EXCEPTION_DIVISOR) {
- result = (0 == (nextInt % EXCEPTION_DIVISOR));
- }
- return result;
-}
-
-}
diff --git a/mozilla/java/webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java b/mozilla/java/webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java
index 68f5617b81a..b62b5944d85 100644
--- a/mozilla/java/webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java
+++ b/mozilla/java/webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java
@@ -1,5 +1,5 @@
/*
- * $Id: NavigationTest.java,v 1.22 2007-05-04 17:10:35 edburns%acm.org Exp $
+ * $Id: NavigationTest.java,v 1.23 2007-06-13 16:57:17 edburns%acm.org Exp $
*/
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
@@ -26,6 +26,7 @@
package org.mozilla.webclient;
+import java.io.InputStream;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -36,6 +37,7 @@ import java.awt.BorderLayout;
import java.io.File;
import java.io.FileInputStream;
+import org.mozilla.mcp.THTTPD;
import org.mozilla.mcp.junit.WebclientTestCase;
// NavigationTest.java
@@ -83,8 +85,7 @@ public class NavigationTest extends WebclientTestCase {
assertNotNull(canvas);
Frame frame = new Frame();
- frame.setUndecorated(true);
- frame.setBounds(0, 0, 640, 480);
+ frame.setBounds(0, 30, 640, 480);
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);
canvas.setVisible(true);
@@ -129,7 +130,7 @@ public class NavigationTest extends WebclientTestCase {
//
// try loading from the dreaded RandomHTMLInputStream
//
- RandomHTMLInputStream rhis = new RandomHTMLInputStream(10, false);
+ InputStream rhis = THTTPD.newRandomHtmlInputStream(10, 13320, false);
eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() {
public void doEndCheck() {
@@ -189,8 +190,7 @@ public class NavigationTest extends WebclientTestCase {
assertNotNull(canvas);
Frame frame = new Frame();
- frame.setUndecorated(true);
- frame.setBounds(0, 0, 640, 480);
+ frame.setBounds(0, 30, 640, 480);
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);
canvas.setVisible(true);
@@ -202,23 +202,18 @@ public class NavigationTest extends WebclientTestCase {
firstBrowserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
NavigationTest.keepWaiting = true;
- //
- // try loading from the dreaded RandomHTMLInputStream
- //
- RandomHTMLInputStream rhis = new RandomHTMLInputStream(10, false);
eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() {
private int progressCalls = 0;
public void doProgressCheck() {
- if (5 == ++progressCalls) {
+ if (2 == ++progressCalls) {
nav.stop();
NavigationTest.keepWaiting = false;
}
}
});
- nav.loadFromStream(rhis, "http://randomstream.com/",
- "text/html", -1, null);
+ nav.loadURL("http://localhost:5243/randomHtml");
// keep waiting until the previous load completes
while (NavigationTest.keepWaiting) {
@@ -249,7 +244,6 @@ public class NavigationTest extends WebclientTestCase {
assertNotNull(canvas);
Frame frame = new Frame();
- frame.setUndecorated(true);
frame.setBounds(0, 0, 640, 480);
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);
@@ -267,8 +261,40 @@ public class NavigationTest extends WebclientTestCase {
// try loading a file over HTTP
//
- NavigationTest.keepWaiting = true;
+ // clear cache listener
+ listener = new DocumentLoadListenerImpl() {
+ public void doEndCheck() {
+ NavigationTest.keepWaiting = false;
+ }
+ };
+
+ eventRegistration.addDocumentLoadListener(listener);
+
+ String url = "http://localhost:5243/HttpNavigationTest.txt";
+
+ Thread.currentThread().sleep(3000);
+ NavigationTest.keepWaiting = true;
+
+ nav.loadURL(url);
+
+ // keep waiting until the previous load completes
+ while (NavigationTest.keepWaiting) {
+ Thread.currentThread().sleep(1000);
+ }
+
+ NavigationTest.keepWaiting = true;
+ nav.loadURL(url);
+
+ // keep waiting until the previous load completes
+ while (NavigationTest.keepWaiting) {
+ Thread.currentThread().sleep(1000);
+ }
+
+
+
+ eventRegistration.removeDocumentLoadListener(listener);
+
listener = new DocumentLoadListenerImpl() {
public void doEndCheck() {
currentPage.selectAll();
@@ -282,13 +308,15 @@ public class NavigationTest extends WebclientTestCase {
eventRegistration.addDocumentLoadListener(listener);
- String url = "http://localhost:5243/HttpNavigationTest.txt";
+ url = "http://localhost:5243/HttpNavigationTest.txt";
Thread.currentThread().sleep(3000);
- nav.loadURL(url);
-
- // keep waiting until the previous load completes
+ NavigationTest.keepWaiting = true;
+
+ nav.loadURL(url);
+
+ // keep waiting until the previous load completes
while (NavigationTest.keepWaiting) {
Thread.currentThread().sleep(1000);
}
@@ -320,7 +348,6 @@ public class NavigationTest extends WebclientTestCase {
assertNotNull(canvas);
Frame frame = new Frame();
- frame.setUndecorated(true);
frame.setBounds(0, 0, 640, 480);
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);
@@ -381,7 +408,6 @@ public class NavigationTest extends WebclientTestCase {
assertNotNull(canvas);
Frame frame = new Frame();
- frame.setUndecorated(true);
frame.setBounds(0, 0, 640, 480);
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);