From 257a7c3bf5c1865463c13e343fe0ce8a2a807aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 6 Feb 2024 22:23:51 +0100 Subject: [PATCH 1/2] Add tests for `-->` in the first line --- .../single-line-html-close-first-line-1.js | 22 +++++++++++++++++++ .../single-line-html-close-first-line-2.js | 22 +++++++++++++++++++ .../single-line-html-close-first-line-3.js | 22 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 test/annexB/language/comments/single-line-html-close-first-line-1.js create mode 100644 test/annexB/language/comments/single-line-html-close-first-line-2.js create mode 100644 test/annexB/language/comments/single-line-html-close-first-line-3.js diff --git a/test/annexB/language/comments/single-line-html-close-first-line-1.js b/test/annexB/language/comments/single-line-html-close-first-line-1.js new file mode 100644 index 00000000000..faf72f91d67 --- /dev/null +++ b/test/annexB/language/comments/single-line-html-close-first-line-1.js @@ -0,0 +1,22 @@ +--> a comment + +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +description: > + A SingleLineHTMLCloseComment is allowed in the first line +flags: [raw] +info: | + InputElementHashbangOrRegExp :: + WhiteSpace + LineTerminator + Comment + CommonToken + HashbangComment + RegularExpressionLiteral + HTMLCloseComment + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +---*/ diff --git a/test/annexB/language/comments/single-line-html-close-first-line-2.js b/test/annexB/language/comments/single-line-html-close-first-line-2.js new file mode 100644 index 00000000000..2d59c51e2db --- /dev/null +++ b/test/annexB/language/comments/single-line-html-close-first-line-2.js @@ -0,0 +1,22 @@ + --> a comment + +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +description: > + A SingleLineHTMLCloseComment is allowed in the first line when preceeded by spaces +flags: [raw] +info: | + InputElementHashbangOrRegExp :: + WhiteSpace + LineTerminator + Comment + CommonToken + HashbangComment + RegularExpressionLiteral + HTMLCloseComment + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +---*/ diff --git a/test/annexB/language/comments/single-line-html-close-first-line-3.js b/test/annexB/language/comments/single-line-html-close-first-line-3.js new file mode 100644 index 00000000000..11197d46144 --- /dev/null +++ b/test/annexB/language/comments/single-line-html-close-first-line-3.js @@ -0,0 +1,22 @@ +/* a comment */ /*another comment*/--> a comment + +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +description: > + A SingleLineHTMLCloseComment is allowed in the first line when preceeded by spaces and single-line block comments +flags: [raw] +info: | + InputElementHashbangOrRegExp :: + WhiteSpace + LineTerminator + Comment + CommonToken + HashbangComment + RegularExpressionLiteral + HTMLCloseComment + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +---*/ From 3c4e1cec658d212a361bc7e765a89cbda7f476dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 6 Feb 2024 22:42:26 +0100 Subject: [PATCH 2/2] Improve test robustness --- .../comments/single-line-html-close-first-line-1.js | 12 ++++++++++++ .../comments/single-line-html-close-first-line-2.js | 12 ++++++++++++ .../comments/single-line-html-close-first-line-3.js | 12 ++++++++++++ 3 files changed, 36 insertions(+) diff --git a/test/annexB/language/comments/single-line-html-close-first-line-1.js b/test/annexB/language/comments/single-line-html-close-first-line-1.js index faf72f91d67..708e42e4aea 100644 --- a/test/annexB/language/comments/single-line-html-close-first-line-1.js +++ b/test/annexB/language/comments/single-line-html-close-first-line-1.js @@ -19,4 +19,16 @@ info: | HTMLCloseComment :: WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: + phase: runtime + type: Test262Error ---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. +throw new Test262Error("This is not in a comment"); diff --git a/test/annexB/language/comments/single-line-html-close-first-line-2.js b/test/annexB/language/comments/single-line-html-close-first-line-2.js index 2d59c51e2db..0b68aa0f6f5 100644 --- a/test/annexB/language/comments/single-line-html-close-first-line-2.js +++ b/test/annexB/language/comments/single-line-html-close-first-line-2.js @@ -19,4 +19,16 @@ info: | HTMLCloseComment :: WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: + phase: runtime + type: Test262Error ---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. +throw new Test262Error("This is not in a comment"); diff --git a/test/annexB/language/comments/single-line-html-close-first-line-3.js b/test/annexB/language/comments/single-line-html-close-first-line-3.js index 11197d46144..d638fd5080d 100644 --- a/test/annexB/language/comments/single-line-html-close-first-line-3.js +++ b/test/annexB/language/comments/single-line-html-close-first-line-3.js @@ -19,4 +19,16 @@ info: | HTMLCloseComment :: WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: + phase: runtime + type: Test262Error ---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. +throw new Test262Error("This is not in a comment");