mshtml/tests: Use more winetest.js helpers in more places.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
44dbb88ce4
commit
e06c541cb6
|
@ -16,7 +16,9 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
function test_input_selection() {
|
||||
var tests = [];
|
||||
|
||||
sync_test("input_selection", function() {
|
||||
var input = document.createElement("input");
|
||||
input.type = "text";
|
||||
input.value = "test";
|
||||
|
@ -55,11 +57,9 @@ function test_input_selection() {
|
|||
|
||||
input.setSelectionRange(3, 3);
|
||||
test_range(3, 3);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_textContent() {
|
||||
sync_test("textContent", function() {
|
||||
var text = document.createTextNode("test");
|
||||
ok(text.textContent === "test", "text.textContent = " + text.textContent);
|
||||
|
||||
|
@ -85,11 +85,9 @@ function test_textContent() {
|
|||
ok(div.textContent === "10.5", "div.textContent = " + div.textContent);
|
||||
|
||||
ok(document.textContent === null, "document.textContent = " + document.textContent);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_ElementTraversal() {
|
||||
sync_test("ElementTraversal", function() {
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = "abc<b>bold</b><script>/* */<script><div>text</div>def";
|
||||
ok(div.firstElementChild.outerHTML === "<b>bold</b>",
|
||||
|
@ -99,19 +97,15 @@ function test_ElementTraversal() {
|
|||
ok(div.firstElementChild === null, "div.firstElementChild = " + div.firstElementChild);
|
||||
|
||||
ok(!("firstElementChild" in document), "firstElementChild found in document");
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_head() {
|
||||
sync_test("head", function() {
|
||||
var h = document.head;
|
||||
ok(h.tagName === "HEAD", "h.tagName = " + h.tagName);
|
||||
ok(h === document.getElementsByTagName("head")[0], "unexpected head element");
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_iframe() {
|
||||
async_test("iframe", function() {
|
||||
document.body.innerHTML = '<iframe src="runscript.html?frame.js"></iframe>'
|
||||
var iframe = document.body.firstChild;
|
||||
|
||||
|
@ -124,9 +118,9 @@ function test_iframe() {
|
|||
|
||||
next_test();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function test_iframe_location() {
|
||||
async_test("iframe_location", function() {
|
||||
document.body.innerHTML = '<iframe src="emptyfile"></iframe>'
|
||||
var iframe = document.body.firstChild;
|
||||
|
||||
|
@ -140,9 +134,9 @@ function test_iframe_location() {
|
|||
}
|
||||
iframe.src = "empty/file";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function test_anchor() {
|
||||
sync_test("anchor", function() {
|
||||
var iframe = document.body.firstChild;
|
||||
var anchor = document.createElement("a");
|
||||
|
||||
|
@ -162,11 +156,9 @@ function test_anchor() {
|
|||
todo_wine_if("todo_host" in t).
|
||||
ok(anchor.host === t.host, "anchor(" + t.href + ").host = " + anchor.host);
|
||||
}
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_getElementsByClassName() {
|
||||
sync_test("getElementsByClassName", function() {
|
||||
var elems;
|
||||
|
||||
document.body.innerHTML = '<div class="class1">'
|
||||
|
@ -187,11 +179,9 @@ function test_getElementsByClassName() {
|
|||
|
||||
elems = document.getElementsByClassName("classnotfound");
|
||||
ok(elems.length == 0, "elems.length = " + elems.length);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_createElementNS() {
|
||||
sync_test("createElementNS", function() {
|
||||
var svg_ns = "http://www.w3.org/2000/svg";
|
||||
var elem;
|
||||
|
||||
|
@ -210,11 +200,9 @@ function test_createElementNS() {
|
|||
elem = document.createElementNS("test", "svg");
|
||||
ok(elem.tagName === "svg", "elem.tagName = " + elem.tagName);
|
||||
ok(elem.namespaceURI === "test", "elem.namespaceURI = " + elem.namespaceURI);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_query_selector() {
|
||||
sync_test("query_selector", function() {
|
||||
document.body.innerHTML = '<div class="class1">'
|
||||
+ '<div class="class1"></div>'
|
||||
+ '<a id="class1" class="class2"></a>'
|
||||
|
@ -237,11 +225,9 @@ function test_query_selector() {
|
|||
ok(e.tagName === "A", "e.tagName = " + e.tagName);
|
||||
e = document.body.querySelector("a");
|
||||
ok(e.tagName === "A", "e.tagName = " + e.tagName);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_compare_position() {
|
||||
sync_test("compare_position", function() {
|
||||
document.body.innerHTML = '<div><div></div><div></div></div>';
|
||||
|
||||
var parent = document.body.firstChild;
|
||||
|
@ -261,11 +247,9 @@ function test_compare_position() {
|
|||
compare_position(parent, child2, 0x14);
|
||||
compare_position(parent, elem, 0x21, 6);
|
||||
compare_position(elem, parent, 0x21, 6);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_rects() {
|
||||
sync_test("rects", function() {
|
||||
document.body.innerHTML = '<div>test</div>';
|
||||
var elem = document.body.firstChild;
|
||||
var rects = elem.getClientRects();
|
||||
|
@ -278,11 +262,9 @@ function test_rects() {
|
|||
elem = document.createElement("style");
|
||||
rects = elem.getClientRects();
|
||||
ok(rects.length === 0, "rect.length = " + rects.length);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_document_owner() {
|
||||
sync_test("document_owner", function() {
|
||||
var node;
|
||||
|
||||
ok(document.ownerDocument === null, "ownerDocument = " + document.ownerDocument);
|
||||
|
@ -299,11 +281,9 @@ function test_document_owner() {
|
|||
|
||||
node = document.createTextNode("test");
|
||||
ok(node.ownerDocument === document, "text.ownerDocument = " + node.ownerDocument);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_style_properties() {
|
||||
sync_test("style_properties", function() {
|
||||
document.body.innerHTML = '<div>test</div><svg></svg>';
|
||||
var elem = document.body.firstChild;
|
||||
var style = elem.style;
|
||||
|
@ -354,7 +334,6 @@ function test_style_properties() {
|
|||
ok(style.borderWidth === "5px", "style.borderWidth = " + style.borderWidth);
|
||||
}catch(e) {
|
||||
win_skip("skipping setProperty tests on too old IE version");
|
||||
next_test();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -398,11 +377,9 @@ function test_style_properties() {
|
|||
ok(computed_style.zIndex === 4, "computed_style.zIndex = " + computed_style.zIndex);
|
||||
|
||||
window.getComputedStyle(elem, null);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_stylesheets() {
|
||||
sync_test("stylesheets", function() {
|
||||
document.body.innerHTML = '<style>.div { margin-right: 1px; }</style>';
|
||||
|
||||
ok(document.styleSheets.length === 1, "document.styleSheets.length = " + document.styleSheets.length);
|
||||
|
@ -416,33 +393,11 @@ function test_stylesheets() {
|
|||
stylesheet.rules.item(1);
|
||||
ok(false, "expected exception");
|
||||
}catch(e) {}
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_storage() {
|
||||
sync_test("storage", function() {
|
||||
ok(typeof(window.sessionStorage) === "object",
|
||||
"typeof(window.sessionStorage) = " + typeof(window.sessionStorage));
|
||||
ok(typeof(window.localStorage) === "object",
|
||||
"typeof(window.localStorage) = " + typeof(window.localStorage));
|
||||
next_test();
|
||||
}
|
||||
|
||||
var tests = [
|
||||
test_input_selection,
|
||||
test_textContent,
|
||||
test_ElementTraversal,
|
||||
test_getElementsByClassName,
|
||||
test_createElementNS,
|
||||
test_head,
|
||||
test_iframe,
|
||||
test_iframe_location,
|
||||
test_anchor,
|
||||
test_query_selector,
|
||||
test_compare_position,
|
||||
test_rects,
|
||||
test_document_owner,
|
||||
test_style_properties,
|
||||
test_stylesheets,
|
||||
test_storage
|
||||
];
|
||||
});
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
var tests = [];
|
||||
|
||||
var test_content_loaded = (function() {
|
||||
var calls = "";
|
||||
|
||||
|
@ -24,7 +26,7 @@ var test_content_loaded = (function() {
|
|||
}
|
||||
|
||||
function record_call(msg) {
|
||||
return function() { calls += msg + "," };
|
||||
return function() { calls += msg + ","; };
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", record_call("window.capture"), true);
|
||||
|
@ -42,13 +44,15 @@ var test_content_loaded = (function() {
|
|||
};
|
||||
})();
|
||||
|
||||
function test_listener_order() {
|
||||
async_test("content_loaded", test_content_loaded);
|
||||
|
||||
sync_test("listener_order", function() {
|
||||
document.body.innerHTML = '<div></div>';
|
||||
var div = document.body.firstChild;
|
||||
|
||||
var calls;
|
||||
function record_call(msg) {
|
||||
return function() { calls += msg + "," };
|
||||
return function() { calls += msg + ","; };
|
||||
}
|
||||
|
||||
window.addEventListener("click", record_call("window.click(capture)"), true);
|
||||
|
@ -98,11 +102,9 @@ function test_listener_order() {
|
|||
+ "div.click(bubble),new div.onclick,div.click(capture1),div.click(capture2),"
|
||||
+ "body.onclick,body.click(bubble),body.click(bubble2),document.click(bubble),"
|
||||
+ "document.onclick,window.click(bubble),", "calls = " + calls);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_add_listener_in_listener() {
|
||||
sync_test("add_listener_in_listener", function() {
|
||||
var calls;
|
||||
|
||||
document.body.innerHTML = '<div><div></div></div>';
|
||||
|
@ -110,7 +112,7 @@ function test_add_listener_in_listener() {
|
|||
var div2 = div1.firstChild;
|
||||
|
||||
function record_call(msg) {
|
||||
return function() { calls += msg + "," };
|
||||
return function() { calls += msg + ","; };
|
||||
}
|
||||
|
||||
div1.addEventListener("click", function() {
|
||||
|
@ -126,18 +128,16 @@ function test_add_listener_in_listener() {
|
|||
calls = "";
|
||||
div2.click();
|
||||
ok(calls === "div2.click", "calls = " + calls);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_remove_listener_in_listener() {
|
||||
sync_test("remove_listener_in_listener", function() {
|
||||
var calls;
|
||||
|
||||
document.body.innerHTML = '<div></div>';
|
||||
var div = document.body.firstChild;
|
||||
|
||||
function record_call(msg) {
|
||||
return function() { calls += msg + "," };
|
||||
return function() { calls += msg + ","; };
|
||||
}
|
||||
|
||||
var capture = record_call("capture"), bubble = record_call("bubble");
|
||||
|
@ -155,11 +155,9 @@ function test_remove_listener_in_listener() {
|
|||
calls = "";
|
||||
div.click();
|
||||
ok(calls === "remove,capture,bubble,onclick,", "calls = " + calls);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_add_remove_listener() {
|
||||
sync_test("add_remove_listener", function() {
|
||||
var calls;
|
||||
|
||||
document.body.innerHTML = '<div></div>';
|
||||
|
@ -200,11 +198,9 @@ function test_add_remove_listener() {
|
|||
calls = "";
|
||||
div.click();
|
||||
ok(calls === "", "calls = " + calls);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_event_phase() {
|
||||
sync_test("event_phase", function() {
|
||||
document.body.innerHTML = '<div><div></div></div>';
|
||||
var div1 = document.body.firstChild;
|
||||
var div2 = div1.firstChild;
|
||||
|
@ -230,18 +226,16 @@ function test_event_phase() {
|
|||
|
||||
div2.click();
|
||||
ok(last_event.eventPhase === 3, "last_event.eventPhase = " + last_event.eventPhase);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_stop_propagation() {
|
||||
sync_test("stop_propagation", function() {
|
||||
document.body.innerHTML = '<div><div></div></div>';
|
||||
var div1 = document.body.firstChild;
|
||||
var div2 = div1.firstChild;
|
||||
|
||||
var calls;
|
||||
function record_call(msg) {
|
||||
return function() { calls += msg + "," };
|
||||
return function() { calls += msg + ","; };
|
||||
}
|
||||
|
||||
function stop_propagation(e) {
|
||||
|
@ -304,11 +298,9 @@ function test_stop_propagation() {
|
|||
div2.click();
|
||||
ok(calls === "div1.click(capture),div2.click(capture),div2.click(bubble),stop,div1.click(bubble),",
|
||||
"calls = " + calls);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_prevent_default() {
|
||||
sync_test("prevent_default", function() {
|
||||
document.body.innerHTML = '<div><a href="about:blank"></a></div>';
|
||||
var div = document.body.firstChild;
|
||||
var a = div.firstChild;
|
||||
|
@ -385,11 +377,9 @@ function test_prevent_default() {
|
|||
ok(r === true, "dispatchEvent returned " + r);
|
||||
e.preventDefault();
|
||||
ok(e.defaultPrevented === false, "defaultPrevented = " + e.defaultPrevented);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_init_event() {
|
||||
sync_test("init_event", function() {
|
||||
var e = document.createEvent("Event");
|
||||
var calls;
|
||||
|
||||
|
@ -457,11 +447,9 @@ function test_init_event() {
|
|||
|
||||
document.body.dispatchEvent(e);
|
||||
ok(e.target === document.body, "target != body");
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_current_target() {
|
||||
sync_test("current_target", function() {
|
||||
document.body.innerHTML = '<div><div></div></div>';
|
||||
var parent = document.body.firstChild;
|
||||
var child = parent.firstChild;
|
||||
|
@ -488,11 +476,9 @@ function test_current_target() {
|
|||
child.dispatchEvent(e);
|
||||
ok(calls === 4, "calls = " + calls + " expected 4");
|
||||
ok(e.currentTarget === null, "currentTarget != null");
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_dispatch_event() {
|
||||
sync_test("dispatch_event", function() {
|
||||
document.body.innerHTML = '<div><div></div></div>';
|
||||
var parent = document.body.firstChild;
|
||||
var child = parent.firstChild;
|
||||
|
@ -563,11 +549,9 @@ function test_dispatch_event() {
|
|||
calls = "";
|
||||
xhr.dispatchEvent(e);
|
||||
ok(calls === "xhr.testing", "calls = " + calls);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_recursive_dispatch() {
|
||||
sync_test("recursive_dispatch", function() {
|
||||
document.body.innerHTML = '<div></div><div></div>';
|
||||
var elem1 = document.body.firstChild;
|
||||
var elem2 = elem1.nextSibling;
|
||||
|
@ -596,11 +580,9 @@ function test_recursive_dispatch() {
|
|||
elem1.dispatchEvent(e);
|
||||
ok(calls === "elem1.test,", "calls = " + calls);
|
||||
ok(e.eventPhase === 3, "eventPhase = " + e.eventPhase);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_time_stamp() {
|
||||
sync_test("time_stamp", function() {
|
||||
document.body.innerHTML = '<div></div>';
|
||||
var elem = document.body.firstChild;
|
||||
var calls, last_time_stamp;
|
||||
|
@ -634,11 +616,9 @@ function test_time_stamp() {
|
|||
calls = 0;
|
||||
elem.click();
|
||||
ok(calls === 1, "calls = " + calls);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_mouse_event() {
|
||||
sync_test("mouse_event", function() {
|
||||
var e;
|
||||
|
||||
e = document.createEvent("MouseEvent");
|
||||
|
@ -727,11 +707,9 @@ function test_mouse_event() {
|
|||
ok(e.shiftKey === true, "shiftKey = " + e.shiftKey);
|
||||
ok(e.metaKey === true, "metaKey = " + e.metaKey);
|
||||
ok(e.button === 127, "button = " + e.button);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_ui_event() {
|
||||
sync_test("ui_event", function() {
|
||||
var e;
|
||||
|
||||
e = document.createEvent("UIEvent");
|
||||
|
@ -744,11 +722,9 @@ function test_ui_event() {
|
|||
ok(e.detail === 3, "detail = " + e.detail);
|
||||
todo_wine.
|
||||
ok(e.view === window, "view != window");
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_keyboard_event() {
|
||||
sync_test("keyboard_event", function() {
|
||||
var e;
|
||||
|
||||
e = document.createEvent("KeyboardEvent");
|
||||
|
@ -765,11 +741,9 @@ function test_keyboard_event() {
|
|||
ok(e.location === 0, "location = " + e.location);
|
||||
ok(e.detail === 0, "detail = " + e.detail);
|
||||
ok(e.which === 0, "which = " + e.which);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_custom_event() {
|
||||
sync_test("custom_event", function() {
|
||||
var e = document.createEvent("CustomEvent");
|
||||
|
||||
ok(e.detail === undefined, "detail = " + e.detail);
|
||||
|
@ -779,18 +753,16 @@ function test_custom_event() {
|
|||
ok(e.bubbles === true, "bubbles = " + e.bubbles);
|
||||
ok(e.cancelable === false, "cancelable = " + e.cancelable);
|
||||
ok(e.detail === 123, "detail = " + e.detail);
|
||||
});
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
function test_error_event() {
|
||||
async_test("error_event", function() {
|
||||
document.body.innerHTML = '<div><img></img></div>';
|
||||
var div = document.body.firstChild;
|
||||
var img = div.firstChild;
|
||||
var calls = "";
|
||||
|
||||
function record_call(msg) {
|
||||
return function() { calls += msg + "," };
|
||||
return function() { calls += msg + ","; };
|
||||
}
|
||||
var win_onerror = record_call("window.onerror");
|
||||
var doc_onerror = record_call("doc.onerror");
|
||||
|
@ -811,34 +783,12 @@ function test_error_event() {
|
|||
}, true);
|
||||
|
||||
img.src = "about:blank";
|
||||
}
|
||||
});
|
||||
|
||||
function test_detached_img_error_event() {
|
||||
async_test("detached_img_error_event", function() {
|
||||
var img = new Image();
|
||||
img.onerror = function() {
|
||||
next_test();
|
||||
}
|
||||
img.src = "about:blank";
|
||||
}
|
||||
|
||||
var tests = [
|
||||
test_content_loaded,
|
||||
test_add_remove_listener,
|
||||
test_add_listener_in_listener,
|
||||
test_remove_listener_in_listener,
|
||||
test_event_phase,
|
||||
test_stop_propagation,
|
||||
test_prevent_default,
|
||||
test_init_event,
|
||||
test_current_target,
|
||||
test_dispatch_event,
|
||||
test_recursive_dispatch,
|
||||
test_ui_event,
|
||||
test_mouse_event,
|
||||
test_keyboard_event,
|
||||
test_custom_event,
|
||||
test_error_event,
|
||||
test_detached_img_error_event,
|
||||
test_time_stamp,
|
||||
test_listener_order
|
||||
];
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue