Jacek Caban : mshtml: Rewrite navigation tests using new HTTP emulation framework.

Alexandre Julliard julliard at winehq.org
Wed Jul 6 09:57:30 CDT 2016


Module: wine
Branch: master
Commit: 00f74afeefcf5ca64ce5303e3d62956bf64326da
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=00f74afeefcf5ca64ce5303e3d62956bf64326da

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Jul  5 22:45:32 2016 +0200

mshtml: Rewrite navigation tests using new HTTP emulation framework.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/tests/navigation.js | 103 ++++++++++++++++++++++++++++++++++++++++
 dlls/mshtml/tests/rsrc.rc       |   4 +-
 dlls/mshtml/tests/script.c      |   4 +-
 3 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/dlls/mshtml/tests/navigation.js b/dlls/mshtml/tests/navigation.js
new file mode 100644
index 0000000..63f3d57
--- /dev/null
+++ b/dlls/mshtml/tests/navigation.js
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2016 Jacek Caban for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+function nav_parent_test() {
+    external.trace("Running _parent navigation tests...");
+
+    var iframe = document.getElementById("testframe");
+    var subframe = iframe.contentWindow.document.createElement("iframe");
+
+    subframe.onload = function() {
+        var doc = subframe.contentWindow.document;
+        doc.body.innerHTML = '<a href="http://winetest.org/blank2.html" id="aid" target="_parent">test</a>';
+        doc.getElementById("aid").click();
+    }
+
+    iframe.onload = function() {
+        iframe.onload = null;
+        var href = iframe.contentWindow.location.href;
+	ok(/.*blank2.html/.test(href), "Unexpected href " + href);
+	next_test();
+    }
+
+    iframe.contentWindow.document.body.appendChild(subframe);
+    subframe.src = "blank.html";
+}
+
+function window_navigate_test() {
+    external.trace("Running window.navigate() tests...");
+
+    var iframe = document.getElementById("testframe");
+
+    iframe.onload = function() {
+        iframe.onload = null;
+        var href = iframe.contentWindow.location.href;
+	ok(href === "about:blank", "Unexpected href " + href);
+	next_test();
+    }
+
+    iframe.contentWindow.navigate("about:blank");
+}
+
+function window_open_self_test() {
+    external.trace("Running window.open(_self) tests...");
+
+    var iframe = document.getElementById("testframe");
+    var iframe_window = iframe.contentWindow;
+
+    iframe.onload = function() {
+        iframe.onload = null;
+        var href = iframe.contentWindow.location.href;
+        ok(/.*blank.html\?window_open_self/.test(href), "Unexpected href " + href);
+        ok(iframe.contentWindow === iframe_window, "iframe.contentWindow !== iframe_window");
+	next_test();
+    }
+
+    iframe_window.open("blank.html?window_open_self", "_self");
+}
+
+function detached_src_test() {
+    var iframe = document.createElement("iframe");
+    var onload_called = false;
+
+    iframe.onload = function() {
+        onload_called = true;
+        next_test();
+    }
+
+    iframe.src = "blank.html";
+    document.body.appendChild(iframe);
+    ok(onload_called === false, "called onload too early?");
+}
+
+function init_test_iframe() {
+    var iframe = document.createElement("iframe");
+
+    iframe.onload = next_test;
+    iframe.id = "testframe";
+    iframe.src = "about:blank";
+    document.body.appendChild(iframe);
+}
+
+var tests = [
+    init_test_iframe,
+    nav_parent_test,
+    window_navigate_test,
+    window_open_self_test,
+    detached_src_test
+];
diff --git a/dlls/mshtml/tests/rsrc.rc b/dlls/mshtml/tests/rsrc.rc
index 1660dd6..a9ab563 100644
--- a/dlls/mshtml/tests/rsrc.rc
+++ b/dlls/mshtml/tests/rsrc.rc
@@ -34,8 +34,8 @@ events.html HTML "events.html"
 /* @makedep: externscr.js */
 externscr.js HTML "externscr.js"
 
-/* @makedep: nav_test.html */
-nav_test.html HTML "nav_test.html"
+/* @makedep: navigation.js */
+navigation.js HTML "navigation.js"
 
 /* @makedep: xhr.js */
 xhr.js HTML "xhr.js"
diff --git a/dlls/mshtml/tests/script.c b/dlls/mshtml/tests/script.c
index 57681c6..eadf737 100644
--- a/dlls/mshtml/tests/script.c
+++ b/dlls/mshtml/tests/script.c
@@ -3315,11 +3315,11 @@ static void run_js_tests(void)
         return;
     }
 
-    run_js_script("nav_test.html");
-
     init_protocol_handler();
 
     run_script_as_http_with_mode("xhr.js", NULL, "11");
+    run_script_as_http_with_mode("navigation.js", NULL, NULL);
+    run_script_as_http_with_mode("navigation.js", NULL, "11");
 }
 
 static BOOL init_registry(BOOL init)




More information about the wine-cvs mailing list