diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/html/dom/documents/resource-metadata-management | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/dom/documents/resource-metadata-management')
11 files changed, 286 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-01.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-01.html new file mode 100644 index 0000000000..218a3fe843 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-01.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<title>document.compatMode: Standards</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"> +<body> +<div id="log"></div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + assert_equals(document.compatMode, "CSS1Compat"); +}) +</script> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-02.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-02.html new file mode 100644 index 0000000000..6da40d61ee --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-02.html @@ -0,0 +1,14 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<title>document.compatMode: Almost standards</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"> +<body> +<div id="log"></div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + assert_equals(document.compatMode, "CSS1Compat"); +}) +</script> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-03.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-03.html new file mode 100644 index 0000000000..3d55d6e835 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-03.html @@ -0,0 +1,12 @@ +<title>document.compatMode: Quirks</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"> +<body> +<div id="log"></div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + assert_equals(document.compatMode, "BackCompat"); +}) +</script> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-04.xhtml b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-04.xhtml new file mode 100644 index 0000000000..a71c1d9dd3 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-04.xhtml @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>document.compatMode: Standards</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"/> +</head> +<body> +<div id="log"></div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + assert_equals(document.compatMode, "CSS1Compat"); +}) +</script> +</body> +</html> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-05.xhtml b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-05.xhtml new file mode 100644 index 0000000000..3fde06e5af --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-05.xhtml @@ -0,0 +1,19 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>document.compatMode: Standards</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"/> +</head> +<body> +<div id="log"></div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + assert_equals(document.compatMode, "CSS1Compat"); +}) +</script> +</body> +</html> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-06.xhtml b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-06.xhtml new file mode 100644 index 0000000000..eb64dfb90e --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-06.xhtml @@ -0,0 +1,17 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>document.compatMode: Standards</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"/> +</head> +<body> +<div id="log"></div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + assert_equals(document.compatMode, "CSS1Compat"); +}) +</script> +</body> +</html> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-cookie.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-cookie.html new file mode 100644 index 0000000000..2af65effeb --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-cookie.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>document.cookie</title> +<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> +<link rel=help href="https://html.spec.whatwg.org/multipage/#resource-metadata-management"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +const TEST_CASES = [ + {value: "", expected: "", test: "Empty value"}, + {value: "a=b", expected: "a=b", test: "A simple cookie"}, + {value: "b=A\0Z", expected: "", test: "A null char"}, +]; + +test(function(){ + assert_equals(document.cookie, ""); +}, "document has no cookie"); + +for (const i in TEST_CASES) { + const t = TEST_CASES[i]; + test(() => { + document.cookie = t.value; + assert_equals(document.cookie, t.expected); + + // Cleanup + if (document.cookie.includes("=")) { + document.cookie = document.cookie.split("=")[0] + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC"; + assert_equals(document.cookie, ""); + } + }, t.name); +} + +test(function(){ + var doc = document.implementation.createHTMLDocument("doc"); + assert_equals(doc.cookie, ""); + doc.cookie = "test=foobar"; + assert_equals(doc.cookie, ""); +}, "getting cookie for a cookie-averse document returns empty string, setting does nothing"); +</script> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified-01.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified-01.html new file mode 100644 index 0000000000..4d9d870f6a --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified-01.html @@ -0,0 +1,103 @@ +<!DOCTYPE html> +<title>document.lastModified should return current local time</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + var last_modified = document.lastModified; + + var pattern = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/; + + test(function() { + assert_regexp_match(last_modified, pattern, + "Format should match the pattern \"NN/NN/NNNN NN:NN:NN\"."); + }, "Date returned by lastModified is in the form \"MM/DD/YYYY hh:mm:ss\"."); + + function assert_date_string_approximately_now(str) { + // We want to test that |str| was a time in the user's local + // timezone generated within a few seconds prior to the present. + // This requires some care, since it is possible that: + // - the few second difference may have crossed a + // year/month/day/hour/minute boundary + // - the few second difference may have crossed a change in the + // local timezone's UTC offset + // - the local time might be one that has multiple valid UTC + // representations (for example, because it's in the hour + // following a shift from summer time to winter time) + // We will make some assumptions to do this: + // - local time's UTC offset doesn't change more than once per + // minute + // - local time's UTC offset only changes by integral numbers of + // minutes + + // The date must be equal to or earlier than the present time. + var dmax = new Date(); + + // The date must be equal to or later than 2.5 seconds ago. + var TOLERANCE_MILLISECONDS = 2500; + var dmin = new Date(); + dmin.setTime(dmax.getTime() - TOLERANCE_MILLISECONDS); + + // Extract the year/month/date/hours/minutes/seconds from str. It + // is important that we do *not* try to construct a Date object from + // these, since the core of the date object is a timestamp in UTC, + // and there are cases (such as the hour on each side of a change + // from summer time to winter time) where there are multiple + // possible UTC timestamps for a given YYYY-MM-DD HH:MM:SS, and + // constructing a Date object would pick one of them, which might be + // the wrong one. However, we already have the right one in dmin + // and dmax, so we should instead extract local time from those + // rather than converting these values to UTC. + var m = pattern.exec(str); + var syear = Number(m[3]); + var smonth = Number(m[1]) - 1; // match Javascript 0-based months + var sdate = Number(m[2]); + var shours = Number(m[4]); + var sminutes = Number(m[5]); + var sseconds = Number(m[6]); + + if (dmin.getFullYear() == dmax.getFullYear() && + dmin.getMonth() == dmax.getMonth() && + dmin.getDate() == dmax.getDate() && + dmin.getHours() == dmax.getHours() && + dmin.getMinutes() == dmax.getMinutes()) { + // min and max have the same minute + assert_equals(smonth, dmin.getMonth(), "month"); + assert_equals(sdate, dmin.getDate(), "date"); + assert_equals(syear, dmin.getFullYear(), "year"); + assert_equals(shours, dmin.getHours(), "hours"); + assert_equals(sminutes, dmin.getMinutes(), "minutes"); + assert_true(dmin.getSeconds() <= sseconds && + sseconds <= dmax.getSeconds(), "seconds"); + } else if (dmin.getFullYear() == syear && + dmin.getMonth() == smonth && + dmin.getDate() == sdate && + dmin.getHours() == shours && + dmin.getMinutes() == sminutes) { + // actual value has the same minute as min + assert_true(dmin.getSeconds() <= sseconds, "dmin.getSeconds() <= sseconds"); + assert_true(57 <= dmin.getSeconds(), "unexpected local time rules (dmin match)"); + } else if (dmax.getFullYear() == syear && + dmax.getMonth() == smonth && + dmax.getDate() == sdate && + dmax.getHours() == shours && + dmax.getMinutes() == sminutes) { + // actual value has the same minute as max + assert_true(sseconds <= dmax.getSeconds(), "sseconds <= dmax.getSeconds()"); + assert_true(dmax.getSeconds() <= 2, "unexpected local time rules (dmax match)"); + } else { + assert_unreached("unexpected local time rules (no match)"); + } + } + + test(function() { + assert_date_string_approximately_now(last_modified); + }, "Date returned by lastModified is current at page load"); + + var t = async_test("Date returned by lastModified is current after timeout."); + t.step_timeout(function() { + assert_date_string_approximately_now(document.lastModified); + t.done(); + }, 4000); +</script> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html new file mode 100644 index 0000000000..9e0a07d8eb --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>document.lastModified</title> +<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> +<link rel=help href="https://html.spec.whatwg.org/multipage/#resource-metadata-management"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + test(function(){ + var date = new Date("Thu, 01 Jan 1970 01:23:45 GMT"); + var result = ('0' + (date.getMonth()+1)).slice(-2) + '/' + ('0' + date.getDate()).slice(-2) + '/' + date.getFullYear() + " " + [date.getHours(),date.getMinutes(),date.getSeconds()].map(function(n){return ("0" + n).slice(-2);}).join(":"); + assert_equals(document.lastModified, result); + }, "lastModified should return the last modified date and time"); +</script> diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html.headers b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html.headers new file mode 100644 index 0000000000..377e3b52dc --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html.headers @@ -0,0 +1 @@ +Last-Modified: Thu, 01 Jan 1970 01:23:45 GMT diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-readyState.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-readyState.html new file mode 100644 index 0000000000..8c91e0a001 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-readyState.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>document.readyState</title> +<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> +<link rel=help href="https://html.spec.whatwg.org/multipage/#resource-metadata-management"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + var t1 = async_test("readyState equals 'complete' when the document has loaded"), + t2 = async_test("readyState equals 'interactive' when the document is finished parsing"), + t3 = async_test("readystatechange event is fired each time document.readyState changes"); + + window.onload = t1.step_func_done(function(){ + assert_equals(document.readyState, "complete"); + }); + + document.addEventListener("DOMContentLoaded", function(event) { + t2.step(function() { + assert_equals(document.readyState, "interactive") + }); + t2.done(); + }); + + var states = [document.readyState]; + document.onreadystatechange = t3.step_func(function(){ + states.push(document.readyState); + if (document.readyState === "complete") { + assert_array_equals(states, ["loading", "interactive", "complete"]); + t3.done(); + } + }) +</script> |