diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/base/test/test_encodeToStringWithMaxLength.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/test_encodeToStringWithMaxLength.html')
-rw-r--r-- | dom/base/test/test_encodeToStringWithMaxLength.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/base/test/test_encodeToStringWithMaxLength.html b/dom/base/test/test_encodeToStringWithMaxLength.html new file mode 100644 index 0000000000..c3d6f509e3 --- /dev/null +++ b/dom/base/test/test_encodeToStringWithMaxLength.html @@ -0,0 +1,60 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=995321 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 995321 - encodeToStringWithMaxLength</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="application/javascript"> + function getEncoder() { + // Create a plaintext encoder without flags. + var encoder = SpecialPowers.Cu.createDocumentEncoder("text/plain"); + encoder.init(document, "text/plain", 0); + return encoder; + } + + function testPlaintextSerializerWithMaxLength() { + var string = getEncoder().encodeToString(); + + var shorterString = getEncoder().encodeToStringWithMaxLength(1); + ok(shorterString.length < 1 + 72, + "test length is in the expected range after limiting the length to 1"); + ok(string.startsWith(shorterString.trimRight()), + "the shorter string has the expected content"); + + shorterString = getEncoder().encodeToStringWithMaxLength(300); + ok(shorterString.length < 300 + 72, + "test length is in the expected range after limiting the length to 300"); + ok(string.startsWith(shorterString.trimRight()), + "the shorter string has the expected content"); + + is(getEncoder().encodeToStringWithMaxLength(0), string, + "limiting the length to 0 should be ignored"); + + is(getEncoder().encodeToStringWithMaxLength(10000), string, + "limiting the length to a huge value should return the whole page"); + + SimpleTest.finish(); + } + + addLoadEvent(testPlaintextSerializerWithMaxLength); + SimpleTest.waitForExplicitFinish(); + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=995321">Mozilla Bug 995321</a> +<p id="display"></p> +<div id="content" style="display: none"> +The <em>Mozilla</em> project is a global community of <strong>people</strong> who believe that openness, innovation, and opportunity are key to the continued health of the Internet. We have worked together since 1998 to ensure that the Internet is developed in a way that benefits everyone. We are best known for creating the Mozilla Firefox web browser. + +The Mozilla project uses a community-based approach to create world-class open source software and to develop new types of collaborative activities. We create communities of people involved in making the Internet experience better for all of us. + +As a result of these efforts, we have distilled a set of principles that we believe are critical for the Internet to continue to benefit the public good as well as commercial aspects of life. We set out these principles below. +</div> +<pre id="test"> +</pre> +</body> +</html> |