Commit 9ef9d7d6 authored by Amos Lim's avatar Amos Lim Committed by Commit Bot

Ignore 'usemap' attribute if it contains no #

According to the HTML standard, usemap="no-hash-name" should not work
with <map name="no-hash-name"> [1].
[1] https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-a-hash-name-reference

Bug: 897025
Change-Id: Ib8ef533795e986e782a702c2562a155f59d7ce13
Reviewed-on: https://chromium-review.googlesource.com/c/1291190Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Amos Lim <eui-sang.lim@samsung.com>
Cr-Commit-Position: refs/heads/master@{#601473}
parent 551cdd50
This is a testharness.js-based test.
Found 168 tests; 82 PASS, 86 FAIL, 0 TIMEOUT, 0 NOTRUN.
FAIL HTML (standards) IMG usemap="no-hash-name" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="no-hash-name">... but got Element node <area shape="rect" coords="0,0,99,50" href="#area-no-hash...
Found 168 tests; 89 PASS, 79 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS HTML (standards) IMG usemap="no-hash-name"
PASS HTML (standards) OBJECT usemap="no-hash-name"
PASS HTML (standards) IMG usemap="no-hash-id"
PASS HTML (standards) OBJECT usemap="no-hash-id"
......@@ -22,7 +22,7 @@ FAIL HTML (standards) IMG usemap="#two-maps-with-this-id-or-name" assert_equals:
FAIL HTML (standards) OBJECT usemap="#two-maps-with-this-id-or-name" assert_equals: expected Element node <area shape="rect" coords="0,0,99,50" href="#area-two-map... but got Element node <object data="/images/threecolors.png" usemap="#two-maps-...
FAIL HTML (standards) IMG usemap="hash-last#" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="hash-last#"></... but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS HTML (standards) OBJECT usemap="hash-last#"
FAIL HTML (standards) IMG usemap="" assert_equals: expected Element node <img src="/images/threecolors.png" usemap=""></img> but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS HTML (standards) IMG usemap=""
PASS HTML (standards) OBJECT usemap=""
FAIL HTML (standards) IMG usemap="#" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="#"></img> but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS HTML (standards) OBJECT usemap="#"
......@@ -58,7 +58,7 @@ PASS HTML (standards) IMG usemap="#different-CASE-name"
PASS HTML (standards) OBJECT usemap="#different-CASE-name"
PASS HTML (standards) IMG usemap="#different-CASE-id"
PASS HTML (standards) OBJECT usemap="#different-CASE-id"
FAIL HTML (quirks) IMG usemap="no-hash-name" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="no-hash-name">... but got Element node <area shape="rect" coords="0,0,99,50" href="#area-no-hash...
PASS HTML (quirks) IMG usemap="no-hash-name"
PASS HTML (quirks) OBJECT usemap="no-hash-name"
PASS HTML (quirks) IMG usemap="no-hash-id"
PASS HTML (quirks) OBJECT usemap="no-hash-id"
......@@ -80,7 +80,7 @@ FAIL HTML (quirks) IMG usemap="#two-maps-with-this-id-or-name" assert_equals: ex
FAIL HTML (quirks) OBJECT usemap="#two-maps-with-this-id-or-name" assert_equals: expected Element node <area shape="rect" coords="0,0,99,50" href="#area-two-map... but got Element node <object data="/images/threecolors.png" usemap="#two-maps-...
FAIL HTML (quirks) IMG usemap="hash-last#" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="hash-last#"></... but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS HTML (quirks) OBJECT usemap="hash-last#"
FAIL HTML (quirks) IMG usemap="" assert_equals: expected Element node <img src="/images/threecolors.png" usemap=""></img> but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS HTML (quirks) IMG usemap=""
PASS HTML (quirks) OBJECT usemap=""
FAIL HTML (quirks) IMG usemap="#" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="#"></img> but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS HTML (quirks) OBJECT usemap="#"
......@@ -116,9 +116,9 @@ PASS HTML (quirks) IMG usemap="#different-CASE-name"
PASS HTML (quirks) OBJECT usemap="#different-CASE-name"
PASS HTML (quirks) IMG usemap="#different-CASE-id"
PASS HTML (quirks) OBJECT usemap="#different-CASE-id"
FAIL XHTML img usemap="no-hash-name" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="no-hash-name">... but got Element node <area shape="rect" coords="0,0,99,50" href="#area-no-hash...
PASS XHTML img usemap="no-hash-name"
PASS XHTML object usemap="no-hash-name"
FAIL XHTML img usemap="no-hash-id" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="no-hash-id"></... but got Element node <area shape="rect" coords="0,0,99,50" href="#area-no-hash...
PASS XHTML img usemap="no-hash-id"
PASS XHTML object usemap="no-hash-id"
PASS XHTML img usemap="#hash-name"
FAIL XHTML object usemap="#hash-name" assert_equals: expected Element node <area shape="rect" coords="0,0,99,50" href="#area-hash-na... but got Element node <object data="/images/threecolors.png" usemap="#hash-name...
......@@ -138,7 +138,7 @@ PASS XHTML img usemap="#two-maps-with-this-id-or-name"
FAIL XHTML object usemap="#two-maps-with-this-id-or-name" assert_equals: expected Element node <area shape="rect" coords="0,0,99,50" href="#area-two-map... but got Element node <object data="/images/threecolors.png" usemap="#two-maps-...
FAIL XHTML img usemap="hash-last#" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="hash-last#"></... but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS XHTML object usemap="hash-last#"
FAIL XHTML img usemap="" assert_equals: expected Element node <img src="/images/threecolors.png" usemap=""></img> but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS XHTML img usemap=""
PASS XHTML object usemap=""
FAIL XHTML img usemap="#" assert_equals: expected Element node <img src="/images/threecolors.png" usemap="#"></img> but got Element node <area shape="rect" coords="0,0,99,50" href="#area-empty-u...
PASS XHTML object usemap="#"
......
......@@ -78,7 +78,7 @@ function runTest()
<map name="mapname"><area shape="rect" coords="0,0,100,100" onclick="setResult('1')" /></map>
<map name="mapname"><area shape="rect" coords="0,0,100,100" onclick="setResult('2')" /></map>
<map name="mapname"><area shape="rect" coords="0,0,100,100" onclick="setResult('3')" /></map>
<img src="resources/green.jpg" border="20" width="100" height="100" usemap="mapname" ismap="ismap" onclick="setResult('img')" />
<img src="resources/green.jpg" border="20" width="100" height="100" usemap="#mapname" ismap="ismap" onclick="setResult('img')" />
<div>This tests image map behavior when there are multiple maps with the same name.</div>
<pre id="log" />
</body>
......
......@@ -189,7 +189,9 @@ HTMLMapElement* TreeScope::GetImageMap(const String& url) const {
if (!image_maps_by_name_)
return nullptr;
wtf_size_t hash_pos = url.find('#');
String name = hash_pos == kNotFound ? url : url.Substring(hash_pos + 1);
if (hash_pos == kNotFound)
return nullptr;
String name = url.Substring(hash_pos + 1);
return ToHTMLMapElement(
image_maps_by_name_->GetElementByMapName(AtomicString(name), *this));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment