[PATCH 10/11] mshtml/tests: Test builtin objects' behavior across document modes.

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Sep 20 09:46:16 CDT 2021


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/mshtml/tests/documentmode.js | 137 ++++++++++++++++++++++++++++++
 1 file changed, 137 insertions(+)

diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js
index d4704a4..1fb0721 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -794,3 +794,140 @@ sync_test("elem_attr", function() {
     r = Object.prototype.toString.call(elem);
     ok(r === (v < 9 ? "[object Object]" : "[object HTMLDivElement]"), "toString returned " + r);
 });
+
+sync_test("builtin_obj", function() {
+    var v = document.documentMode;
+    var f = document.createElement;
+    var e;
+
+    if(v < 9) {
+        ok(!(window instanceof Object), "window instance of Object");
+        ok(!(document instanceof Object), "document instance of Object");
+        ok(!(f.apply instanceof Function), "f.apply instance of Function");
+        ok(!(f.call instanceof Function), "f.call instance of Function");
+        ok(f.arguments === undefined, "f.arguments = " + f.arguments);
+        ok(f.length === undefined, "f.length = " + f.length);
+        e = 0;
+        try {
+            f.toString();
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[f.toString] e = " + e);
+    }
+    else {
+        ok(window instanceof Object, "window not instance of Object");
+        ok(document instanceof Object, "document not instance of Object");
+        ok(Object.isExtensible(window), "window is not extensible");
+        ok(Object.isExtensible(document), "document is not extensible");
+
+        ok(f.toString() === "\nfunction createElement() {\n    [native code]\n}\n", "f.toString() = " + f.toString());
+        ok(Object.getPrototypeOf(f) === Function.prototype, "unexpected document.createElement prototype");
+        ok(Object.getPrototypeOf(f.apply) === Function.prototype, "unexpected f.apply prototype");
+        ok(Object.getPrototypeOf(f.call) === Function.prototype, "unexpected f.call prototype");
+    }
+
+    e = 0;
+    try {
+        f.call(Object, "div");
+    }catch(ex) {
+        e = ex.number;
+    }
+    ok(e === (v < 9 ? 0xa0005 : 0x0ffff) - 0x80000000, "[f.call(Object, 'div')] e = " + e);
+
+    var elem = f.call(document, "div");
+    elem.setAttribute("class", "cls");
+    elem.setAttribute("className", "cls");
+    ok(elem.className === "cls", "elem.className = " + elem.className);
+
+    if(v < 9) {
+        e = 0;
+        try {
+            elem = f.call.call(f, document, "div");
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[elem = f.call.call(f, document, 'div')] e = " + e);
+        e = 0;
+        try {
+            f = f.bind(document);
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[f.bind(document)] e = " + e);
+        elem = f.apply(document, ["style"]);
+        document.body.appendChild(elem);
+
+        var enumerator = new Enumerator(document.getElementsByTagName("style"));
+        var enum_elem = enumerator.item();
+        enumerator.moveNext();
+        ok(enum_elem === elem, "enum_elem = " + enum_elem);
+        ok(enumerator.atEnd(), "enumerator not at end");
+
+        e = 0;
+        try {
+            f.apply = 0;
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[f.apply = 0] e = " + e);
+        e = 0;
+        try {
+            f.call = function() { };
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[f.call = function() { }] e = " + e);
+        e = 0;
+        try {
+            f.arguments = 0;
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[f.arguments = 0] e = " + e);
+        e = 0;
+        try {
+            f.length = 0;
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[f.length = 0] e = " + e);
+
+        f = f.apply;
+        ok(f.arguments === undefined, "f.apply.arguments = " + f.arguments);
+        ok(f.length === undefined, "f.apply.length = " + f.length);
+        e = 0;
+        try {
+            f.toString();
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[f.apply.toString] e = " + e);
+        e = 0;
+        try {
+            f(document, ["style"]);
+        }catch(ex) {
+            e = ex.number;
+        }
+        ok(e === 0xa01b6 - 0x80000000, "[f.apply() indirect] e = " + e);
+    }
+    else {
+        elem = f.call.call(f, document, "div");
+        f = f.bind(document);
+        elem = f.apply(null, ["style"]);
+        document.body.appendChild(elem);
+
+        try {
+            var enumerator = new Enumerator(document.getElementsByTagName("style"));
+        }catch(ex) {
+            e = ex.number;
+        }
+        todo_wine.
+        ok(e === 0xa01c3 - 0x80000000, "[style Enumerator] e = " + e);
+
+        f.apply = 0;
+        f.call = function() { };
+        ok(f.apply === 0, "changed f.apply = ", f.apply);
+        ok(f.call instanceof Function, "changed f.call not instance of Function");
+    }
+});
-- 
2.31.1




More information about the wine-devel mailing list