mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
migrate more tests to htmlRunner
This commit is contained in:
@@ -154,134 +154,6 @@ pub const EventTarget = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const testing = @import("../../testing.zig");
|
const testing = @import("../../testing.zig");
|
||||||
test "Browser.DOM.EventTarget" {
|
test "Browser: DOM.EventTarget" {
|
||||||
var runner = try testing.jsRunner(testing.tracking_allocator, .{});
|
try testing.htmlRunner("dom/event_target.html");
|
||||||
defer runner.deinit();
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "new EventTarget()", "[object EventTarget]" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "let content = document.getElementById('content')", "undefined" },
|
|
||||||
.{ "let para = document.getElementById('para')", "undefined" },
|
|
||||||
// NOTE: as some event properties will change during the event dispatching phases
|
|
||||||
// we need to copy thoses values in order to check them afterwards
|
|
||||||
.{
|
|
||||||
\\ var nb = 0; var evt; var phase; var cur;
|
|
||||||
\\ function cbk(event) {
|
|
||||||
\\ evt = event;
|
|
||||||
\\ phase = event.eventPhase;
|
|
||||||
\\ cur = event.currentTarget;
|
|
||||||
\\ nb ++;
|
|
||||||
\\ }
|
|
||||||
,
|
|
||||||
"undefined",
|
|
||||||
},
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "content.addEventListener('basic', cbk)", "undefined" },
|
|
||||||
.{ "content.dispatchEvent(new Event('basic'))", "true" },
|
|
||||||
.{ "nb", "1" },
|
|
||||||
.{ "evt instanceof Event", "true" },
|
|
||||||
.{ "evt.type", "basic" },
|
|
||||||
.{ "phase", "2" },
|
|
||||||
.{ "cur.getAttribute('id')", "content" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0; evt = undefined; phase = undefined; cur = undefined", "undefined" },
|
|
||||||
.{ "para.dispatchEvent(new Event('basic'))", "true" },
|
|
||||||
.{ "nb", "0" }, // handler is not called, no capture, not the target, no bubbling
|
|
||||||
.{ "evt === undefined", "true" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0", "0" },
|
|
||||||
.{ "content.addEventListener('basic', cbk)", "undefined" },
|
|
||||||
.{ "content.dispatchEvent(new Event('basic'))", "true" },
|
|
||||||
.{ "nb", "1" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0", "0" },
|
|
||||||
.{ "content.addEventListener('basic', cbk, true)", "undefined" },
|
|
||||||
.{ "content.dispatchEvent(new Event('basic'))", "true" },
|
|
||||||
.{ "nb", "2" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0", "0" },
|
|
||||||
.{ "content.removeEventListener('basic', cbk)", "undefined" },
|
|
||||||
.{ "content.dispatchEvent(new Event('basic'))", "true" },
|
|
||||||
.{ "nb", "1" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0", "0" },
|
|
||||||
.{ "content.removeEventListener('basic', cbk, {capture: true})", "undefined" },
|
|
||||||
.{ "content.dispatchEvent(new Event('basic'))", "true" },
|
|
||||||
.{ "nb", "0" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0; evt = undefined; phase = undefined; cur = undefined", "undefined" },
|
|
||||||
.{ "content.addEventListener('capture', cbk, true)", "undefined" },
|
|
||||||
.{ "content.dispatchEvent(new Event('capture'))", "true" },
|
|
||||||
.{ "nb", "1" },
|
|
||||||
.{ "evt instanceof Event", "true" },
|
|
||||||
.{ "evt.type", "capture" },
|
|
||||||
.{ "phase", "2" },
|
|
||||||
.{ "cur.getAttribute('id')", "content" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0; evt = undefined; phase = undefined; cur = undefined", "undefined" },
|
|
||||||
.{ "para.dispatchEvent(new Event('capture'))", "true" },
|
|
||||||
.{ "nb", "1" },
|
|
||||||
.{ "evt instanceof Event", "true" },
|
|
||||||
.{ "evt.type", "capture" },
|
|
||||||
.{ "phase", "1" },
|
|
||||||
.{ "cur.getAttribute('id')", "content" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0; evt = undefined; phase = undefined; cur = undefined", "undefined" },
|
|
||||||
.{ "content.addEventListener('bubbles', cbk)", "undefined" },
|
|
||||||
.{ "content.dispatchEvent(new Event('bubbles', {bubbles: true}))", "true" },
|
|
||||||
.{ "nb", "1" },
|
|
||||||
.{ "evt instanceof Event", "true" },
|
|
||||||
.{ "evt.type", "bubbles" },
|
|
||||||
.{ "evt.bubbles", "true" },
|
|
||||||
.{ "phase", "2" },
|
|
||||||
.{ "cur.getAttribute('id')", "content" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "nb = 0; evt = undefined; phase = undefined; cur = undefined", "undefined" },
|
|
||||||
.{ "para.dispatchEvent(new Event('bubbles', {bubbles: true}))", "true" },
|
|
||||||
.{ "nb", "1" },
|
|
||||||
.{ "evt instanceof Event", "true" },
|
|
||||||
.{ "evt.type", "bubbles" },
|
|
||||||
.{ "phase", "3" },
|
|
||||||
.{ "cur.getAttribute('id')", "content" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "const obj1 = {calls: 0, handleEvent: function() { this.calls += 1; } };", null },
|
|
||||||
.{ "content.addEventListener('he', obj1);", null },
|
|
||||||
.{ "content.dispatchEvent(new Event('he'));", null },
|
|
||||||
.{ "obj1.calls", "1" },
|
|
||||||
|
|
||||||
.{ "content.removeEventListener('he', obj1);", null },
|
|
||||||
.{ "content.dispatchEvent(new Event('he'));", null },
|
|
||||||
.{ "obj1.calls", "1" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
// doesn't crash on null receiver
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "content.addEventListener('he2', null);", null },
|
|
||||||
.{ "content.dispatchEvent(new Event('he2'));", null },
|
|
||||||
}, .{});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,47 +219,6 @@ pub const DOMException = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const testing = @import("../../testing.zig");
|
const testing = @import("../../testing.zig");
|
||||||
test "Browser.DOM.Exception" {
|
test "Browser: DOM.Exceptions" {
|
||||||
var runner = try testing.jsRunner(testing.tracking_allocator, .{});
|
try testing.htmlRunner("dom/exceptions.html");
|
||||||
defer runner.deinit();
|
|
||||||
|
|
||||||
const err = "Failed to execute 'appendChild' on 'Node': The new child element contains the parent.";
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "let content = document.getElementById('content')", "undefined" },
|
|
||||||
.{ "let link = document.getElementById('link')", "undefined" },
|
|
||||||
// HierarchyRequestError
|
|
||||||
.{
|
|
||||||
\\ var he;
|
|
||||||
\\ try { link.appendChild(content) } catch (error) { he = error}
|
|
||||||
\\ he.name
|
|
||||||
,
|
|
||||||
"HierarchyRequestError",
|
|
||||||
},
|
|
||||||
.{ "he.code", "3" },
|
|
||||||
.{ "he.message", err },
|
|
||||||
.{ "he.toString()", "HierarchyRequestError: " ++ err },
|
|
||||||
.{ "he instanceof DOMException", "true" },
|
|
||||||
.{ "he instanceof Error", "true" },
|
|
||||||
}, .{});
|
|
||||||
|
|
||||||
// Test DOMException constructor
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "let exc0 = new DOMException()", "undefined" },
|
|
||||||
.{ "exc0.name", "Error" },
|
|
||||||
.{ "exc0.code", "0" },
|
|
||||||
.{ "exc0.message", "" },
|
|
||||||
.{ "exc0.toString()", "Error" },
|
|
||||||
|
|
||||||
.{ "let exc1 = new DOMException('Sandwich malfunction')", "undefined" },
|
|
||||||
.{ "exc1.name", "Error" },
|
|
||||||
.{ "exc1.code", "0" },
|
|
||||||
.{ "exc1.message", "Sandwich malfunction" },
|
|
||||||
.{ "exc1.toString()", "Error: Sandwich malfunction" },
|
|
||||||
|
|
||||||
.{ "let exc2 = new DOMException('Caterpillar turned into a butterfly', 'NoModificationAllowedError')", "undefined" },
|
|
||||||
.{ "exc2.name", "NoModificationAllowedError" },
|
|
||||||
.{ "exc2.code", "7" },
|
|
||||||
.{ "exc2.message", "Caterpillar turned into a butterfly" },
|
|
||||||
.{ "exc2.toString()", "NoModificationAllowedError: Caterpillar turned into a butterfly" },
|
|
||||||
}, .{});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -462,52 +462,6 @@ pub const HTMLCollection = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const testing = @import("../../testing.zig");
|
const testing = @import("../../testing.zig");
|
||||||
test "Browser.DOM.HTMLCollection" {
|
test "Browser: DOM.HTMLCollection" {
|
||||||
var runner = try testing.jsRunner(testing.tracking_allocator, .{});
|
try testing.htmlRunner("dom/html_collection.html");
|
||||||
defer runner.deinit();
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "let getElementsByTagName = document.getElementsByTagName('p')", "undefined" },
|
|
||||||
.{ "getElementsByTagName.length", "2" },
|
|
||||||
.{ "let getElementsByTagNameCI = document.getElementsByTagName('P')", "undefined" },
|
|
||||||
.{ "getElementsByTagNameCI.length", "2" },
|
|
||||||
.{ "getElementsByTagName.item(0).localName", "p" },
|
|
||||||
.{ "getElementsByTagName.item(1).localName", "p" },
|
|
||||||
.{ "let getElementsByTagNameAll = document.getElementsByTagName('*')", "undefined" },
|
|
||||||
.{ "getElementsByTagNameAll.length", "8" },
|
|
||||||
.{ "getElementsByTagNameAll.item(0).localName", "html" },
|
|
||||||
.{ "getElementsByTagNameAll.item(0).localName", "html" },
|
|
||||||
.{ "getElementsByTagNameAll.item(1).localName", "head" },
|
|
||||||
.{ "getElementsByTagNameAll.item(0).localName", "html" },
|
|
||||||
.{ "getElementsByTagNameAll.item(2).localName", "body" },
|
|
||||||
.{ "getElementsByTagNameAll.item(3).localName", "div" },
|
|
||||||
.{ "getElementsByTagNameAll.item(7).localName", "p" },
|
|
||||||
.{ "getElementsByTagNameAll.namedItem('para-empty-child').localName", "span" },
|
|
||||||
|
|
||||||
// array like
|
|
||||||
.{ "getElementsByTagNameAll[0].localName", "html" },
|
|
||||||
.{ "getElementsByTagNameAll[7].localName", "p" },
|
|
||||||
.{ "getElementsByTagNameAll[8]", "undefined" },
|
|
||||||
.{ "getElementsByTagNameAll['para-empty-child'].localName", "span" },
|
|
||||||
.{ "getElementsByTagNameAll['foo']", "undefined" },
|
|
||||||
|
|
||||||
.{ "document.getElementById('content').getElementsByTagName('*').length", "4" },
|
|
||||||
.{ "document.getElementById('content').getElementsByTagName('p').length", "2" },
|
|
||||||
.{ "document.getElementById('content').getElementsByTagName('div').length", "0" },
|
|
||||||
|
|
||||||
.{ "document.children.length", "1" },
|
|
||||||
.{ "document.getElementById('content').children.length", "3" },
|
|
||||||
|
|
||||||
// check liveness
|
|
||||||
.{ "let content = document.getElementById('content')", "undefined" },
|
|
||||||
.{ "let pe = document.getElementById('para-empty')", "undefined" },
|
|
||||||
.{ "let p = document.createElement('p')", "undefined" },
|
|
||||||
.{ "p.textContent = 'OK live'", "OK live" },
|
|
||||||
.{ "getElementsByTagName.item(1).textContent", " And" },
|
|
||||||
.{ "content.appendChild(p) != undefined", "true" },
|
|
||||||
.{ "getElementsByTagName.length", "3" },
|
|
||||||
.{ "getElementsByTagName.item(2).textContent", "OK live" },
|
|
||||||
.{ "content.insertBefore(p, pe) != undefined", "true" },
|
|
||||||
.{ "getElementsByTagName.item(0).textContent", "OK live" },
|
|
||||||
}, .{});
|
|
||||||
}
|
}
|
||||||
|
|||||||
115
src/tests/dom/event_target.html
Normal file
115
src/tests/dom/event_target.html
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<script src="../testing.js"></script>
|
||||||
|
|
||||||
|
<div id="content"><p id=para></p></div>
|
||||||
|
|
||||||
|
<script id=eventTarget>
|
||||||
|
testing.expectEqual('[object EventTarget]', new EventTarget().toString());
|
||||||
|
|
||||||
|
let content = $('#content');
|
||||||
|
let para = $('#para');
|
||||||
|
|
||||||
|
var nb = 0;
|
||||||
|
var evt;
|
||||||
|
var phase;
|
||||||
|
var cur;
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
nb = 0;
|
||||||
|
evt = undefined;
|
||||||
|
phase = undefined;
|
||||||
|
cur = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cbk(event) {
|
||||||
|
evt = event;
|
||||||
|
phase = event.eventPhase;
|
||||||
|
cur = event.currentTarget;
|
||||||
|
nb++;
|
||||||
|
}
|
||||||
|
|
||||||
|
content.addEventListener('basic', cbk);
|
||||||
|
content.dispatchEvent(new Event('basic'));
|
||||||
|
testing.expectEqual(1, nb);
|
||||||
|
testing.expectEqual(true, evt instanceof Event);
|
||||||
|
testing.expectEqual('basic', evt.type);
|
||||||
|
testing.expectEqual(2, phase);
|
||||||
|
testing.expectEqual('content', cur.getAttribute('id'));
|
||||||
|
|
||||||
|
reset();
|
||||||
|
para.dispatchEvent(new Event('basic'))
|
||||||
|
|
||||||
|
// handler is not called, no capture, not the targeno bubbling
|
||||||
|
testing.expectEqual(0, nb);
|
||||||
|
testing.expectEqual(undefined, evt);
|
||||||
|
|
||||||
|
reset();
|
||||||
|
content.addEventListener('basic', cbk);
|
||||||
|
content.dispatchEvent(new Event('basic'))
|
||||||
|
testing.expectEqual(1, nb);
|
||||||
|
|
||||||
|
reset();
|
||||||
|
content.addEventListener('basic', cbk, true);
|
||||||
|
content.dispatchEvent(new Event('basic'));
|
||||||
|
testing.expectEqual(2, nb);
|
||||||
|
|
||||||
|
reset()
|
||||||
|
content.removeEventListener('basic', cbk);
|
||||||
|
content.dispatchEvent(new Event('basic'));
|
||||||
|
testing.expectEqual(1, nb);
|
||||||
|
|
||||||
|
reset();
|
||||||
|
content.removeEventListener('basic', cbk, {capture: true});
|
||||||
|
content.dispatchEvent(new Event('basic'));
|
||||||
|
testing.expectEqual(0, nb);
|
||||||
|
|
||||||
|
reset();
|
||||||
|
content.addEventListener('capture', cbk, true);
|
||||||
|
content.dispatchEvent(new Event('capture'));
|
||||||
|
testing.expectEqual(1, nb);
|
||||||
|
testing.expectEqual(true, evt instanceof Event);
|
||||||
|
testing.expectEqual('capture', evt.type);
|
||||||
|
testing.expectEqual(2, phase);
|
||||||
|
testing.expectEqual('content', cur.getAttribute('id'));
|
||||||
|
|
||||||
|
reset();
|
||||||
|
para.dispatchEvent(new Event('capture'));
|
||||||
|
testing.expectEqual(1, nb);
|
||||||
|
testing.expectEqual(true, evt instanceof Event);
|
||||||
|
testing.expectEqual('capture', evt.type);
|
||||||
|
testing.expectEqual(1, phase);
|
||||||
|
testing.expectEqual('content', cur.getAttribute('id'));
|
||||||
|
|
||||||
|
reset();
|
||||||
|
content.addEventListener('bubbles', cbk);
|
||||||
|
content.dispatchEvent(new Event('bubbles', {bubbles: true}));
|
||||||
|
testing.expectEqual(1, nb);
|
||||||
|
testing.expectEqual(true, evt instanceof Event);
|
||||||
|
testing.expectEqual('bubbles', evt.type);
|
||||||
|
testing.expectEqual(2, phase);
|
||||||
|
testing.expectEqual('content', cur.getAttribute('id'));
|
||||||
|
|
||||||
|
reset();
|
||||||
|
para.dispatchEvent(new Event('bubbles', {bubbles: true}));
|
||||||
|
testing.expectEqual(1, nb);
|
||||||
|
testing.expectEqual(true, evt instanceof Event);
|
||||||
|
testing.expectEqual('bubbles', evt.type);
|
||||||
|
testing.expectEqual(3, phase);
|
||||||
|
testing.expectEqual('content', cur.getAttribute('id'));
|
||||||
|
|
||||||
|
|
||||||
|
const obj1 = {
|
||||||
|
calls: 0,
|
||||||
|
handleEvent: function() { this.calls += 1 }
|
||||||
|
};
|
||||||
|
content.addEventListener('he', obj1);
|
||||||
|
content.dispatchEvent(new Event('he'));
|
||||||
|
testing.expectEqual(1, obj1.calls);
|
||||||
|
|
||||||
|
content.removeEventListener('he', obj1);
|
||||||
|
content.dispatchEvent(new Event('he'));
|
||||||
|
testing.expectEqual(1, obj1.calls);
|
||||||
|
|
||||||
|
// doesn't crash on null receiver
|
||||||
|
content.addEventListener('he2', null);
|
||||||
|
content.dispatchEvent(new Event('he2'));
|
||||||
|
</script>
|
||||||
39
src/tests/dom/exceptions.html
Normal file
39
src/tests/dom/exceptions.html
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<script src="../testing.js"></script>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<a id="link" href="foo" class="ok">OK</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script id=exceptions>
|
||||||
|
let content = $('#content');
|
||||||
|
let link = $('#link');
|
||||||
|
|
||||||
|
testing.withError((err) => {
|
||||||
|
const msg = "Failed to execute 'appendChild' on 'Node': The new child element contains the parent.";
|
||||||
|
testing.expectEqual(3, err.code);
|
||||||
|
testing.expectEqual(msg, err.message);
|
||||||
|
testing.expectEqual('HierarchyRequestError: ' + msg, err.toString());
|
||||||
|
testing.expectEqual(true, err instanceof DOMException);
|
||||||
|
testing.expectEqual(true, err instanceof Error);
|
||||||
|
}, () => link.appendChild(content));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script id=constructor>
|
||||||
|
let exc0 = new DOMException();
|
||||||
|
testing.expectEqual('Error', exc0.name);
|
||||||
|
testing.expectEqual(0, exc0.code);
|
||||||
|
testing.expectEqual('', exc0.message);
|
||||||
|
testing.expectEqual('Error', exc0.toString());
|
||||||
|
|
||||||
|
let exc1 = new DOMException('Sandwich malfunction');
|
||||||
|
testing.expectEqual('Error', exc1.name);
|
||||||
|
testing.expectEqual(0, exc1.code);
|
||||||
|
testing.expectEqual('Sandwich malfunction', exc1.message);
|
||||||
|
testing.expectEqual('Error: Sandwich malfunction', exc1.toString());
|
||||||
|
|
||||||
|
let exc2 = new DOMException('Caterpillar turned into a butterfly', 'NoModificationAllowedError');
|
||||||
|
testing.expectEqual('NoModificationAllowedError', exc2.name);
|
||||||
|
testing.expectEqual(7, exc2.code);
|
||||||
|
testing.expectEqual('Caterpillar turned into a butterfly', exc2.message);
|
||||||
|
testing.expectEqual('NoModificationAllowedError: Caterpillar turned into a butterfly', exc2.toString());
|
||||||
|
</script>
|
||||||
59
src/tests/dom/html_collection.html
Normal file
59
src/tests/dom/html_collection.html
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<body>
|
||||||
|
<div id="content">
|
||||||
|
<a id="link" href="foo" class="ok">OK</a>
|
||||||
|
<p id="para-empty" class="ok empty">
|
||||||
|
<span id="para-empty-child"></span>
|
||||||
|
</p>
|
||||||
|
<p id="para"> And</p>
|
||||||
|
<!--comment-->
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script src="../testing.js"></script>
|
||||||
|
<script id=exceptions>
|
||||||
|
let content = $('#content');
|
||||||
|
let pe = $('#para-empty');
|
||||||
|
|
||||||
|
let getElementsByTagName = document.getElementsByTagName('p');
|
||||||
|
testing.expectEqual(2, getElementsByTagName.length);
|
||||||
|
|
||||||
|
let getElementsByTagNameCI = document.getElementsByTagName('P');
|
||||||
|
testing.expectEqual(2, getElementsByTagNameCI.length);
|
||||||
|
testing.expectEqual('p', getElementsByTagName.item(0).localName);
|
||||||
|
testing.expectEqual('p', getElementsByTagName.item(1).localName);
|
||||||
|
|
||||||
|
let getElementsByTagNameAll = document.getElementsByTagName('*');
|
||||||
|
testing.expectEqual(10, getElementsByTagNameAll.length);
|
||||||
|
testing.expectEqual('html', getElementsByTagNameAll.item(0).localName);
|
||||||
|
testing.expectEqual('html', getElementsByTagNameAll.item(0).localName);
|
||||||
|
testing.expectEqual('head', getElementsByTagNameAll.item(1).localName);
|
||||||
|
testing.expectEqual('html', getElementsByTagNameAll.item(0).localName);
|
||||||
|
testing.expectEqual('body', getElementsByTagNameAll.item(2).localName);
|
||||||
|
testing.expectEqual('div', getElementsByTagNameAll.item(3).localName);
|
||||||
|
testing.expectEqual('p', getElementsByTagNameAll.item(7).localName);
|
||||||
|
testing.expectEqual('span', getElementsByTagNameAll.namedItem('para-empty-child').localName);
|
||||||
|
|
||||||
|
// array like
|
||||||
|
testing.expectEqual('html', getElementsByTagNameAll[0].localName);
|
||||||
|
testing.expectEqual('p', getElementsByTagNameAll[7].localName);
|
||||||
|
testing.expectEqual(undefined, getElementsByTagNameAll[11]);
|
||||||
|
testing.expectEqual('span', getElementsByTagNameAll['para-empty-child'].localName);
|
||||||
|
testing.expectEqual(undefined, getElementsByTagNameAll['foo']);
|
||||||
|
|
||||||
|
testing.expectEqual(4, content.getElementsByTagName('*').length);
|
||||||
|
testing.expectEqual(2, content.getElementsByTagName('p').length);
|
||||||
|
testing.expectEqual(0, content.getElementsByTagName('div').length);
|
||||||
|
|
||||||
|
testing.expectEqual(1, document.children.length);
|
||||||
|
testing.expectEqual(3, content.children.length);
|
||||||
|
|
||||||
|
// check liveness
|
||||||
|
let p = document.createElement('p');
|
||||||
|
testing.expectEqual('OK live', p.textContent = 'OK live');
|
||||||
|
testing.expectEqual(' And', getElementsByTagName.item(1).textContent);
|
||||||
|
testing.expectEqual(true, content.appendChild(p) != undefined);
|
||||||
|
testing.expectEqual(3, getElementsByTagName.length);
|
||||||
|
testing.expectEqual('OK live', getElementsByTagName.item(2).textContent);
|
||||||
|
testing.expectEqual(true, content.insertBefore(p, pe) != undefined);
|
||||||
|
testing.expectEqual('OK live', getElementsByTagName.item(0).textContent);
|
||||||
|
</script>
|
||||||
@@ -50,7 +50,6 @@
|
|||||||
function getStatus() {
|
function getStatus() {
|
||||||
// if we're already in a fail state, return fail, nothing can recover this
|
// if we're already in a fail state, return fail, nothing can recover this
|
||||||
if (testing._status === 'fail') return 'fail';
|
if (testing._status === 'fail') return 'fail';
|
||||||
|
|
||||||
// run any eventually's that we've captured
|
// run any eventually's that we've captured
|
||||||
for (const ev of testing._eventually) {
|
for (const ev of testing._eventually) {
|
||||||
testing._captured = ev[1];
|
testing._captured = ev[1];
|
||||||
@@ -70,7 +69,8 @@
|
|||||||
if (!id) {
|
if (!id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!testing._executed_scripts[id]) {
|
|
||||||
|
if (!testing._executed_scripts.has(id)) {
|
||||||
console.warn(`Failed to execute any expectations for <script id="${id}">...</script>`),
|
console.warn(`Failed to execute any expectations for <script id="${id}">...</script>`),
|
||||||
testing._status = 'fail';
|
testing._status = 'fail';
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
testing._status = 'ok';
|
testing._status = 'ok';
|
||||||
|
|
||||||
const script_id = testing._captured?.script_id || document.currentScript.id;
|
const script_id = testing._captured?.script_id || document.currentScript.id;
|
||||||
testing._executed_scripts[script_id] = true;
|
testing._executed_scripts.add(script_id);
|
||||||
_registerErrorCallback();
|
_registerErrorCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@
|
|||||||
window.testing = {
|
window.testing = {
|
||||||
_status: 'empty',
|
_status: 'empty',
|
||||||
_eventually: [],
|
_eventually: [],
|
||||||
_executed_scripts: {},
|
_executed_scripts: new Set(),
|
||||||
_captured: null,
|
_captured: null,
|
||||||
skip: skip,
|
skip: skip,
|
||||||
getStatus: getStatus,
|
getStatus: getStatus,
|
||||||
|
|||||||
2
vendor/netsurf/libdom
vendored
2
vendor/netsurf/libdom
vendored
Submodule vendor/netsurf/libdom updated: c0df458132...120717bad4
Reference in New Issue
Block a user