summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-08-01 21:32:01 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-08-01 21:32:01 +0100
commitffa3e6bf3565143c3bda79a0198fe47af5c00276 (patch)
tree1fc1fa9a4a456b5ca56963652e7c7984e79a3d13
parent30bc438ab00483ce3be7fc994a2739dfbf486c5a (diff)
parent6bbae1f2284a7d52daf96ad30e1519600ae5493b (diff)
downloadnetsurf-ffa3e6bf3565143c3bda79a0198fe47af5c00276.tar.gz
netsurf-ffa3e6bf3565143c3bda79a0198fe47af5c00276.tar.bz2
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
-rw-r--r--javascript/jsapi/document.c81
-rw-r--r--test/js/index.html2
-rw-r--r--test/js/inline-innerhtml.html15
-rw-r--r--test/js/sync-script-css.html2
-rw-r--r--test/js/sync-script-err.html12
5 files changed, 111 insertions, 1 deletions
diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c
index bb5019c4b..c54d2f6a5 100644
--- a/javascript/jsapi/document.c
+++ b/javascript/jsapi/document.c
@@ -24,6 +24,80 @@
#include "render/html_internal.h"
#include "utils/log.h"
+/* IDL from http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html
+
+
+interface Document : Node {
+ // Modified in DOM Level 3:
+ 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);
+ // Introduced in DOM Level 3:
+ readonly attribute DOMString inputEncoding;
+ // Introduced in DOM Level 3:
+ readonly attribute DOMString xmlEncoding;
+ // Introduced in DOM Level 3:
+ attribute boolean xmlStandalone;
+ // raises(DOMException) on setting
+
+ // Introduced in DOM Level 3:
+ attribute DOMString xmlVersion;
+ // raises(DOMException) on setting
+
+ // Introduced in DOM Level 3:
+ attribute boolean strictErrorChecking;
+ // Introduced in DOM Level 3:
+ attribute DOMString documentURI;
+ // Introduced in DOM Level 3:
+ Node adoptNode(in Node source)
+ raises(DOMException);
+ // Introduced in DOM Level 3:
+ readonly attribute DOMConfiguration domConfig;
+ // Introduced in DOM Level 3:
+ void normalizeDocument();
+ // Introduced in DOM Level 3:
+ Node renameNode(in Node n,
+ in DOMString namespaceURI,
+ in DOMString qualifiedName)
+ raises(DOMException);
+};
+
+
+ */
+
+
static JSClass jsclass_document =
{
"document",
@@ -39,6 +113,12 @@ static JSClass jsclass_document =
JSCLASS_NO_OPTIONAL_MEMBERS
};
+static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp)
+{
+ JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
+
+ return JS_TRUE;
+}
static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
{
@@ -67,6 +147,7 @@ static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
static JSFunctionSpec jsfunctions_document[] = {
JSAPI_FS(write, 1, 0),
+ JSAPI_FS(getElementById, 1, 0),
JSAPI_FS_END
};
diff --git a/test/js/index.html b/test/js/index.html
index f7ce2f37a..6bb010c3b 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -10,7 +10,9 @@
<li><a href="inline-doc-write-simple.html">Simple docuemnt write</a></li>
<li><a href="inline-doc-write.html">Script within inline script</a></li>
<li><a href="sync-script.html">External syncronous script</a></li>
+<li><a href="sync-script-err.html">External syncronous script with missing js file</a></li>
<li><a href="sync-script-css.html">External syncronous script (with css)</a></li>
+<li><a href="inline-innerhtml.html">Inline script innerHtml test</a></li>
</ul>
diff --git a/test/js/inline-innerhtml.html b/test/js/inline-innerhtml.html
new file mode 100644
index 000000000..6bfd6608b
--- /dev/null
+++ b/test/js/inline-innerhtml.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>Inline Script innerHTML Test</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>Inline Script innerHTML Test</h1>
+<p>Before</p>
+<p id="demo">some text you should never see</p>
+<script type="text/javascript">
+document.getElementById("demo").innerHTML="text inserted by script";
+</script>
+<p>Afterwards</p>
+</body>
+</html>
diff --git a/test/js/sync-script-css.html b/test/js/sync-script-css.html
index 55840f297..ecba5be0f 100644
--- a/test/js/sync-script-css.html
+++ b/test/js/sync-script-css.html
@@ -4,7 +4,7 @@
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Sync script Test (css0</h1>
+<h1>Sync script Test (css)</h1>
<p>Before</p>
<script src="tst.js"></script>
<p>Afterwards</p>
diff --git a/test/js/sync-script-err.html b/test/js/sync-script-err.html
new file mode 100644
index 000000000..68e77baea
--- /dev/null
+++ b/test/js/sync-script-err.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>Sync script Test with bad src</title>
+</head>
+<body>
+<h1>Sync script Test with bad src</h1>
+<p>Before</p>
+<script src="notthere.js"></script>
+<script src="tst.js"></script>
+<p>Afterwards</p>
+</body>
+</html>