Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'level2' of git://github.com/tmpvar/jsdom

  • Loading branch information...
commit 4186e5de85913a17e5dfc510df23db8eb642cc07 2 parents e7044b8 + f637c41
@aredridel aredridel authored
View
4 example/browser/browser.js
@@ -1,8 +1,8 @@
var sys = require('sys');
-var dom = require('../../lib/level1/core').dom.level1.core;
-var browser = require('../../lib/browser/index').windowAugmentation(dom);
+var dom = require('../../lib/jsdom/level1/core').dom.level1.core;
+var browser = require('../../lib/jsdom/browser/index').windowAugmentation(dom);
var document = browser.document;
var window = browser.window;
View
25 example/jquery/run.js
@@ -1,22 +1,17 @@
-var sys = require("sys"), fs = require("fs");
+var sys = require("sys"), fs = require("fs");
-var dom = require("../../lib/level1/core").dom.level1.core;
-var window = require("../../lib/browser").windowAugmentation(dom).window;
-var document = window.document;
-var location = window.location;
-var navigator = window.navigator;
+var dom = require("../../lib/jsdom/level1/core").dom.level1.core;
+var window = require("../../lib/jsdom/browser").windowAugmentation(dom).window;
+var Script = process.binding('evals').Script;
fs.readFile(__dirname + "/jquery.js", function(err, data) {
-
+
try {
- eval(data.toString());
- } catch (e) {
- sys.puts(sys.inspect(e.stack, true));
+ Script.runInNewContext(data.toString(), {window: window, location: window.location, navigator: window.navigator});
+ } catch(e){
+ sys.puts(sys.inspect(e));
}
-
- // Doing this requires you setup a parser, easiest way is to put node-htmlparser.js into
- // ~/.node_libraries/
-
- window.jQuery(document.body).append("<div class='testing'>Hello World, It works!</div>");
+ window.jQuery('body').append("<div class='testing'>Hello World, It works!</div>");
sys.puts(window.jQuery(".testing").text());
+
});
View
2  example/node-xml/run.js
@@ -1,5 +1,5 @@
var sys = require('sys');
-process.mixin(GLOBAL, require("../../lib/level1/core").dom.level1.core);
+process.mixin(GLOBAL, require("../../lib/jsdom/level1/core").dom.level1.core);
// git clone git://github.com/robrighter/node-xml.git into ~/.node_libraries
var xml = require("node-xml/lib/node-xml");
View
34 example/pure/run.js
@@ -1,5 +1,5 @@
-var browser = require("../../lib/browser");
-var dom = new browser.browserAugmentation(require("../../lib/level1/core").dom.level1.core);
+var browser = require("../../lib/jsdom/browser");
+var dom = new browser.browserAugmentation(require("../../lib/jsdom/level1/core").dom.level1.core);
var sax = require("./sax");
var sys = require("sys");
@@ -63,21 +63,21 @@ dom.Element.prototype.__defineSetter__('innerHTML', function(html) {
var doc = new dom.Document("html");
-var implementation = new dom.DOMImplementation(doc, {
- "HTML" : "1.0",
- "DisableLiveLists" : "1.0"
-});
-
-var notations = new dom.NotationNodeMap(
- doc,
- doc.createNotationNode("notation1","notation1File", null),
- doc.createNotationNode("notation2",null, "notation2File")
-);
-
-var entities = new dom.EntityNodeMap(doc);
-
-var doctype = new dom.DocumentType(doc, "html", entities, notations);
-doc.doctype = doctype;
+var implementation = new dom.DOMImplementation(doc, {
+ "HTML" : "1.0",
+ "DisableLiveLists" : "1.0"
+});
+
+var notations = new dom.NotationNodeMap(
+ doc,
+ doc.createNotationNode("notation1","notation1File", null),
+ doc.createNotationNode("notation2",null, "notation2File")
+);
+
+var entities = new dom.EntityNodeMap(doc);
+
+var doctype = new dom.DocumentType(doc, "html", entities, notations);
+doc.doctype = doctype;
doc.implementation = implementation;
doc.innerHTML = '<html><head></head><body><div class="who"></div></body></html>';
View
4 example/sizzle/run.js
@@ -1,5 +1,5 @@
-var browser = require("../../lib/browser");
-var dom = browser.browserAugmentation(require("../../lib/level1/core").dom.level1.core);
+var browser = require("../../lib/jsdom/browser");
+var dom = browser.browserAugmentation(require("../../lib/jsdom/level1/core").dom.level1.core);
var sys = require("sys");
View
449 lib/jsdom/level2/core.js
@@ -1,14 +1,14 @@
var core = require("../level1/core").dom.level1.core;
-core.INVALID_STATE_ERR = 11;
-core.SYNTAX_ERR = 12
-core.INVALID_MODIFICATION_ERR = 13;
-core.NAMESPACE_ERR = 14;
-core.INVALID_ACCESS_ERR = 15;
+var INVALID_STATE_ERR = core.INVALID_STATE_ERR = 11;
+var SYNTAX_ERR = core.SYNTAX_ERR = 12
+var INVALID_MODIFICATION_ERR = core.INVALID_MODIFICATION_ERR = 13;
+var NAMESPACE_ERR = core.NAMESPACE_ERR = 14;
+var INVALID_ACCESS_ERR = core.INVALID_ACCESS_ERR = 15;
core.DOMImplementation.prototype.createDocumentType = function(/* String */ qualifiedName,
- /* String */ publicId,
- /* String */ systemId)
+ /* String */ publicId,
+ /* String */ systemId)
{
var doctype = new core.DocumentType(this._ownerDocument, qualifiedName);
doctype.publicId = publicId ? publicId : '';
@@ -65,321 +65,148 @@ core.Element.prototype.getElementsByTagNameNS = function(/* String */ namespaceU
}
};
-/*
-// File: dom.idl
-#ifndef _DOM_IDL_
-#define _DOM_IDL_
+core.Node.prototype.__defineGetter__("ownerDocument", function() {
+
+});
+
+core.Node.prototype.isSupported = function(/* string */ feature, /* string */ version) {
+
+
+};
+
+core.Node.prototype.__defineGetter__("namespaceURI", function() {
+
+});
+
+core.Node.prototype.__defineGetter__("prefix", function() {
+
+});
+
+core.Node.prototype.__defineSetter__("prefix", function() {
+ throw new core.DOMException();
+});
-#pragma prefix "w3c.org"
-module dom
+core.Node.prototype.__defineGetter__("localName", function() {
+
+});
+
+/* return boolean */
+core.Node.prototype.hasAttributes = function() {
+
+};
+
+
+core.NamedNodeMap.prototype.getNamedItemNS = function(/* string */ namespaceURI,
+ /* string */ localName)
{
- valuetype DOMString sequence<unsigned short>;
-
- typedef unsigned long long DOMTimeStamp;
-
- interface DocumentType;
- interface Document;
- interface NodeList;
- interface NamedNodeMap;
- interface Element;
-
- exception DOMException {
- unsigned short code;
- };
- // ExceptionCode
- const unsigned short INDEX_SIZE_ERR = 1;
- const unsigned short DOMSTRING_SIZE_ERR = 2;
- const unsigned short HIERARCHY_REQUEST_ERR = 3;
- const unsigned short WRONG_DOCUMENT_ERR = 4;
- const unsigned short INVALID_CHARACTER_ERR = 5;
- const unsigned short NO_DATA_ALLOWED_ERR = 6;
- const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
- const unsigned short NOT_FOUND_ERR = 8;
- const unsigned short NOT_SUPPORTED_ERR = 9;
- const unsigned short INUSE_ATTRIBUTE_ERR = 10;
- // Introduced in DOM Level 2:
- const unsigned short INVALID_STATE_ERR = 11;
- // Introduced in DOM Level 2:
- const unsigned short SYNTAX_ERR = 12;
- // Introduced in DOM Level 2:
- const unsigned short INVALID_MODIFICATION_ERR = 13;
- // Introduced in DOM Level 2:
- const unsigned short NAMESPACE_ERR = 14;
- // Introduced in DOM Level 2:
- const unsigned short INVALID_ACCESS_ERR = 15;
-
-
- interface DOMImplementation {
- boolean hasFeature(in DOMString feature,
- in DOMString version);
- // Introduced in DOM Level 2:
- DocumentType createDocumentType(in DOMString qualifiedName,
- in DOMString publicId,
- in DOMString systemId)
- raises(DOMException);
- // Introduced in DOM Level 2:
- Document createDocument(in DOMString namespaceURI,
- in DOMString qualifiedName,
- in DocumentType doctype)
- raises(DOMException);
- };
-
- interface Node {
-
- // NodeType
- const unsigned short ELEMENT_NODE = 1;
- const unsigned short ATTRIBUTE_NODE = 2;
- const unsigned short TEXT_NODE = 3;
- const unsigned short CDATA_SECTION_NODE = 4;
- const unsigned short ENTITY_REFERENCE_NODE = 5;
- const unsigned short ENTITY_NODE = 6;
- const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
- const unsigned short COMMENT_NODE = 8;
- const unsigned short DOCUMENT_NODE = 9;
- const unsigned short DOCUMENT_TYPE_NODE = 10;
- const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
- const unsigned short NOTATION_NODE = 12;
-
- readonly attribute DOMString nodeName;
- attribute DOMString nodeValue;
- // raises(DOMException) on setting
- // raises(DOMException) on retrieval
-
- readonly attribute unsigned short nodeType;
- readonly attribute Node parentNode;
- readonly attribute NodeList childNodes;
- readonly attribute Node firstChild;
- readonly attribute Node lastChild;
- readonly attribute Node previousSibling;
- readonly attribute Node nextSibling;
- readonly attribute NamedNodeMap attributes;
- // Modified in DOM Level 2:
- readonly attribute Document ownerDocument;
- Node insertBefore(in Node newChild,
- in Node refChild)
- raises(DOMException);
- Node replaceChild(in Node newChild,
- in Node oldChild)
- raises(DOMException);
- Node removeChild(in Node oldChild)
- raises(DOMException);
- Node appendChild(in Node newChild)
- raises(DOMException);
- boolean hasChildNodes();
- Node cloneNode(in boolean deep);
- // Modified in DOM Level 2:
- void normalize();
- // Introduced in DOM Level 2:
- boolean isSupported(in DOMString feature,
- in DOMString version);
- // Introduced in DOM Level 2:
- readonly attribute DOMString namespaceURI;
- // Introduced in DOM Level 2:
- attribute DOMString prefix;
- // raises(DOMException) on setting
-
- // Introduced in DOM Level 2:
- readonly attribute DOMString localName;
- // Introduced in DOM Level 2:
- boolean hasAttributes();
- };
-
- interface NodeList {
- Node item(in unsigned long index);
- readonly attribute unsigned long length;
- };
-
- interface NamedNodeMap {
- Node getNamedItem(in DOMString name);
- Node setNamedItem(in Node arg)
- raises(DOMException);
- Node removeNamedItem(in DOMString name)
- raises(DOMException);
- Node item(in unsigned long index);
- readonly attribute unsigned long length;
- // Introduced in DOM Level 2:
- Node getNamedItemNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- Node setNamedItemNS(in Node arg)
- raises(DOMException);
- // Introduced in DOM Level 2:
- Node removeNamedItemNS(in DOMString namespaceURI,
- in DOMString localName)
- raises(DOMException);
- };
-
- interface CharacterData : Node {
- attribute DOMString data;
- // raises(DOMException) on setting
- // raises(DOMException) on retrieval
-
- readonly attribute unsigned long length;
- DOMString substringData(in unsigned long offset,
- in unsigned long count)
- raises(DOMException);
- void appendData(in DOMString arg)
- raises(DOMException);
- void insertData(in unsigned long offset,
- in DOMString arg)
- raises(DOMException);
- void deleteData(in unsigned long offset,
- in unsigned long count)
- raises(DOMException);
- void replaceData(in unsigned long offset,
- in unsigned long count,
- in DOMString arg)
- raises(DOMException);
- };
-
- interface Attr : Node {
- readonly attribute DOMString name;
- readonly attribute boolean specified;
- attribute DOMString value;
- // raises(DOMException) on setting
-
- // Introduced in DOM Level 2:
- readonly attribute Element ownerElement;
- };
-
- interface Element : Node {
- readonly attribute DOMString tagName;
- DOMString getAttribute(in DOMString name);
- void setAttribute(in DOMString name,
- in DOMString value)
- raises(DOMException);
- void removeAttribute(in DOMString name)
- raises(DOMException);
- Attr getAttributeNode(in DOMString name);
- Attr setAttributeNode(in Attr newAttr)
- raises(DOMException);
- Attr removeAttributeNode(in Attr oldAttr)
- raises(DOMException);
- NodeList getElementsByTagName(in DOMString name);
- // Introduced in DOM Level 2:
- DOMString getAttributeNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- void setAttributeNS(in DOMString namespaceURI,
- in DOMString qualifiedName,
- in DOMString value)
- raises(DOMException);
- // Introduced in DOM Level 2:
- void removeAttributeNS(in DOMString namespaceURI,
- in DOMString localName)
- raises(DOMException);
- // Introduced in DOM Level 2:
- Attr getAttributeNodeNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- Attr setAttributeNodeNS(in Attr newAttr)
- raises(DOMException);
- // Introduced in DOM Level 2:
- NodeList getElementsByTagNameNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- boolean hasAttribute(in DOMString name);
- // Introduced in DOM Level 2:
- boolean hasAttributeNS(in DOMString namespaceURI,
- in DOMString localName);
- };
-
- interface Text : CharacterData {
- Text splitText(in unsigned long offset)
- raises(DOMException);
- };
-
- interface Comment : CharacterData {
- };
-
- interface CDATASection : Text {
- };
-
- interface DocumentType : Node {
- readonly attribute DOMString name;
- readonly attribute NamedNodeMap entities;
- readonly attribute NamedNodeMap notations;
- // Introduced in DOM Level 2:
- readonly attribute DOMString publicId;
- // Introduced in DOM Level 2:
- readonly attribute DOMString systemId;
- // Introduced in DOM Level 2:
- readonly attribute DOMString internalSubset;
- };
-
- interface Notation : Node {
- readonly attribute DOMString publicId;
- readonly attribute DOMString systemId;
- };
-
- interface Entity : Node {
- readonly attribute DOMString publicId;
- readonly attribute DOMString systemId;
- readonly attribute DOMString notationName;
- };
-
- interface EntityReference : Node {
- };
-
- interface ProcessingInstruction : Node {
- readonly attribute DOMString target;
- attribute DOMString data;
- // raises(DOMException) on setting
-
- };
-
- interface DocumentFragment : Node {
- };
-
- interface Document : Node {
- readonly attribute DocumentType doctype;
- readonly attribute DOMImplementation implementation;
- readonly attribute Element documentElement;
- Element createElement(in DOMString tagName)
- raises(DOMException);
- DocumentFragment createDocumentFragment();
- Text createTextNode(in DOMString data);
- Comment createComment(in DOMString data);
- CDATASection createCDATASection(in DOMString data)
- raises(DOMException);
- ProcessingInstruction createProcessingInstruction(in DOMString target,
- in DOMString data)
- raises(DOMException);
- Attr createAttribute(in DOMString name)
- raises(DOMException);
- EntityReference createEntityReference(in DOMString name)
- raises(DOMException);
- NodeList getElementsByTagName(in DOMString tagname);
- // Introduced in DOM Level 2:
- Node importNode(in Node importedNode,
- in boolean deep)
- raises(DOMException);
- // Introduced in DOM Level 2:
- Element createElementNS(in DOMString namespaceURI,
- in DOMString qualifiedName)
- raises(DOMException);
- // Introduced in DOM Level 2:
- Attr createAttributeNS(in DOMString namespaceURI,
- in DOMString qualifiedName)
- raises(DOMException);
- // Introduced in DOM Level 2:
- NodeList getElementsByTagNameNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- Element getElementById(in DOMString elementId);
- };
};
-#endif // _DOM_IDL_
+core.NamedNodeMap.prototype.setNamedItemNS = function(/* Node */ arg)
+{
+};
-*/
+core.NamedNodeMap.prototype.removeNamedItemNS = function(/*string */ namespaceURI,
+ /* string */ localName)
+{
+};
+
+core.Attr.prototype.__defineGetter__("ownerElement", function() {
+
+});
+
+
+core.Element.prototype.getAttributeNS = function(/* string */ namespaceURI,
+ /* string */ localName)
+{
+
+};
+
+core.Element.prototype.setAttributeNS = function(/* string */ namespaceURI,
+ /* string */ qualifiedName,
+ /* string */ value)
+{
+};
+
+core.Element.prototype.removeAttributeNS = function(/* string */ namespaceURI,
+ /* string */ localName)
+{
+
+};
+
+core.Element.prototype.getAttributeNodeNS = function(/* string */ namespaceURI,
+ /* string */ localName)
+{
+
+};
+core.Element.prototype.setAttributeNodeNS = function(/* Attr */ newAttr)
+{
+
+};
+
+core.Element.prototype.getElementsByTagNameNS = function(/* string */ namespaceURI,
+ /* string */ localName)
+{
+
+};
+
+core.Element.prototype.hasAttribute = function(/* string */name)
+{
+
+};
+
+core.Element.prototype.hasAttributeNS = function(/* string */namespaceURI,
+ /* string */localName)
+{
+
+};
+
+core.DocumentType.prototype.__defineGetter__("publicId", function() {
+ return this._publicId || "";
+});
+
+core.DocumentType.prototype.__defineGetter__("systemId", function() {
+ return this._systemId || "";
+});
+
+core.DocumentType.prototype.__defineGetter__("internalSubset", function() {
+ return this._internalSubset || "";
+});
+
+core.Document.prototype.importNode = function(/* Node */ importedNode,
+ /* bool */ deep)
+{
+
+};
+
+core.Document.prototype.createElementNS = function(/* string */ namespaceURI,
+ /* string */ qualifiedName)
+{
+
+};
+
+core.Document.prototype.createAttributeNS = function(/* string */ namespaceURI,
+ /* string */ qualifiedName)
+{
+
+};
+
+core.Document.prototype.getElementsByTagNameNS = function(/* string */ namespaceURI,
+ /* string */ localName)
+{
+
+};
+
+core.Document.prototype.getElementById = function(/* string */ elementId)
+{
+
+};
-exports.dom =
+exports.dom =
{
level2 : {
core : core
View
21 test/runner.js
@@ -20,7 +20,7 @@ var mixin = function(target) {
return target;
};
-mixin(global, require("../lib/level1/core").dom.level1.core);
+mixin(global, require(__dirname + "/../lib/jsdom/level1/core").dom.level1.core);
mixin(global, require(__dirname + "/mjsunit"));
mixin(global, require("./DOMTestCase"));
@@ -32,7 +32,10 @@ global.builder = {
};
global.load = function(docRef, doc, name) {
- return require("./" + global.builder.testDirectory + "/files/" + name + "." + global.builder.type)[name]();
+ return require(__dirname + "/" +
+ global.builder.testDirectory +
+ "/files/" + name + "." +
+ global.builder.type)[name]();
};
global.checkInitialization = function() {
@@ -73,7 +76,7 @@ var suites = {
}
},
"level2/core" : { cases: require("./level2/core").tests, setUp : function() {
- mixin(global, require("../lib/level2/core").dom.level2.core);
+ mixin(global, require("../lib/jsdom/level2/core").dom.level2.core);
global.builder.contentType = "text/xml";
global.builder.type = "xml";
global.builder.testDirectory = "level2/core";
@@ -81,9 +84,8 @@ var suites = {
}
},
"browser" : { cases: require("./browser").tests, setUp : function() {
- global.dom = require(__dirname + "/../lib/level1/core").dom.level1.core;
- global.browser = require(__dirname + "/../lib/browser").browserAugmentation(dom);
-
+ global.dom = require(__dirname + "/../lib/jsdom/level1/core").dom.level1.core;
+ global.browser = require(__dirname + "/../lib/jsdom/browser").browserAugmentation(dom);
global.builder.contentType = "text/html";
global.builder.type = "html";
@@ -91,9 +93,8 @@ var suites = {
}
},
"window" : { cases: require("./window").tests, setUp : function() {
- global.dom = require(__dirname + "/../lib/level1/core").dom.level1.core;
- global.window = require(__dirname + "/../lib/browser").windowAugmentation(dom);
-
+ global.dom = require(__dirname + "/../lib/jsdom/level1/core").dom.level1.core;
+ global.window = require(__dirname + "/../lib/jsdom/browser").windowAugmentation(dom);
global.builder.contentType = "text/html";
global.builder.type = "html";
@@ -124,6 +125,6 @@ var suites = {
*/
};
-require.paths.unshift(__dirname + "/../../.node_libraries");
+
require("mjsunit.runner/lib/runner").run(suites);
Please sign in to comment.
Something went wrong with that request. Please try again.