Bug 1726374 - Correctly highlight <!-- a <!-->b in View Source. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D123061
This commit is contained in:
Henri Sivonen 2021-08-19 13:00:25 +00:00
parent b968f7a794
commit 974eddfb01
6 changed files with 7 additions and 2 deletions

View File

@ -289,6 +289,7 @@ int32_t nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume,
case nsHtml5Tokenizer::COMMENT_START_DASH:
case nsHtml5Tokenizer::BOGUS_COMMENT:
case nsHtml5Tokenizer::BOGUS_COMMENT_HYPHEN:
case nsHtml5Tokenizer::COMMENT_LESSTHAN_BANG_DASH_DASH:
if (aState == nsHtml5Tokenizer::DATA) {
AddClass(sComment);
FinishTag();

View File

@ -1,4 +1,4 @@
<html><head><meta name="viewport" content="width=device-width"><title>file:///opt/Projects/gecko/parser/htmlparser/tests/reftest/bug1319410-1.html</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
<html><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
<span id="line2"></span></span><span class="comment">&lt;!-- -- --&gt;</span><span>
<span id="line3"></span></span><span class="error comment" title="Saw “<!--” within a comment. Probable cause: Nested comment (not allowed).">&lt;!-- &lt;!-- --&gt;</span><span> --&gt;
<span id="line4"></span></span><span class="error comment" title="Premature end of comment. Use “-->” to end a comment properly.">&lt;!--&gt;</span><span>

View File

@ -1,4 +1,4 @@
<html><head><meta name="viewport" content="width=device-width"><title>file:///opt/Projects/gecko/parser/htmlparser/tests/reftest/bug1650087-1.html</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
<html><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
<span id="line2"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">td</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>
<span id="line3"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">tr</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>
<span id="line4"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">thead</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>

View File

@ -0,0 +1,2 @@
<html><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span></span><span class="comment">&lt;!-- a &lt;!--&gt;</span><span>b
<span id="line2"></span></span></pre></body></html>

View File

@ -0,0 +1 @@
<!DOCTYPE html><!-- a <!-->b

View File

@ -28,3 +28,4 @@ random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == view-source:bug673094-1.
== bug1636607-2.html bug1636607-2-ref.html
== view-source:bug1319410-1.html bug1319410-1-ref.html
== view-source:bug1650087-1.html bug1650087-1-ref.html
== view-source:bug1726374-1.html bug1726374-1-ref.html