From 6bbae1f2284a7d52daf96ad30e1519600ae5493b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 1 Aug 2012 19:25:45 +0100 Subject: add document IDL and test for geteleemntbyid --- javascript/jsapi/document.c | 81 +++++++++++++++++++++++++++++++++++++++++++ test/js/index.html | 2 ++ test/js/inline-innerhtml.html | 15 ++++++++ test/js/sync-script-css.html | 2 +- test/js/sync-script-err.html | 12 +++++++ 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 test/js/inline-innerhtml.html create mode 100644 test/js/sync-script-err.html 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 @@
  • Simple docuemnt write
  • Script within inline script
  • External syncronous script
  • +
  • External syncronous script with missing js file
  • External syncronous script (with css)
  • +
  • Inline script innerHtml test
  • 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 @@ + + +Inline Script innerHTML Test + + + +

    Inline Script innerHTML Test

    +

    Before

    +

    some text you should never see

    + +

    Afterwards

    + + 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 @@ -

    Sync script Test (css0

    +

    Sync script Test (css)

    Before

    Afterwards

    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 @@ + + +Sync script Test with bad src + + +

    Sync script Test with bad src

    +

    Before

    + + +

    Afterwards

    + + -- cgit v1.2.3