<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[169360] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169360">169360</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-05-26 14:45:17 -0700 (Mon, 26 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix the quirks mode selector matching of the pseudo classes :hover and :active
https://bugs.webkit.org/show_bug.cgi?id=133063

Reviewed by Antti Koivisto.


Source/WebCore: 
Our implementation of the quirks mode of :active and :hover was very wrong. The only
thing it was doing is verify the pseudo class is not the first selector of a fragment
(which was conveniently the only thing that was tested :)).

Since those pseudo class were only checking for the order of the filters, something like
    #target:hover
would succeed because :hover is not the first simple selector, while
    :hover#target
would fail.

That behavior is also a problem for the CSS JIT as it is an implementation detail of SelectorChecker
and compiling something like that with our out-of-order matching would be nonsense.

This patch update the implementation to follow http://quirks.spec.whatwg.org/#the-:active-and-:hover-quirk
Basically, the only cases that do not work in quirks mode are selectors composed only of &quot;*, :hover and :active&quot;.

To implement this behavior, I needed to be able to inspect a complete selector fragment, including
what is before and after :hover/:active.
To do that, I replaced the boolean isSubSelector by a pointer to the first selector of the fragment.
When we need to match :active/:hover in quirks mode, we just go over all the selectors in the fragment
to find one of the qualifying match type.

Tests: fast/selectors/active-hover-quirks.html
       fast/selectors/active-quirks.html
       fast/selectors/hover-quirks.html

* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchRecursively):
(WebCore::canMatchHoverOrActiveInQuirksMode):
(WebCore::SelectorChecker::checkOne):
* css/SelectorChecker.h:
(WebCore::SelectorChecker::SelectorCheckingContext::SelectorCheckingContext):

LayoutTests: 
The test coverage of :hover and :active was extremly poor.
Those new tests add coverage for the cases fixed by this patch.

* fast/selectors/active-hover-quirks-expected.txt: Added.
* fast/selectors/active-hover-quirks.html: Added.
* fast/selectors/active-hover-strict-expected.txt: Added.
* fast/selectors/active-hover-strict.html: Added.
* fast/selectors/active-quirks-expected.txt: Added.
* fast/selectors/active-quirks.html: Added.
* fast/selectors/active-strict-expected.txt: Added.
* fast/selectors/active-strict.html: Added.
* fast/selectors/hover-quirks-expected.txt: Added.
* fast/selectors/hover-quirks.html: Added.
* fast/selectors/hover-strict-expected.txt: Added.
* fast/selectors/hover-strict.html: Added.
* fast/selectors/resources/hover-active-quirks-utility.js: Added.
* selectors/resources/hover-active-strict-utility.js: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckercpp">trunk/Source/WebCore/css/SelectorChecker.cpp</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckerh">trunk/Source/WebCore/css/SelectorChecker.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastselectorsactivehoverquirksexpectedtxt">trunk/LayoutTests/fast/selectors/active-hover-quirks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsactivehoverquirkshtml">trunk/LayoutTests/fast/selectors/active-hover-quirks.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsactivehoverstrictexpectedtxt">trunk/LayoutTests/fast/selectors/active-hover-strict-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsactivehoverstricthtml">trunk/LayoutTests/fast/selectors/active-hover-strict.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsactivequirksexpectedtxt">trunk/LayoutTests/fast/selectors/active-quirks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsactivequirkshtml">trunk/LayoutTests/fast/selectors/active-quirks.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsactivestrictexpectedtxt">trunk/LayoutTests/fast/selectors/active-strict-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsactivestricthtml">trunk/LayoutTests/fast/selectors/active-strict.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorshoverquirksexpectedtxt">trunk/LayoutTests/fast/selectors/hover-quirks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorshoverquirkshtml">trunk/LayoutTests/fast/selectors/hover-quirks.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorshoverstrictexpectedtxt">trunk/LayoutTests/fast/selectors/hover-strict-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorshoverstricthtml">trunk/LayoutTests/fast/selectors/hover-strict.html</a></li>
<li>trunk/LayoutTests/fast/selectors/resources/</li>
<li><a href="#trunkLayoutTestsfastselectorsresourceshoveractivequirksutilityjs">trunk/LayoutTests/fast/selectors/resources/hover-active-quirks-utility.js</a></li>
<li><a href="#trunkLayoutTestsfastselectorsresourceshoveractivestrictutilityjs">trunk/LayoutTests/fast/selectors/resources/hover-active-strict-utility.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (169359 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-05-26 20:18:25 UTC (rev 169359)
+++ trunk/LayoutTests/ChangeLog        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-05-26  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        Fix the quirks mode selector matching of the pseudo classes :hover and :active
+        https://bugs.webkit.org/show_bug.cgi?id=133063
+
+        Reviewed by Antti Koivisto.
+
+        The test coverage of :hover and :active was extremly poor.
+        Those new tests add coverage for the cases fixed by this patch.
+
+        * fast/selectors/active-hover-quirks-expected.txt: Added.
+        * fast/selectors/active-hover-quirks.html: Added.
+        * fast/selectors/active-hover-strict-expected.txt: Added.
+        * fast/selectors/active-hover-strict.html: Added.
+        * fast/selectors/active-quirks-expected.txt: Added.
+        * fast/selectors/active-quirks.html: Added.
+        * fast/selectors/active-strict-expected.txt: Added.
+        * fast/selectors/active-strict.html: Added.
+        * fast/selectors/hover-quirks-expected.txt: Added.
+        * fast/selectors/hover-quirks.html: Added.
+        * fast/selectors/hover-strict-expected.txt: Added.
+        * fast/selectors/hover-strict.html: Added.
+        * fast/selectors/resources/hover-active-quirks-utility.js: Added.
+        * selectors/resources/hover-active-strict-utility.js: Added.
+
</ins><span class="cx"> 2014-05-26  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Class name matching should use ASCII case-insensitive matching, not Unicode case folding
</span></span></pre></div>
<a id="trunkLayoutTestsfastselectorsactivehoverquirksexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/active-hover-quirks-expected.txt (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/active-hover-quirks-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/active-hover-quirks-expected.txt        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,101 @@
</span><ins>+Test the :active:hover selector when the document is in quirks mode. To test manually, move the cursor over the green rectangle and press a mouse button until the test is finished.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;:active:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;*:active:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:hover:active:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:hover:active:hover:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:active:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:active:hover:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;div:active:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:active:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:active:hover#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:active:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover.aClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:active:hover.otherClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id]:active:hover[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id=target]:active:hover[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id^=ta]:active:hover[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id$=et]:active:hover[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id*=rg]:active:hover[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id~=target]:active:hover[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id|=target]:active:hover[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):active:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):active:hover:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:hover &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:hover:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:hover #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:hover:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:-webkit-any(:active:hover) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsactivehoverquirkshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/active-hover-quirks.html (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/active-hover-quirks.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/active-hover-quirks.html        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/hover-active-quirks-utility.js&quot;&gt;&lt;/script&gt;
+&lt;style id=&quot;testStyle&quot;&gt;
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;target&quot; class=&quot;aClass otherClass&quot; webkit=&quot;rocks&quot; style=&quot;background-color:green; width:200px; height:200px;&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the :active:hover selector when the document is in quirks mode. To test manually, move the cursor over the green rectangle and press a mouse button until the test is finished.');
+
+
+if (window.eventSender) {
+    var target = document.getElementById('target');
+    var x = target.offsetLeft + target.offsetWidth / 2;
+    var y = target.offsetTop + target.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    test(':active:hover');
+    eventSender.mouseUp()
+} else {
+    // For some reasons, the test does not work well without the timeout on Firefox.
+    var target = document.getElementById('target');
+    target.addEventListener('mousedown', function() { setTimeout(test, 250, ':active:hover'); });
+}
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsactivehoverstrictexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/active-hover-strict-expected.txt (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/active-hover-strict-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/active-hover-strict-expected.txt        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+Test the :active:hover selector when the document is in strict mode. To test manually, move the cursor over the green rectangle and press a mouse button until the test is finished.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;div:active:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:active:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:active:hover#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:active:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover.aClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:active:hover.otherClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id]:active:hover[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id=target]:active:hover[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id^=ta]:active:hover[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id$=et]:active:hover[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id*=rg]:active:hover[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id~=target]:active:hover[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id|=target]:active:hover[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):active:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):active:hover:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:hover &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:hover:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:hover #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:hover:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:-webkit-any(:active:hover) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:hover&quot;).length is 3
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;*:active:hover&quot;).length is 3
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsactivehoverstricthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/active-hover-strict.html (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/active-hover-strict.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/active-hover-strict.html        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/hover-active-strict-utility.js&quot;&gt;&lt;/script&gt;
+&lt;style id=&quot;testStyle&quot;&gt;
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;target&quot; class=&quot;aClass otherClass&quot; webkit=&quot;rocks&quot; style=&quot;background-color:green; width:200px; height:200px;&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the :active:hover selector when the document is in strict mode. To test manually, move the cursor over the green rectangle and press a mouse button until the test is finished.');
+
+if (window.eventSender) {
+    var target = document.getElementById('target');
+    var x = target.offsetLeft + target.offsetWidth / 2;
+    var y = target.offsetTop + target.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    test(':active:hover');
+    eventSender.mouseUp()
+} else {
+    // For some reasons, the test does not work well without the timeout on Firefox.
+    var target = document.getElementById('target');
+    target.addEventListener('mousedown', function() { setTimeout(test, 250, ':active:hover'); });
+}
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsactivequirksexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/active-quirks-expected.txt (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/active-quirks-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/active-quirks-expected.txt        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,101 @@
</span><ins>+Test the :active selector when the document is in quirks mode. To test manually, move the cursor over the green rectangle and press a mouse button until the test is finished.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;*:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:hover:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:hover:active:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:active:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;div:active&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:active&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:active#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:active&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active.aClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:active.otherClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id]:active[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id=target]:active[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id^=ta]:active[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id$=et]:active[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id*=rg]:active[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id~=target]:active[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id|=target]:active[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):active&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):active:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:-webkit-any(:active) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsactivequirkshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/active-quirks.html (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/active-quirks.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/active-quirks.html        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/hover-active-quirks-utility.js&quot;&gt;&lt;/script&gt;
+&lt;style id=&quot;testStyle&quot;&gt;
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;target&quot; class=&quot;aClass otherClass&quot; webkit=&quot;rocks&quot; style=&quot;background-color:green; width:200px; height:200px;&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the :active selector when the document is in quirks mode. To test manually, move the cursor over the green rectangle and press a mouse button until the test is finished.');
+
+
+if (window.eventSender) {
+    var target = document.getElementById('target');
+    var x = target.offsetLeft + target.offsetWidth / 2;
+    var y = target.offsetTop + target.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    test(':active');
+    eventSender.mouseUp()
+} else {
+    // For some reasons, the test does not work well without the timeout on Firefox.
+    var target = document.getElementById('target');
+    target.addEventListener('mousedown', function() { setTimeout(test, 250, ':active'); });
+}
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsactivestrictexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/active-strict-expected.txt (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/active-strict-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/active-strict-expected.txt        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+Test the :active selector when the document is in strict mode. To test manually, move the cursor over the green rectangle and press a mouse button until the test is finished.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;div:active&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:active&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:active#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:active&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active.aClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:active.otherClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id]:active[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id=target]:active[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id^=ta]:active[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id$=et]:active[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id*=rg]:active[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id~=target]:active[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id|=target]:active[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):active&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):active:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):active:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:-webkit-any(:active) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:active&quot;).length is 3
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;*:active&quot;).length is 3
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsactivestricthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/active-strict.html (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/active-strict.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/active-strict.html        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/hover-active-strict-utility.js&quot;&gt;&lt;/script&gt;
+&lt;style id=&quot;testStyle&quot;&gt;
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;target&quot; class=&quot;aClass otherClass&quot; webkit=&quot;rocks&quot; style=&quot;background-color:green; width:200px; height:200px;&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the :active selector when the document is in strict mode. To test manually, move the cursor over the green rectangle and press a mouse button until the test is finished.');
+
+if (window.eventSender) {
+    var target = document.getElementById('target');
+    var x = target.offsetLeft + target.offsetWidth / 2;
+    var y = target.offsetTop + target.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    test(':active');
+    eventSender.mouseUp()
+} else {
+    // For some reasons, the test does not work well without the timeout on Firefox.
+    var target = document.getElementById('target');
+    target.addEventListener('mousedown', function() { setTimeout(test, 250, ':active'); });
+}
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorshoverquirksexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/hover-quirks-expected.txt (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/hover-quirks-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/hover-quirks-expected.txt        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,101 @@
</span><ins>+Test the :hover selector when the document is in quirks mode. To test manually, move the cursor over the green rectangle and reload the page.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;*:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:hover:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:hover:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:hover:hover:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:hover:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:hover&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;:active:hover:active&quot;).length is 0
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(1, 2, 3)&quot;
+PASS document.querySelectorAll(&quot;div:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:hover#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover.aClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:hover.otherClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id]:hover[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id=target]:hover[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id^=ta]:hover[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id$=et]:hover[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id*=rg]:hover[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id~=target]:hover[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id|=target]:hover[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):hover:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):hover &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):hover:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):hover #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):hover:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:-webkit-any(:hover) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorshoverquirkshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/hover-quirks.html (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/hover-quirks.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/hover-quirks.html        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/hover-active-quirks-utility.js&quot;&gt;&lt;/script&gt;
+&lt;style id=&quot;testStyle&quot;&gt;
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;target&quot; class=&quot;aClass otherClass&quot; webkit=&quot;rocks&quot; style=&quot;background-color:green; width:200px; height:200px;&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the :hover selector when the document is in quirks mode. To test manually, move the cursor over the green rectangle and reload the page.');
+
+if (window.eventSender) {
+    var target = document.getElementById('target');
+    var x = target.offsetLeft + target.offsetWidth / 2;
+    var y = target.offsetTop + target.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    test(':hover');
+} else {
+    // To test manually, wait a bit to make sure the browers has updated its state, then run the tests.
+    setTimeout(test, 250, ':hover');
+}
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorshoverstrictexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/hover-strict-expected.txt (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/hover-strict-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/hover-strict-expected.txt        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+Test the :hover selector when the document is in strict mode. To test manually, move the cursor over the green rectangle and reload the page.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;div:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;#target:hover#target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover.aClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass:hover.otherClass&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id]:hover[webkit]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id=target]:hover[webkit=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id^=ta]:hover[webkit^=ro]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id$=et]:hover[webkit$=ks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id*=rg]:hover[webkit*=ck]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id~=target]:hover[webkit~=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;.aClass[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;[id|=target]:hover[webkit|=rocks]&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):hover&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(1):hover:nth-child(1)&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):hover &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):hover:nth-child(n) &gt; #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):hover #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:nth-child(n):hover:nth-child(n) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:-webkit-any(:hover) #target&quot;).length is 1
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;:hover&quot;).length is 3
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS document.querySelectorAll(&quot;*:hover&quot;).length is 3
+PASS getComputedStyle(document.getElementById(&quot;target&quot;)).color is &quot;rgb(4, 5, 6)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorshoverstricthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/hover-strict.html (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/hover-strict.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/hover-strict.html        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/hover-active-strict-utility.js&quot;&gt;&lt;/script&gt;
+&lt;style id=&quot;testStyle&quot;&gt;
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;target&quot; class=&quot;aClass otherClass&quot; webkit=&quot;rocks&quot; style=&quot;background-color:green; width:200px; height:200px;&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test the :hover selector when the document is in strict mode. To test manually, move the cursor over the green rectangle and reload the page.');
+
+if (window.eventSender) {
+    var target = document.getElementById('target');
+    var x = target.offsetLeft + target.offsetWidth / 2;
+    var y = target.offsetTop + target.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    test(':hover');
+} else {
+    // To test manually, wait a bit to make sure the browers has updated its state, then run the tests.
+    setTimeout(test, 250, ':hover');
+}
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsresourceshoveractivequirksutilityjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/resources/hover-active-quirks-utility.js (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/resources/hover-active-quirks-utility.js                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/resources/hover-active-quirks-utility.js        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,93 @@
</span><ins>+var testCases = [
+    // The universal selector does not qualify the pseudo class.
+    [&quot;PLACEHOLDER&quot;, false],
+    [&quot;*PLACEHOLDER&quot;, false],
+
+    // Having :hover or :active does not qualify the pseudo class.
+    [&quot;PLACEHOLDER:hover&quot;, false],
+    [&quot;:hoverPLACEHOLDER&quot;, false],
+    [&quot;:hoverPLACEHOLDER:hover&quot;, false],
+    [&quot;PLACEHOLDER:active&quot;, false],
+    [&quot;:activePLACEHOLDER&quot;, false],
+    [&quot;:activePLACEHOLDER:active&quot;, false],
+
+    // Tag qualify the pseudo class.
+    [&quot;divPLACEHOLDER&quot;, true],
+
+    // Id qualify the pseudo class.
+    [&quot;#targetPLACEHOLDER&quot;, true],
+    [&quot;PLACEHOLDER#target&quot;, true],
+    [&quot;#targetPLACEHOLDER#target&quot;, true],
+
+    // Class qualify the pseudo class.
+    [&quot;.aClassPLACEHOLDER&quot;, true],
+    [&quot;PLACEHOLDER.aClass&quot;, true],
+    [&quot;.aClassPLACEHOLDER.otherClass&quot;, true],
+
+    // Any attribute filter qualify the pseudo class.
+    [&quot;.aClass[webkit]&quot;, true],
+    [&quot;PLACEHOLDER[webkit]&quot;, true],
+    [&quot;[id]PLACEHOLDER[webkit]&quot;, true],
+
+    [&quot;.aClass[webkit=rocks]&quot;, true],
+    [&quot;PLACEHOLDER[webkit=rocks]&quot;, true],
+    [&quot;[id=target]PLACEHOLDER[webkit=rocks]&quot;, true],
+
+    [&quot;.aClass[webkit^=ro]&quot;, true],
+    [&quot;PLACEHOLDER[webkit^=ro]&quot;, true],
+    [&quot;[id^=ta]PLACEHOLDER[webkit^=ro]&quot;, true],
+
+    [&quot;.aClass[webkit$=ks]&quot;, true],
+    [&quot;PLACEHOLDER[webkit$=ks]&quot;, true],
+    [&quot;[id$=et]PLACEHOLDER[webkit$=ks]&quot;, true],
+
+    [&quot;.aClass[webkit*=ck]&quot;, true],
+    [&quot;PLACEHOLDER[webkit*=ck]&quot;, true],
+    [&quot;[id*=rg]PLACEHOLDER[webkit*=ck]&quot;, true],
+
+    [&quot;.aClass[webkit~=rocks]&quot;, true],
+    [&quot;PLACEHOLDER[webkit~=rocks]&quot;, true],
+    [&quot;[id~=target]PLACEHOLDER[webkit~=rocks]&quot;, true],
+
+    [&quot;.aClass[webkit|=rocks]&quot;, true],
+    [&quot;PLACEHOLDER[webkit|=rocks]&quot;, true],
+    [&quot;[id|=target]PLACEHOLDER[webkit|=rocks]&quot;, true],
+
+    // A pseudo-class other than :active/:hover qualify the pseudo class.
+    [&quot;:nth-child(1)PLACEHOLDER&quot;, true],
+    [&quot;PLACEHOLDER:nth-child(1)&quot;, true],
+    [&quot;:nth-child(1)PLACEHOLDER:nth-child(1)&quot;, true],
+    // Same with child.
+    [&quot;:nth-child(n)PLACEHOLDER &gt; #target&quot;, true],
+    [&quot;PLACEHOLDER:nth-child(n) &gt; #target&quot;, true],
+    [&quot;:nth-child(n)PLACEHOLDER:nth-child(n) &gt; #target&quot;, true],
+    // Same with descendant.
+    [&quot;:nth-child(n)PLACEHOLDER #target&quot;, true],
+    [&quot;PLACEHOLDER:nth-child(n) #target&quot;, true],
+    [&quot;:nth-child(n)PLACEHOLDER:nth-child(n) #target&quot;, true],
+
+    [&quot;:-webkit-any(PLACEHOLDER) #target&quot;, true],
+];
+
+function testQuerySelector(selector, shouldMatch) {
+    shouldBe('document.querySelectorAll(&quot;' + selector + '&quot;).length', shouldMatch? '1' : '0');
+}
+
+function testStyling(selector, shouldMatch) {
+    var testStyle = document.getElementById('testStyle');
+    var noMatchStyle = &quot;rgb(1, 2, 3)&quot;;
+    var matchStyle = &quot;rgb(4, 5, 6)&quot;
+    testStyle.textContent = &quot;#target { color:&quot; + noMatchStyle + &quot; } &quot; + selector + &quot; { color:&quot; + matchStyle + &quot; !important }&quot;;
+
+    shouldBeEqualToString('getComputedStyle(document.getElementById(&quot;target&quot;)).color', shouldMatch ? matchStyle : noMatchStyle);
+
+    testStyle.textContent = &quot;&quot;;
+}
+
+function test(pseudoClass) {
+    for (var i = 0, length = testCases.length; i &lt; length; ++i) {
+        var selector = testCases[i][0].replace('PLACEHOLDER', pseudoClass)
+        testQuerySelector(selector, testCases[i][1]);
+        testStyling(selector, testCases[i][1]);
+    }
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsresourceshoveractivestrictutilityjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/resources/hover-active-strict-utility.js (0 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/resources/hover-active-strict-utility.js                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/resources/hover-active-strict-utility.js        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+// In strict mode, there is no restriction on when :hover or :active can match.
+var testCases = [
+    // Tag name.
+    [&quot;divPLACEHOLDER&quot;, true],
+
+    // Id.
+    [&quot;#targetPLACEHOLDER&quot;, true],
+    [&quot;PLACEHOLDER#target&quot;, true],
+    [&quot;#targetPLACEHOLDER#target&quot;, true],
+
+    // Class name.
+    [&quot;.aClassPLACEHOLDER&quot;, true],
+    [&quot;PLACEHOLDER.aClass&quot;, true],
+    [&quot;.aClassPLACEHOLDER.otherClass&quot;, true],
+
+    // Attribute filter.
+    [&quot;.aClass[webkit]&quot;, true],
+    [&quot;PLACEHOLDER[webkit]&quot;, true],
+    [&quot;[id]PLACEHOLDER[webkit]&quot;, true],
+
+    [&quot;.aClass[webkit=rocks]&quot;, true],
+    [&quot;PLACEHOLDER[webkit=rocks]&quot;, true],
+    [&quot;[id=target]PLACEHOLDER[webkit=rocks]&quot;, true],
+
+    [&quot;.aClass[webkit^=ro]&quot;, true],
+    [&quot;PLACEHOLDER[webkit^=ro]&quot;, true],
+    [&quot;[id^=ta]PLACEHOLDER[webkit^=ro]&quot;, true],
+
+    [&quot;.aClass[webkit$=ks]&quot;, true],
+    [&quot;PLACEHOLDER[webkit$=ks]&quot;, true],
+    [&quot;[id$=et]PLACEHOLDER[webkit$=ks]&quot;, true],
+
+    [&quot;.aClass[webkit*=ck]&quot;, true],
+    [&quot;PLACEHOLDER[webkit*=ck]&quot;, true],
+    [&quot;[id*=rg]PLACEHOLDER[webkit*=ck]&quot;, true],
+
+    [&quot;.aClass[webkit~=rocks]&quot;, true],
+    [&quot;PLACEHOLDER[webkit~=rocks]&quot;, true],
+    [&quot;[id~=target]PLACEHOLDER[webkit~=rocks]&quot;, true],
+
+    [&quot;.aClass[webkit|=rocks]&quot;, true],
+    [&quot;PLACEHOLDER[webkit|=rocks]&quot;, true],
+    [&quot;[id|=target]PLACEHOLDER[webkit|=rocks]&quot;, true],
+
+    // Pseudo-class other than :active/:hover.
+    [&quot;:nth-child(1)PLACEHOLDER&quot;, true],
+    [&quot;PLACEHOLDER:nth-child(1)&quot;, true],
+    [&quot;:nth-child(1)PLACEHOLDER:nth-child(1)&quot;, true],
+    // Same with child relation.
+    [&quot;:nth-child(n)PLACEHOLDER &gt; #target&quot;, true],
+    [&quot;PLACEHOLDER:nth-child(n) &gt; #target&quot;, true],
+    [&quot;:nth-child(n)PLACEHOLDER:nth-child(n) &gt; #target&quot;, true],
+    // Same with descendant relation.
+    [&quot;:nth-child(n)PLACEHOLDER #target&quot;, true],
+    [&quot;PLACEHOLDER:nth-child(n) #target&quot;, true],
+    [&quot;:nth-child(n)PLACEHOLDER:nth-child(n) #target&quot;, true],
+
+    [&quot;:-webkit-any(PLACEHOLDER) #target&quot;, true],
+];
+
+function testQuerySelector(selector, shouldMatch) {
+    shouldBe('document.querySelectorAll(&quot;' + selector + '&quot;).length', shouldMatch? '1' : '0');
+}
+
+function testStyling(selector, shouldMatch) {
+    var testStyle = document.getElementById('testStyle');
+    var noMatchStyle = &quot;rgb(1, 2, 3)&quot;;
+    var matchStyle = &quot;rgb(4, 5, 6)&quot;
+    testStyle.textContent = &quot;#target { color:&quot; + noMatchStyle + &quot; } &quot; + selector + &quot; { color:&quot; + matchStyle + &quot; !important }&quot;;
+
+    shouldBeEqualToString('getComputedStyle(document.getElementById(&quot;target&quot;)).color', shouldMatch ? matchStyle : noMatchStyle);
+
+    testStyle.textContent = &quot;&quot;;
+}
+
+function test(pseudoClass) {
+    for (var i = 0, length = testCases.length; i &lt; length; ++i) {
+        var selector = testCases[i][0].replace('PLACEHOLDER', pseudoClass)
+        testQuerySelector(selector, testCases[i][1]);
+        testStyling(selector, testCases[i][1]);
+    }
+
+    // In strict mode, no tag name or the universal selector also work. This is tested separately because those selectors match
+    // every ancestor of the target.
+    shouldBe('document.querySelectorAll(&quot;' + pseudoClass + '&quot;).length', '3');
+    testStyling(pseudoClass, true);
+    shouldBe('document.querySelectorAll(&quot;*' + pseudoClass + '&quot;).length', '3');
+    testStyling('*' + pseudoClass, true);
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169359 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-26 20:18:25 UTC (rev 169359)
+++ trunk/Source/WebCore/ChangeLog        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2014-05-26  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        Fix the quirks mode selector matching of the pseudo classes :hover and :active
+        https://bugs.webkit.org/show_bug.cgi?id=133063
+
+        Reviewed by Antti Koivisto.
+
+        Our implementation of the quirks mode of :active and :hover was very wrong. The only
+        thing it was doing is verify the pseudo class is not the first selector of a fragment
+        (which was conveniently the only thing that was tested :)).
+
+        Since those pseudo class were only checking for the order of the filters, something like
+            #target:hover
+        would succeed because :hover is not the first simple selector, while
+            :hover#target
+        would fail.
+
+        That behavior is also a problem for the CSS JIT as it is an implementation detail of SelectorChecker
+        and compiling something like that with our out-of-order matching would be nonsense.
+
+        This patch update the implementation to follow http://quirks.spec.whatwg.org/#the-:active-and-:hover-quirk
+        Basically, the only cases that do not work in quirks mode are selectors composed only of &quot;*, :hover and :active&quot;.
+
+        To implement this behavior, I needed to be able to inspect a complete selector fragment, including
+        what is before and after :hover/:active.
+        To do that, I replaced the boolean isSubSelector by a pointer to the first selector of the fragment.
+        When we need to match :active/:hover in quirks mode, we just go over all the selectors in the fragment
+        to find one of the qualifying match type.
+
+        Tests: fast/selectors/active-hover-quirks.html
+               fast/selectors/active-quirks.html
+               fast/selectors/hover-quirks.html
+
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::matchRecursively):
+        (WebCore::canMatchHoverOrActiveInQuirksMode):
+        (WebCore::SelectorChecker::checkOne):
+        * css/SelectorChecker.h:
+        (WebCore::SelectorChecker::SelectorCheckingContext::SelectorCheckingContext):
+
</ins><span class="cx"> 2014-05-26  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Split the call to adjustForLocalZoom out into a separate expression.
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (169359 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorChecker.cpp        2014-05-26 20:18:25 UTC (rev 169359)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -192,7 +192,7 @@
</span><span class="cx">             return SelectorFailsCompletely;
</span><span class="cx"> 
</span><span class="cx">         // Disable :visited matching when we see the first link or try to match anything else than an ancestors.
</span><del>-        if (!context.isSubSelector &amp;&amp; (context.element-&gt;isLink() || (relation != CSSSelector::Descendant &amp;&amp; relation != CSSSelector::Child)))
</del><ins>+        if (context.firstSelectorOfTheFragment == context.selector &amp;&amp; (context.element-&gt;isLink() || (relation != CSSSelector::Descendant &amp;&amp; relation != CSSSelector::Child)))
</ins><span class="cx">             nextContext.visitedMatchType = VisitedMatchDisabled;
</span><span class="cx"> 
</span><span class="cx">         nextContext.pseudoId = NOPSEUDO;
</span><span class="lines">@@ -201,7 +201,7 @@
</span><span class="cx">     switch (relation) {
</span><span class="cx">     case CSSSelector::Descendant:
</span><span class="cx">         nextContext.element = context.element-&gt;parentElement();
</span><del>-        nextContext.isSubSelector = false;
</del><ins>+        nextContext.firstSelectorOfTheFragment = nextContext.selector;
</ins><span class="cx">         nextContext.elementStyle = 0;
</span><span class="cx">         for (; nextContext.element; nextContext.element = nextContext.element-&gt;parentElement()) {
</span><span class="cx">             Match match = this-&gt;matchRecursively(nextContext, ignoreDynamicPseudo);
</span><span class="lines">@@ -215,7 +215,7 @@
</span><span class="cx">             nextContext.element = context.element-&gt;parentElement();
</span><span class="cx">             if (!nextContext.element)
</span><span class="cx">                 return SelectorFailsCompletely;
</span><del>-            nextContext.isSubSelector = false;
</del><ins>+            nextContext.firstSelectorOfTheFragment = nextContext.selector;
</ins><span class="cx">             nextContext.elementStyle = nullptr;
</span><span class="cx">             Match match = matchRecursively(nextContext, ignoreDynamicPseudo);
</span><span class="cx">             if (match == SelectorMatches || match == SelectorFailsCompletely)
</span><span class="lines">@@ -231,7 +231,7 @@
</span><span class="cx">         nextContext.element = context.element-&gt;previousElementSibling();
</span><span class="cx">         if (!nextContext.element)
</span><span class="cx">             return SelectorFailsAllSiblings;
</span><del>-        nextContext.isSubSelector = false;
</del><ins>+        nextContext.firstSelectorOfTheFragment = nextContext.selector;
</ins><span class="cx">         nextContext.elementStyle = 0;
</span><span class="cx">         return matchRecursively(nextContext, ignoreDynamicPseudo);
</span><span class="cx"> 
</span><span class="lines">@@ -241,7 +241,7 @@
</span><span class="cx">                 parentElement-&gt;setChildrenAffectedByForwardPositionalRules();
</span><span class="cx">         }
</span><span class="cx">         nextContext.element = context.element-&gt;previousElementSibling();
</span><del>-        nextContext.isSubSelector = false;
</del><ins>+        nextContext.firstSelectorOfTheFragment = nextContext.selector;
</ins><span class="cx">         nextContext.elementStyle = 0;
</span><span class="cx">         for (; nextContext.element; nextContext.element = nextContext.element-&gt;previousElementSibling()) {
</span><span class="cx">             Match match = this-&gt;matchRecursively(nextContext, ignoreDynamicPseudo);
</span><span class="lines">@@ -260,7 +260,6 @@
</span><span class="cx">             &amp;&amp; !nextContext.hasSelectionPseudo
</span><span class="cx">             &amp;&amp; !(nextContext.hasScrollbarPseudo &amp;&amp; nextContext.selector-&gt;m_match == CSSSelector::PseudoClass))
</span><span class="cx">             return SelectorFailsCompletely;
</span><del>-        nextContext.isSubSelector = true;
</del><span class="cx">         return matchRecursively(nextContext, dynamicPseudo);
</span><span class="cx"> 
</span><span class="cx">     case CSSSelector::ShadowDescendant:
</span><span class="lines">@@ -269,7 +268,7 @@
</span><span class="cx">             if (!shadowHostNode)
</span><span class="cx">                 return SelectorFailsCompletely;
</span><span class="cx">             nextContext.element = shadowHostNode;
</span><del>-            nextContext.isSubSelector = false;
</del><ins>+            nextContext.firstSelectorOfTheFragment = nextContext.selector;
</ins><span class="cx">             nextContext.elementStyle = 0;
</span><span class="cx">             return matchRecursively(nextContext, ignoreDynamicPseudo);
</span><span class="cx">         }
</span><span class="lines">@@ -356,6 +355,61 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool canMatchHoverOrActiveInQuirksMode(const SelectorChecker::SelectorCheckingContext&amp; context)
+{
+    // For quirks mode, follow this: http://quirks.spec.whatwg.org/#the-:active-and-:hover-quirk
+    // In quirks mode, a compound selector 'selector' that matches the following conditions must not match elements that would not also match the ':any-link' selector.
+    //
+    //    selector uses the ':active' or ':hover' pseudo-classes.
+    //    selector does not use a type selector.
+    //    selector does not use an attribute selector.
+    //    selector does not use an ID selector.
+    //    selector does not use a class selector.
+    //    selector does not use a pseudo-class selector other than ':active' and ':hover'.
+    //    selector does not use a pseudo-element selector.
+    //    selector is not part of an argument to a functional pseudo-class or pseudo-element.
+    if (context.inFunctionalPseudoClass)
+        return true;
+
+    for (const CSSSelector* selector = context.firstSelectorOfTheFragment; selector; selector = selector-&gt;tagHistory()) {
+        switch (selector-&gt;m_match) {
+        case CSSSelector::Tag:
+            if (selector-&gt;tagQName() != anyQName())
+                return true;
+            break;
+        case CSSSelector::PseudoClass: {
+            CSSSelector::PseudoClassType pseudoClassType = selector-&gt;pseudoClassType();
+            if (pseudoClassType != CSSSelector::PseudoClassHover &amp;&amp; pseudoClassType != CSSSelector::PseudoClassActive)
+                return true;
+            break;
+        }
+        case CSSSelector::Id:
+        case CSSSelector::Class:
+        case CSSSelector::Exact:
+        case CSSSelector::Set:
+        case CSSSelector::List:
+        case CSSSelector::Hyphen:
+        case CSSSelector::Contain:
+        case CSSSelector::Begin:
+        case CSSSelector::End:
+        case CSSSelector::PagePseudoClass:
+        case CSSSelector::PseudoElement:
+            return true;
+        case CSSSelector::Unknown:
+            ASSERT_NOT_REACHED();
+            break;
+        }
+
+        CSSSelector::Relation relation = selector-&gt;relation();
+        if (relation == CSSSelector::ShadowDescendant)
+            return true;
+
+        if (relation != CSSSelector::SubSelector)
+            return false;
+    }
+    return false;
+}
+
</ins><span class="cx"> bool SelectorChecker::checkOne(const SelectorCheckingContext&amp; context) const
</span><span class="cx"> {
</span><span class="cx">     Element* const &amp; element = context.element;
</span><span class="lines">@@ -393,7 +447,8 @@
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">             SelectorCheckingContext subContext(context);
</span><del>-            subContext.isSubSelector = true;
</del><ins>+            subContext.inFunctionalPseudoClass = true;
+            subContext.firstSelectorOfTheFragment = selectorList-&gt;first();
</ins><span class="cx">             for (subContext.selector = selectorList-&gt;first(); subContext.selector; subContext.selector = subContext.selector-&gt;tagHistory()) {
</span><span class="cx">                 if (subContext.selector-&gt;m_match == CSSSelector::PseudoClass) {
</span><span class="cx">                     // :not cannot nest. I don't really know why this is a
</span><span class="lines">@@ -582,9 +637,10 @@
</span><span class="cx">         case CSSSelector::PseudoClassAny:
</span><span class="cx">             {
</span><span class="cx">                 SelectorCheckingContext subContext(context);
</span><del>-                subContext.isSubSelector = true;
</del><ins>+                subContext.inFunctionalPseudoClass = true;
</ins><span class="cx">                 PseudoId ignoreDynamicPseudo = NOPSEUDO;
</span><span class="cx">                 for (subContext.selector = selector-&gt;selectorList()-&gt;first(); subContext.selector; subContext.selector = CSSSelectorList::next(subContext.selector)) {
</span><ins>+                    subContext.firstSelectorOfTheFragment = subContext.selector;
</ins><span class="cx">                     if (matchRecursively(subContext, ignoreDynamicPseudo) == SelectorMatches)
</span><span class="cx">                         return true;
</span><span class="cx">                 }
</span><span class="lines">@@ -612,9 +668,7 @@
</span><span class="cx">         case CSSSelector::PseudoClassFocus:
</span><span class="cx">             return matchesFocusPseudoClass(element);
</span><span class="cx">         case CSSSelector::PseudoClassHover:
</span><del>-            // If we're in quirks mode, then hover should never match anchors with no
-            // href and *:hover should not match anything. This is important for sites like wsj.com.
-            if (m_strictParsing || context.isSubSelector || element-&gt;isLink()) {
</del><ins>+            if (m_strictParsing || element-&gt;isLink() || canMatchHoverOrActiveInQuirksMode(context)) {
</ins><span class="cx">                 if (m_mode == ResolvingStyle) {
</span><span class="cx">                     if (context.elementStyle)
</span><span class="cx">                         context.elementStyle-&gt;setAffectedByHover();
</span><span class="lines">@@ -626,9 +680,7 @@
</span><span class="cx">             }
</span><span class="cx">             break;
</span><span class="cx">         case CSSSelector::PseudoClassActive:
</span><del>-            // If we're in quirks mode, then :active should never match anchors with no
-            // href and *:active should not match anything.
-            if (m_strictParsing || context.isSubSelector || element-&gt;isLink()) {
</del><ins>+            if (m_strictParsing || element-&gt;isLink() || canMatchHoverOrActiveInQuirksMode(context)) {
</ins><span class="cx">                 if (m_mode == ResolvingStyle) {
</span><span class="cx">                     if (context.elementStyle)
</span><span class="cx">                         context.elementStyle-&gt;setAffectedByActive();
</span><span class="lines">@@ -742,11 +794,12 @@
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     else if (selector-&gt;m_match == CSSSelector::PseudoElement &amp;&amp; selector-&gt;pseudoElementType() == CSSSelector::PseudoElementCue) {
</span><span class="cx">         SelectorCheckingContext subContext(context);
</span><del>-        subContext.isSubSelector = true;
</del><span class="cx"> 
</span><span class="cx">         PseudoId ignoreDynamicPseudo = NOPSEUDO;
</span><span class="cx">         const CSSSelector* const &amp; selector = context.selector;
</span><span class="cx">         for (subContext.selector = selector-&gt;selectorList()-&gt;first(); subContext.selector; subContext.selector = CSSSelectorList::next(subContext.selector)) {
</span><ins>+            subContext.firstSelectorOfTheFragment = subContext.selector;
+            subContext.inFunctionalPseudoClass = true;
</ins><span class="cx">             if (matchRecursively(subContext, ignoreDynamicPseudo) == SelectorMatches)
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorChecker.h (169359 => 169360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorChecker.h        2014-05-26 20:18:25 UTC (rev 169359)
+++ trunk/Source/WebCore/css/SelectorChecker.h        2014-05-26 21:45:17 UTC (rev 169360)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx">  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><span class="cx">  *           (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
</span><span class="cx">  * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
</span><del>- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2007 Alexey Proskuryakov &lt;ap@webkit.org&gt;
</span><span class="cx">  * Copyright (C) 2007, 2008 Eric Seidel &lt;eric@webkit.org&gt;
</span><span class="cx">  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</span><span class="lines">@@ -61,8 +61,9 @@
</span><span class="cx">             , pseudoId(NOPSEUDO)
</span><span class="cx">             , elementStyle(0)
</span><span class="cx">             , scrollbar(0)
</span><ins>+            , firstSelectorOfTheFragment(selector)
</ins><span class="cx">             , scrollbarPart(NoPart)
</span><del>-            , isSubSelector(false)
</del><ins>+            , inFunctionalPseudoClass(false)
</ins><span class="cx">             , hasScrollbarPseudo(false)
</span><span class="cx">             , hasSelectionPseudo(false)
</span><span class="cx">         { }
</span><span class="lines">@@ -74,8 +75,9 @@
</span><span class="cx">         PseudoId pseudoId;
</span><span class="cx">         RenderStyle* elementStyle;
</span><span class="cx">         RenderScrollbar* scrollbar;
</span><ins>+        const CSSSelector* firstSelectorOfTheFragment;
</ins><span class="cx">         ScrollbarPart scrollbarPart;
</span><del>-        bool isSubSelector;
</del><ins>+        bool inFunctionalPseudoClass;
</ins><span class="cx">         bool hasScrollbarPseudo;
</span><span class="cx">         bool hasSelectionPseudo;
</span><span class="cx">     };
</span></span></pre>
</div>
</div>

</body>
</html>