aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/html/dom.nim4
-rw-r--r--test/js/document.html9
-rw-r--r--test/js/window.html4
3 files changed, 12 insertions, 5 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index b7ecffe0..70a9277c 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -4995,7 +4995,9 @@ return x;
""")
doAssert JS_SetConstructorBit(ctx, imageFun, true)
let jsWindow = JS_GetGlobalObject(ctx)
- ctx.defineProperty(jsWindow, "Image", imageFun)
+ ctx.definePropertyCW(jsWindow, "Image", imageFun)
+ ctx.definePropertyCW(jsWindow, "HTMLDocument",
+ JS_GetPropertyStr(ctx, jsWindow, "Document"))
JS_FreeValue(ctx, jsWindow)
# Forward declaration hack
diff --git a/test/js/document.html b/test/js/document.html
index 1020283c..10ecf17d 100644
--- a/test/js/document.html
+++ b/test/js/document.html
@@ -12,10 +12,11 @@ assertEquals(document.toString, document.getElementById("toString"));
document.toString.remove();
document.testtest = "hi";
assertEquals(Object.getOwnPropertyNames(document).toString(), "testtest,location,img2,img3,asdf");
-// the spec doesn't have HTMLDocument, but browsers do.
-//TODO: we'll probably have to implement HTMLDocument ourselves too
-// nonetheless.
-if (!window.HTMLDocument)
+/*
+ * Note: the spec says Document == HTMLDocument, but in other browsers
+ * this is not true.
+ */
+if (HTMLDocument == Document)
assertEquals(document.toString(), "[object Document]");
assertEquals(document, window.document);
assertEquals(document.implementation, document.implementation);
diff --git a/test/js/window.html b/test/js/window.html
index 81485cad..06729e0e 100644
--- a/test/js/window.html
+++ b/test/js/window.html
@@ -15,5 +15,9 @@ delete window.localStorage.b;
assertEquals(window.localStorage["b"], undefined);
window.localStorage["b"] = "y";
assert(window.sessionStorage instanceof Storage);
+Image = "test";
+HTMLDocument = "test";
+assertEquals(Image, "test");
+assertEquals(HTMLDocument, "test");
document.getElementById("x").textContent = "Success";
</script>