diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2012-08-01 19:25:45 +0100 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2012-08-01 19:25:45 +0100 |
commit | 6bbae1f2284a7d52daf96ad30e1519600ae5493b (patch) | |
tree | 5d35c4f4e378d5c4083d3b04e51fb1799374a20d | |
parent | b238791002697efbda1ece31985ca15331511fa8 (diff) | |
download | netsurf-6bbae1f2284a7d52daf96ad30e1519600ae5493b.tar.gz netsurf-6bbae1f2284a7d52daf96ad30e1519600ae5493b.tar.bz2 |
add document IDL and test for geteleemntbyid
-rw-r--r-- | javascript/jsapi/document.c | 81 | ||||
-rw-r--r-- | test/js/index.html | 2 | ||||
-rw-r--r-- | test/js/inline-innerhtml.html | 15 | ||||
-rw-r--r-- | test/js/sync-script-css.html | 2 | ||||
-rw-r--r-- | test/js/sync-script-err.html | 12 |
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> |