@@ -314,116 +314,7 @@ pub const HTMLDocument = struct {
314314 }
315315};
316316
317- // Tests
318- // -----
319-
320317const testing = @import ("../../testing.zig" );
321-
322- test "Browser.HTML.Document" {
323- var runner = try testing .jsRunner (testing .tracking_allocator , .{});
324- defer runner .deinit ();
325-
326- try runner .testCases (&.{
327- .{ "document.__proto__.constructor.name" , "HTMLDocument" },
328- .{ "document.__proto__.__proto__.constructor.name" , "Document" },
329- .{ "document.body.localName == 'body'" , "true" },
330- }, .{});
331-
332- try runner .testCases (&.{
333- .{ "document.domain" , "lightpanda.io" },
334- .{ "document.referrer" , "" },
335- .{ "document.title" , "" },
336- .{ "document.body.localName" , "body" },
337- .{ "document.head.localName" , "head" },
338- .{ "document.images.length" , "0" },
339- .{ "document.embeds.length" , "0" },
340- .{ "document.plugins.length" , "0" },
341- .{ "document.scripts.length" , "0" },
342- .{ "document.forms.length" , "0" },
343- .{ "document.links.length" , "1" },
344- .{ "document.applets.length" , "0" },
345- .{ "document.anchors.length" , "0" },
346- .{ "document.all.length" , "8" },
347- .{ "document.currentScript" , "null" },
348- }, .{});
349-
350- try runner .testCases (&.{
351- .{ "document.title = 'foo'" , "foo" },
352- .{ "document.title" , "foo" },
353- .{ "document.title = ''" , "" },
354- }, .{});
355-
356- try runner .testCases (&.{
357- .{ "document.getElementById('link').setAttribute('name', 'foo')" , "undefined" },
358- .{ "let list = document.getElementsByName('foo')" , "undefined" },
359- .{ "list.length" , "1" },
360- }, .{});
361-
362- try runner .testCases (&.{
363- .{ "document.cookie" , "" },
364- .{ "document.cookie = 'name=Oeschger; SameSite=None; Secure'" , "name=Oeschger; SameSite=None; Secure" },
365- .{ "document.cookie = 'favorite_food=tripe; SameSite=None; Secure'" , "favorite_food=tripe; SameSite=None; Secure" },
366- .{ "document.cookie" , "name=Oeschger; favorite_food=tripe" },
367- .{ "document.cookie = 'IgnoreMy=Ghost; HttpOnly'" , null }, // "" should be returned, but the framework overrules it atm
368- .{ "document.cookie" , "name=Oeschger; favorite_food=tripe" },
369- }, .{});
370-
371- try runner .testCases (&.{
372- .{ "document.elementFromPoint(0.5, 0.5)" , "null" }, // Return null since we only return element s when they have previously been localized
373- .{ "document.elementsFromPoint(0.5, 0.5)" , "" },
374- .{
375- \\ let div1 = document.createElement('div');
376- \\ document.body.appendChild(div1);
377- \\ div1.getClientRects();
378- ,
379- null ,
380- },
381- .{ "document.elementFromPoint(0.5, 0.5)" , "[object HTMLDivElement]" },
382- .{ "let elems = document.elementsFromPoint(0.5, 0.5)" , null },
383- .{ "elems.length" , "3" },
384- .{ "elems[0]" , "[object HTMLDivElement]" },
385- .{ "elems[1]" , "[object HTMLBodyElement]" },
386- .{ "elems[2]" , "[object HTMLHtmlElement]" },
387- }, .{});
388-
389- try runner .testCases (&.{
390- .{
391- \\ let a = document.createElement('a');
392- \\ a.href = "https://lightpanda.io";
393- \\ document.body.appendChild(a);
394- \\ a.getClientRects();
395- , // Note this will be placed after the div of previous test
396- null ,
397- },
398- .{ "let a_again = document.elementFromPoint(1.5, 0.5)" , null },
399- .{ "a_again" , "[object HTMLAnchorElement]" },
400- .{ "a_again.href" , "https://lightpanda.io" },
401- .{ "let a_agains = document.elementsFromPoint(1.5, 0.5)" , null },
402- .{ "a_agains[0].href" , "https://lightpanda.io" },
403- }, .{});
404-
405- try runner .testCases (&.{
406- .{ "!document.all" , "true" },
407- .{ "!!document.all" , "false" },
408- .{ "document.all(5)" , "[object HTMLParagraphElement]" },
409- .{ "document.all('content')" , "[object HTMLDivElement]" },
410- }, .{});
411-
412- try runner .testCases (&.{
413- .{ "document.defaultView.document == document" , "true" },
414- }, .{});
415-
416- try runner .testCases (&.{
417- .{ "document.readyState" , "loading" },
418- }, .{});
419-
420- try HTMLDocument .documentIsLoaded (runner .page .window .document , runner .page );
421- try runner .testCases (&.{
422- .{ "document.readyState" , "interactive" },
423- }, .{});
424-
425- try HTMLDocument .documentIsComplete (runner .page .window .document , runner .page );
426- try runner .testCases (&.{
427- .{ "document.readyState" , "complete" },
428- }, .{});
318+ test "Browser: HTML.Document" {
319+ try testing .htmlRunner ("html/document.html" );
429320}
0 commit comments