mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 07:31:47 +00:00
migrate more tests to htmlRunner
This commit is contained in:
15
src/tests/dom/performance.html
Normal file
15
src/tests/dom/performance.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<script src="../testing.js"></script>
|
||||
<script id=performance>
|
||||
let performance = window.performance;
|
||||
testing.expectEqual(true, performance instanceof Performance);
|
||||
|
||||
let mark1 = performance.mark("start");
|
||||
testing.expectEqual(true, mark1 instanceof PerformanceMark);
|
||||
testing.expectEqual('start', mark1.name);
|
||||
testing.expectEqual('mark', mark1.entryType);
|
||||
testing.expectEqual(0, mark1.duration);
|
||||
testing.expectEqual(null, mark1.detail);
|
||||
|
||||
let mark2 = performance.mark("start", {startTime: 32939393.9});
|
||||
testing.expectEqual(32939393.9, mark2.startTime);
|
||||
</script>
|
||||
4
src/tests/dom/performance_observer.html
Normal file
4
src/tests/dom/performance_observer.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<script src="../testing.js"></script>
|
||||
<script id=performanceObserver>
|
||||
testing.expectEqual(0, PerformanceObserver.supportedEntryTypes.length);
|
||||
</script>
|
||||
21
src/tests/dom/processing_instruction.html
Normal file
21
src/tests/dom/processing_instruction.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<script src="../testing.js"></script>
|
||||
<script id=processingInstruction>
|
||||
let pi = document.createProcessingInstruction('foo', 'bar');
|
||||
testing.expectEqual('foo', pi.target);
|
||||
testing.expectEqual('bar', pi.data);
|
||||
pi.data = 'foo';
|
||||
testing.expectEqual('foo', pi.data);
|
||||
|
||||
let pi2 = pi.cloneNode();
|
||||
testing.expectEqual(7, pi2.nodeType);
|
||||
|
||||
let pi11 = document.createProcessingInstruction('target1', 'data1');
|
||||
let pi12 = document.createProcessingInstruction('target2', 'data2');
|
||||
let pi13 = document.createProcessingInstruction('target1', 'data1');
|
||||
testing.expectEqual(true, pi11.isEqualNode(pi11));
|
||||
testing.expectEqual(true, pi11.isEqualNode(pi13));
|
||||
testing.expectEqual(false, pi11.isEqualNode(pi12));
|
||||
testing.expectEqual(false, pi12.isEqualNode(pi13));
|
||||
testing.expectEqual(false, pi11.isEqualNode(document));
|
||||
testing.expectEqual(false, document.isEqualNode(pi11));
|
||||
</script>
|
||||
40
src/tests/dom/range.html
Normal file
40
src/tests/dom/range.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<script src="../testing.js"></script>
|
||||
|
||||
<div id=content><!-- hello world --><p>over 9000</p></div>
|
||||
|
||||
<script id="constructor">
|
||||
let range = new Range();
|
||||
testing.expectEqual(true, range instanceof Range);
|
||||
testing.expectEqual(true, range instanceof AbstractRange);
|
||||
|
||||
// Test initial state - collapsed range
|
||||
testing.expectEqual(true, range.collapsed);
|
||||
testing.expectEqual(0, range.startOffset);
|
||||
testing.expectEqual(0, range.endOffset);
|
||||
testing.expectEqual(true, range.startContainer instanceof HTMLDocument);
|
||||
testing.expectEqual(true, range.endContainer instanceof HTMLDocument);
|
||||
</script>
|
||||
|
||||
<script id="createRange">
|
||||
let docRange = document.createRange();
|
||||
testing.expectEqual(true, docRange instanceof Range);
|
||||
testing.expectEqual(true, docRange.collapsed);
|
||||
</script>
|
||||
|
||||
<script id=textRange>
|
||||
const container = $('#content');
|
||||
const commentNode = container.childNodes[0];
|
||||
testing.expectEqual(' hello world ', commentNode.nodeValue);
|
||||
|
||||
const textRange = document.createRange();
|
||||
textRange.selectNodeContents(commentNode);
|
||||
testing.expectEqual(0, textRange.startOffset);
|
||||
testing.expectEqual(13, textRange.endOffset); // length of comment
|
||||
</script>
|
||||
|
||||
<script id=nodeRange>
|
||||
const nodeRange = document.createRange();
|
||||
nodeRange.selectNodeContents(container);
|
||||
testing.expectEqual(0, nodeRange.startOffset);
|
||||
testing.expectEqual(2, nodeRange.endOffset); // length of container.childNodes
|
||||
</script>
|
||||
48
src/tests/dom/shadow_root.html
Normal file
48
src/tests/dom/shadow_root.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<div id=conflict>node</div>
|
||||
|
||||
<script src="../testing.js"></script>
|
||||
<script id=shadow_root>
|
||||
const div1 = document.createElement('div');
|
||||
let sr1 = div1.attachShadow({mode: 'open'});
|
||||
testing.expectEqual(div1, sr1.host);
|
||||
testing.expectEqual(sr1, div1.attachShadow({mode: 'open'}));
|
||||
testing.expectEqual(sr1, div1.shadowRoot);
|
||||
|
||||
testing.expectError('Error: NotSupportedError', () => {
|
||||
div1.attachShadow({mode: 'closed'});
|
||||
});
|
||||
|
||||
sr1.append(document.createElement('div'));
|
||||
sr1.append(document.createElement('span'));
|
||||
testing.expectEqual(2, sr1.childElementCount);
|
||||
|
||||
// re-attaching clears it
|
||||
testing.expectEqual(sr1, div1.attachShadow({mode: 'open'}));
|
||||
testing.expectEqual(0, sr1.childElementCount);
|
||||
|
||||
|
||||
const div2 = document.createElement('di2');
|
||||
let sr2 = div2.attachShadow({mode: 'closed'});
|
||||
testing.expectEqual(div2, sr2.host);
|
||||
testing.expectEqual(null, div2.shadowRoot) // null when attached with 'closed'
|
||||
|
||||
|
||||
testing.expectEqual(null, sr2.getElementById('conflict'));
|
||||
const n1 = document.createElement('div');
|
||||
n1.id = 'conflict';
|
||||
sr2.append(n1);
|
||||
testing.expectEqual(n1, sr2.getElementById('conflict'));
|
||||
|
||||
const acss = sr2.adoptedStyleSheets;
|
||||
testing.expectEqual(0, acss.length);
|
||||
acss.push(new CSSStyleSheet());
|
||||
testing.expectEqual(1, acss.length);
|
||||
|
||||
sr1.innerHTML = '<p>hello</p>';
|
||||
testing.expectEqual('<p>hello</p>', sr1.innerHTML);
|
||||
testing.expectEqual('[object HTMLParagraphElement]', sr1.querySelector('*').toString());
|
||||
|
||||
sr1.innerHTML = null;
|
||||
testing.expectEqual('', sr1.innerHTML);
|
||||
testing.expectEqual(null, sr1.querySelector('*'));
|
||||
</script>
|
||||
18
src/tests/dom/text.html
Normal file
18
src/tests/dom/text.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<a id="link" href="foo" class="ok">OK</a>
|
||||
|
||||
<script src="../testing.js"></script>
|
||||
<script id=text>
|
||||
let t = new Text('foo');
|
||||
testing.expectEqual('foo', t.data);
|
||||
|
||||
let emptyt = new Text();
|
||||
testing.expectEqual('', emptyt.data);
|
||||
|
||||
let text = $('#link').firstChild;
|
||||
testing.expectEqual('OK', text.wholeText);
|
||||
|
||||
text.data = 'OK modified';
|
||||
let split = text.splitText('OK'.length);
|
||||
testing.expectEqual(' modified', split.data);
|
||||
testing.expectEqual('OK', text.data);
|
||||
</script>
|
||||
63
src/tests/dom/token_list.html
Normal file
63
src/tests/dom/token_list.html
Normal file
@@ -0,0 +1,63 @@
|
||||
<p id="para-empty" class="ok empty">
|
||||
|
||||
<script src="../testing.js"></script>
|
||||
<script id=tokenList>
|
||||
let gs = $('#para-empty');
|
||||
|
||||
let cl = gs.classList;
|
||||
testing.expectEqual('ok empty', gs.className);
|
||||
testing.expectEqual('ok empty', cl.value);
|
||||
testing.expectEqual(2, cl.length);
|
||||
|
||||
gs.className = 'foo bar baz';
|
||||
testing.expectEqual('foo bar baz', gs.className);
|
||||
testing.expectEqual(3, cl.length);
|
||||
|
||||
gs.className = 'ok empty';
|
||||
testing.expectEqual(2, cl.length);
|
||||
|
||||
let cl2 = gs.classList;
|
||||
testing.expectEqual(2, cl2.length);
|
||||
testing.expectEqual('ok', cl2.item(0));
|
||||
testing.expectEqual('empty', cl2.item(1));
|
||||
testing.expectEqual(true, cl2.contains('ok'));
|
||||
testing.expectEqual(false, cl2.contains('nok'));
|
||||
|
||||
cl2.add('foo', 'bar', 'baz');
|
||||
testing.expectEqual(5, cl2.length);
|
||||
|
||||
cl2.remove('foo', 'bar', 'baz');
|
||||
testing.expectEqual(2, cl2.length);
|
||||
|
||||
let cl3 = gs.classList;
|
||||
testing.expectEqual(false, cl3.toggle('ok'));
|
||||
testing.expectEqual(true, cl3.toggle('ok'));
|
||||
testing.expectEqual(2, cl3.length);
|
||||
|
||||
let cl4 = gs.classList;
|
||||
testing.expectEqual(true, cl4.replace('ok', 'nok'));
|
||||
testing.expectEqual("empty nok", cl4.value);
|
||||
testing.expectEqual(true, cl4.replace('nok', 'ok'));
|
||||
testing.expectEqual("empty ok", cl4.value);
|
||||
|
||||
let cl5 = gs.classList;
|
||||
let keys = [...cl5.keys()];
|
||||
testing.expectEqual(2, keys.length);
|
||||
testing.expectEqual(0, keys[0]);
|
||||
testing.expectEqual(1, keys[1]);
|
||||
|
||||
let values = [...cl5.values()];
|
||||
testing.expectEqual(2, values.length);
|
||||
testing.expectEqual('empty', values[0]);
|
||||
testing.expectEqual('ok', values[1]);
|
||||
|
||||
let entries = [...cl5.entries()];
|
||||
testing.expectEqual(2, entries.length);
|
||||
testing.expectEqual([0, 'empty'], entries[0]);
|
||||
testing.expectEqual([1, 'ok'], entries[1]);
|
||||
|
||||
let cl6 = gs.classList;
|
||||
cl6.value = 'a b ccc';
|
||||
testing.expectEqual('a b ccc', cl6.value);
|
||||
testing.expectEqual('a b ccc', cl6.toString());
|
||||
</script>
|
||||
Reference in New Issue
Block a user