M dist/mcp-test/src/test/java/cardemo/CarDemoTest.java
- remove Robot from this class. Moved into MCP M dom/classes/org/mozilla/dom/DocumentImpl.java M dom/jni/org_mozilla_dom_DocumentImpl.cpp - implement getDocumentURI(). M dom/classes/org/mozilla/dom/util/DOMTreeDumper.java - added findElementWithName(). R webclient/classes_spec/org/mozilla/webclient/test/DOMTreeModel.java A dom/classes/org/mozilla/dom/util/DOMTreeModel.java R webclient/test/manual/src/classes/org/mozilla/webclient/test/DOMTreeNotifier.java A dom/classes/org/mozilla/dom/util/DOMTreeNotifier.java M webclient/classes_spec/org/mozilla/webclient/test/DOMAccessPanel.java M webclient/classes_spec/org/mozilla/webclient/test/DOMViewerFrame.java M webclient/test/manual/src/classes/org/mozilla/webclient/test/DOMViewerFrame.java - Move these over from test browser package M webclient/classes_spec/org/mozilla/mcp/MCP.java - added useful new public methods findElement clickElement blockingClickElement - absorbed functionality of Robot. R webclient/classes_spec/org/mozilla/webclient/impl/DOMTreeDumper.java R webclient/test/manual/src/classes/org/mozilla/webclient/test/DOMTreeDumper.java - For some reason, there were several copies of this file. M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java - Use newly implemented getDocumentURI() for logging. git-svn-id: svn://10.0.0.236/trunk@221413 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -21,8 +21,9 @@ package org.mozilla.webclient.test;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import org.mozilla.dom.util.DOMTreeNotifier;
|
||||
import org.mozilla.dom.util.DOMTreeDumper;
|
||||
import org.w3c.dom.*;
|
||||
import org.mozilla.dom.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.*; //idk
|
||||
import javax.swing.border.*;
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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 Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Denis Sharypov <sdv@sparc.spb.su>
|
||||
*
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.test;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class DOMTreeDumper {
|
||||
|
||||
private String prefix = "DOMTreeDumper";
|
||||
private boolean debug;
|
||||
private PrintStream ps;
|
||||
private boolean inA;
|
||||
private final String[] endTagForbiddenNames = {"AREA",
|
||||
"BASE",
|
||||
"BASEFONT",
|
||||
"BR",
|
||||
"COL",
|
||||
"FRAME",
|
||||
"HR",
|
||||
"IMG",
|
||||
"INPUT",
|
||||
"ISINDEX",
|
||||
"LINK",
|
||||
"META",
|
||||
"PARAM"};
|
||||
|
||||
DOMTreeDumper() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
DOMTreeDumper(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
private void dumpDocument(Document doc) {
|
||||
if (doc == null) return;
|
||||
Element element = doc.getDocumentElement();
|
||||
if (element == null) return;
|
||||
element.normalize();
|
||||
// DocumentType dt = doc.getDoctype();
|
||||
// dumpNode(dt);
|
||||
|
||||
dumpNode(element);
|
||||
ps.println();
|
||||
ps.flush();
|
||||
|
||||
element = null;
|
||||
doc = null;
|
||||
}
|
||||
|
||||
private void dumpNode(Node node) {
|
||||
dumpNode(node, false);
|
||||
}
|
||||
|
||||
private void dumpNode(Node node, boolean isMapNode) {
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int type = node.getNodeType();
|
||||
String name = node.getNodeName();
|
||||
String value = node.getNodeValue();
|
||||
|
||||
switch (type) {
|
||||
case Node.ELEMENT_NODE:
|
||||
if (name.equals("A")) inA = true;
|
||||
if (!(inA || name.equals("BR"))) {
|
||||
ps.println();
|
||||
}
|
||||
ps.print("<" + name);
|
||||
dumpAttributes(node);
|
||||
ps.print(">");
|
||||
dumpChildren(node);
|
||||
if (name.equals("A")) inA = false;
|
||||
if (!endTagForbidden(name)) {
|
||||
ps.print("</" + node.getNodeName() + ">");
|
||||
}
|
||||
break;
|
||||
case Node.ATTRIBUTE_NODE:
|
||||
ps.print(" " + name.toUpperCase() + "=\"" + value + "\"");
|
||||
break;
|
||||
case Node.TEXT_NODE:
|
||||
if (!node.getParentNode().getNodeName().equals("PRE")) {
|
||||
value = value.trim();
|
||||
}
|
||||
if (!value.equals("")) {
|
||||
if (!inA) {
|
||||
ps.println();
|
||||
}
|
||||
ps.print(canonicalize(value));
|
||||
}
|
||||
break;
|
||||
case Node.COMMENT_NODE:
|
||||
ps.print("\n<!--" + value + "-->");
|
||||
break;
|
||||
case Node.CDATA_SECTION_NODE:
|
||||
case Node.ENTITY_REFERENCE_NODE:
|
||||
case Node.ENTITY_NODE:
|
||||
case Node.PROCESSING_INSTRUCTION_NODE:
|
||||
case Node.DOCUMENT_NODE:
|
||||
case Node.DOCUMENT_TYPE_NODE:
|
||||
case Node.DOCUMENT_FRAGMENT_NODE:
|
||||
case Node.NOTATION_NODE:
|
||||
ps.println("\n<!-- NOT HANDLED: " + name +
|
||||
" value=" + value + " -->");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpAttributes(Node node) {
|
||||
NamedNodeMap map = node.getAttributes();
|
||||
if (map == null) return;
|
||||
int length = map.getLength();
|
||||
for (int i=0; i < length; i++) {
|
||||
Node item = map.item(i);
|
||||
dumpNode(item, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpChildren(Node node) {
|
||||
NodeList children = node.getChildNodes();
|
||||
int length = 0;
|
||||
boolean hasChildren = ((children != null) && ((length = children.getLength()) > 0));
|
||||
if (!hasChildren) {
|
||||
return;
|
||||
}
|
||||
for (int i=0; i < length; i++) {
|
||||
dumpNode(children.item(i), false);
|
||||
}
|
||||
if (!inA) {
|
||||
ps.println();
|
||||
}
|
||||
}
|
||||
|
||||
private String canonicalize(String str) {
|
||||
StringBuffer in = new StringBuffer(str);
|
||||
int length = in.length();
|
||||
StringBuffer out = new StringBuffer(length);
|
||||
char c;
|
||||
for (int i = 0; i < length; i++) {
|
||||
switch (c = in.charAt(i)) {
|
||||
case '&' :
|
||||
out.append("&");
|
||||
break;
|
||||
case '<':
|
||||
out.append("<");
|
||||
break;
|
||||
case '>':
|
||||
out.append(">");
|
||||
break;
|
||||
case '\u00A0':
|
||||
out.append(" ");
|
||||
break;
|
||||
default:
|
||||
out.append(c);
|
||||
}
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
private boolean endTagForbidden(String name) {
|
||||
for (int i = 0; i < endTagForbiddenNames.length; i++) {
|
||||
if (name.equals(endTagForbiddenNames[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void dumpToFile(String fileName, Document doc) {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(fileName);
|
||||
ps = new PrintStream(new BufferedOutputStream(fos, 1024));
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
dbg("dumping to " + fileName);
|
||||
dumpDocument(doc);
|
||||
dbg("finished dumping...");
|
||||
}
|
||||
|
||||
public String dump(Document doc) {
|
||||
ByteArrayOutputStream baos = null;
|
||||
baos = new ByteArrayOutputStream(1024);
|
||||
ps = new PrintStream(baos);
|
||||
|
||||
dbg("dumping to String");
|
||||
dumpDocument(doc);
|
||||
dbg("finished dumping...");
|
||||
return baos.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void dbg(String str) {
|
||||
if (debug) {
|
||||
System.out.println(prefix + ": " + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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 Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Igor Kushnirskiy <idk@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.test;
|
||||
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import java.util.Vector;
|
||||
|
||||
class DOMTreeModel implements TreeModel, DOMTreeNotifier {
|
||||
private Node rootNode;
|
||||
private Vector treeModelListeners = new Vector();
|
||||
|
||||
public DOMTreeModel(Node node) {
|
||||
rootNode = node;
|
||||
}
|
||||
public void addTreeModelListener(TreeModelListener l) {
|
||||
// use addElement instead of add for jdk1.1.x compatibility.
|
||||
treeModelListeners.addElement(l);
|
||||
}
|
||||
public void removeTreeModelListener(TreeModelListener l) {
|
||||
treeModelListeners.removeElement(l);
|
||||
}
|
||||
public Object getChild(Object parent, int index) {
|
||||
return ((Node)parent).getChildNodes().item(index);
|
||||
}
|
||||
public int getChildCount(Object parent) {
|
||||
return ((Node)parent).getChildNodes().getLength();
|
||||
}
|
||||
public int getIndexOfChild(Object parent, Object child) {
|
||||
NodeList childNodes = ((Node)parent).getChildNodes();
|
||||
int res = -1;
|
||||
int length = childNodes.getLength();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (childNodes.item(i) == child) {
|
||||
res = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
public Object getRoot() {
|
||||
return rootNode;
|
||||
}
|
||||
public boolean isLeaf(Object node) {
|
||||
return getChildCount(node) == 0;
|
||||
}
|
||||
|
||||
public void valueForPathChanged(TreePath path, Object newValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Invoked after a node (or a set of siblings) has changed in some way.
|
||||
*/
|
||||
public void treeNodesChanged(TreeModelEvent e) {
|
||||
for (int i = 0; i < treeModelListeners.size() ; i++) {
|
||||
((TreeModelListener)treeModelListeners.elementAt(i)).
|
||||
treeNodesChanged(e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Invoked after nodes have been inserted into the tree.
|
||||
*/
|
||||
public void treeNodesInserted(TreeModelEvent e) {
|
||||
for (int i = 0; i < treeModelListeners.size(); i++) {
|
||||
((TreeModelListener)treeModelListeners.elementAt(i)).
|
||||
treeNodesInserted(e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Invoked after nodes have been removed from the tree.
|
||||
*/
|
||||
public void treeNodesRemoved(TreeModelEvent e) {
|
||||
for (int i = 0; i < treeModelListeners.size(); i++) {
|
||||
((TreeModelListener)treeModelListeners.elementAt(i)).
|
||||
treeNodesRemoved(e);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Invoked after the tree has drastically changed structure from a given node down.
|
||||
*/
|
||||
public void treeStructureChanged(TreeModelEvent e) {
|
||||
for (int i = 0; i < treeModelListeners.size(); i++) {
|
||||
((TreeModelListener)treeModelListeners.elementAt(i)).
|
||||
treeStructureChanged(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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 Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.test;
|
||||
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
|
||||
interface DOMTreeNotifier {
|
||||
/*
|
||||
* Invoked after a node (or a set of siblings) has changed in some way.
|
||||
*/
|
||||
public void treeNodesChanged(TreeModelEvent e);
|
||||
|
||||
/*
|
||||
* Invoked after nodes have been inserted into the tree.
|
||||
*/
|
||||
public void treeNodesInserted(TreeModelEvent e);
|
||||
|
||||
/*
|
||||
* Invoked after nodes have been removed from the tree.
|
||||
*/
|
||||
public void treeNodesRemoved(TreeModelEvent e);
|
||||
/*
|
||||
* Invoked after the tree has drastically changed structure from a given node down.
|
||||
*/
|
||||
public void treeStructureChanged(TreeModelEvent e);
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
package org.mozilla.webclient.test;
|
||||
|
||||
import org.mozilla.dom.util.DOMTreeModel;
|
||||
import org.mozilla.util.Assert;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
@@ -57,7 +58,7 @@ import java.util.Stack;
|
||||
* A dom viewer Frame
|
||||
|
||||
*
|
||||
* @version $Id: DOMViewerFrame.java,v 1.1 2005-04-17 20:19:46 edburns%acm.org Exp $
|
||||
* @version $Id: DOMViewerFrame.java,v 1.2 2007-03-06 22:03:43 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlFactory
|
||||
|
||||
|
||||
Reference in New Issue
Block a user