andreasgal / dom.js Goto Github PK
View Code? Open in Web Editor NEWSelf-hosted JavaScript implementation of a WebIDL-compliant HTML5 DOM.
License: BSD 2-Clause "Simplified" License
Self-hosted JavaScript implementation of a WebIDL-compliant HTML5 DOM.
License: BSD 2-Clause "Simplified" License
jQuery expects Document.ownerDocument to be null, and both Firefox and Chrome return null. dom.js depends on Document.ownerDocument being itself, and has a comment that says DOMCore requires it:
// DOMCore says that documents are always associated with themselves.
this.ownerDocument = this;
I implemented a private name patch for FF, that works roughly like this:
var name = Name();
obj[name] = foo;
These names are not enumerated and there is no way to get to them without having access to the name instance. This might be more efficient than weak maps.
It can't handle unnamed getter/settter/deleter/creator methods.
Hi,
(I am sorry if this is not the right forum, if not, please direct me to one):
I am new to proxies and came across this project. A dumb question, using Dom.js, can I intercept all calls made to the window and/or document object by the Web app? If yes, can I run this in a Firefox extension and still intercept all calls? Or if I am running in a Firefox extension, is there a easier way to do that?
Thanks in advance,
Sunil
Hey, guys. I'm wondering if the dom.js project can provide some contact information (or better yet, a newsgroup) for discussions about the project. I've had some thoughts, but I need a forum to express them in (and a blog post on Planet Mozilla is not appropriate).
https://github.com/tmpvar/jsdom
which seems to be rather similar in scope and has great DOM test suite compliance.
If I do insertBefore() to move a node before one of its own siblings, the internal insert() method doesn't do the right thing because the index changes after the node is removed, and then it gets inserted at the wrong spot. This is causing a test falure in tests/jsdom/core.js: hc_nodeinsertbeforenewchildexists...
There are several bugs found & fixed in domino which appear to still be present in dom.js
For example:
fgnass/domino#9
fgnass/domino#14
fgnass/domino#16
fgnass/domino#20
fgnass/domino#21
fgnass/domino#29
fgnass/domino#31
fgnass/domino@8e52432
fgnass/domino#32
host-4-64:mozilla-central donovan$ hg diff
diff -r a690d8fbcc48 js/src/shell/js.cpp
--- a/js/src/shell/js.cpp Mon Aug 08 17:21:29 2011 -0400
+++ b/js/src/shell/js.cpp Tue Aug 09 10:02:38 2011 -0700
@@ -5678,9 +5678,25 @@
return true;
}
+
+JSTrapStatus
+CoverageHook(JSContext *cx, JSScript *script,
+ jsbytecode *pc, jsval *rval, void *closure)
+{
+ fprintf((FILE *)closure, "%s ---------- %d\n",
+ JS_GetScriptFilename(cx, script),
+ JS_PCToLineNumber(cx, script, pc));
+ fflush((FILE *)closure);
+
+ return JSTRAP_CONTINUE;
+}
+
+
static int
ProcessArgs(JSContext *cx, JSObject *obj, OptionParser *op)
{
+ FILE * coverage_file = NULL;
+
if (op->getBoolOption('a'))
JS_ToggleOptions(cx, JSOPTION_METHODJIT_ALWAYS);
@@ -5689,6 +5705,15 @@
JS_ToggleOptions(cx, JSOPTION_METHODJIT);
}
+ if (op->getBoolOption('c')) {
+ char filename[256];
+ // We open this file but never close it. Since we use it until the process dies,
+ // we don't really need to close it. Messy, but the code to close the file
+ // properly was messier.
+ coverage_file = fopen("coverage.out", "a");
+ JS_SetInterrupt(cx->runtime, &CoverageHook, coverage_file);
+ }
+
#ifdef JS_GC_ZEAL
if (const char *zeal = op->getStringOption('Z'))
ParseZealArg(cx, zeal);
@@ -5957,6 +5982,7 @@
if (!op.addMultiStringOption('f', "file", "PATH", "File path to run")
|| !op.addMultiStringOption('e', "execute", "CODE", "Inline code to run")
|| !op.addBoolOption('i', "shell", "Enter prompt after running code")
+ || !op.addBoolOption('c', "coverage", "Write filenames and line numbers of executed code to coverage.out")
|| !op.addBoolOption('m', "methodjit", "Enable the JaegerMonkey method JIT")
|| !op.addBoolOption('j', "tracejit", "Enable the JaegerMonkey trace JIT")
|| !op.addBoolOption('p', "profiling", "Enable runtime profiling select JIT mode")
diff -r a690d8fbcc48 js/src/tests/jstests.py
--- a/js/src/tests/jstests.py Mon Aug 08 17:21:29 2011 -0400
+++ b/js/src/tests/jstests.py Tue Aug 09 10:02:38 2011 -0700
@@ -241,6 +241,8 @@
help='extra args to pass to valgrind')
op.add_option('-c', '--check-manifest', dest='check_manifest', action='store_true',
help='check for test files not listed in the manifest')
+ op.add_option('-C', '--coverage', dest='coverage', action='store_true',
+ help='gather data on which lines were executed while running tests.')
op.add_option('--failure-file', dest='failure_file',
help='write tests that have not passed to the given file')
op.add_option('--run-slow-tests', dest='run_slow_tests', action='store_true',
@@ -276,6 +278,10 @@
else:
debugger_prefix = []
+ if OPTIONS.coverage:
+ ## If gathering coverage tell spidermonkey to record coverage
+ OPTIONS.shell_args += ' -c'
+
TestTask.set_js_cmd_prefix(JS, OPTIONS.shell_args.split(), debugger_prefix)
output_file = sys.stdout
Hi
I have compiled dom.js and now want to use it in node.js.
How to get started? When I run the generated dom.js in node I get a few errors (const in strict mode, and then Function.prototype not defined...).
Thanks
TC39 decided to leave 'this' bound to the handler and pass the receiver as an extra 1st argument to all proxy handler traps that walk the proto chain. Switch to that new syntax (patches for FF are under review).
Hi,
when I try to evaluate dom.js using the ScriptEngine in Java, it returns the following exception:
Property "nodeValue" already defined in this object literal. (#1131) in at line number 1131
I was hoping to use dom.js in conjunction with jQuery to do dom manipulation of HTML markup.
Add the .md so that markdown actually works.
it would be helpful to have a one or two examples how to use the dom.js in practice. sure there are the test but it wouldn't hurt to have some examples in the README.md
I just wanted someplace to stick this patch until readyState is really implemented.
--- a/src/impl/Document.js
+++ b/src/impl/Document.js
@@ -418,7 +418,7 @@ defineLazyProperty(impl, "Document", function() {
referrer: attribute(nyi),
cookie: attribute(nyi, nyi),
lastModified: attribute(nyi),
readyState: attribute(nyi),
readyState: attribute(function() { return "complete" }),
title: attribute(nyi, nyi),
dir: attribute(nyi, nyi),
// Return the first <body> child of the document element.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.