Tests for unicode-bidi: isolate and plaintext from Webkit. Bug 706194, r=roc

This commit is contained in:
Simon Montagu 2012-04-23 11:48:33 +03:00
Родитель a7b1ccb6f9
Коммит 18d0dc7596
17 изменённых файлов: 498 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>
From WebKit <a href='https://bugs.webkit.org/show_bug.cgi?id=50913'>bug 50913</a>
</p>
<p>
In this example, usernames are shown along with the number of posts that the user has submitted. If the bdi element were not used, the username of the Arabic user would end up confusing the text (the bidirectional algorithm would put the colon and the number "3" next to the word "User" rather than next to the word "posts").
</p>
<ul>
<li><bdo dir="ltr">User jcranmer: 12 posts.</bdo>
<li><bdo dir="ltr">User hober: 5 posts.</bdo>
<li><bdo dir="ltr">User ????: 3 posts.</bdo>
</ul>
</body>
</html>

Просмотреть файл

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>
From WebKit <a href='https://bugs.webkit.org/show_bug.cgi?id=50913'>bug 50913</a>
</p>
<p>
In this example, usernames are shown along with the number of posts that the user has submitted. If the bdi element were not used, the username of the Arabic user would end up confusing the text (the bidirectional algorithm would put the colon and the number "3" next to the word "User" rather than next to the word "posts").
</p>
<ul>
<li>User <bdi>jcranmer</bdi>: 12 posts.
<li>User <bdi>hober</bdi>: 5 posts.
<li>User <bdi>????</bdi>: 3 posts.
</ul>
</body>
</html>

Просмотреть файл

@ -1,3 +1,4 @@
== bdi-element.html bdi-element-ref.html
== bidi-000.html bidi-000-ref.html
== bidi-001.html bidi-001-ref.html
== bidi-001-j.html bidi-001-ref.html
@ -32,6 +33,13 @@ random-if(cocoaWidget) == mirroring-02.html mirroring-02-ref.html
== mixedChartype-03-j.html mixedChartype-03-ref.html
== unicode-bidi-anonymous-001.html unicode-bidi-anonymous-001-ref.html
== unicode-bidi-anonymous-002.html unicode-bidi-anonymous-002-ref.html
== unicode-bidi-isolate-basic.html unicode-bidi-isolate-basic-ref.html
== unicode-bidi-isolate-aharon.html unicode-bidi-isolate-aharon-ref.html
== unicode-bidi-plaintext.html unicode-bidi-plaintext-ref.html
== unicode-bidi-plaintext-textarea-1.html unicode-bidi-plaintext-textarea-ref.html
== unicode-bidi-plaintext-textarea-2.html unicode-bidi-plaintext-textarea-ref.html
== unicode-bidi-plaintext-textarea-3.html unicode-bidi-plaintext-textarea-ref.html
== unicode-bidi-plaintext-textarea-4.html unicode-bidi-plaintext-textarea-ref.html
== with-first-letter-1a.html with-first-letter-1-ref.html
== with-first-letter-1b.html with-first-letter-1-ref.html
random-if(cocoaWidget) == with-first-letter-2a.html with-first-letter-2-ref.html # bug 734313

Просмотреть файл

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html><head>
<title>Test cases for unicode-bidi:isolate</title>
<style>
</style>
</head><body>
opposite-to-base isolate followed by number.
<div>
<div class="reference">
<span dir="ltr">&#x05D0;</span> (3 reviews)
</div>
</div>
<hr>
opposite-to-base isolate with opposite-to-base text before it with neutrals in between.
<div>
<div class="reference">
<span dir="ltr">&#x05D0;</span>: <span dir="ltr">&#x05D1;</span>
</div>
</div>
<hr>
opposite-to-base isolate with opposite-to-base text before it and nothing in between.
<div>
<div class="reference">
<bdo dir="ltr">&#x05D0;&#x05D1;</bdo>
</div>
</div>
<hr>
two opposite-to-base isolates with neutrals in between.
<div>
<div class="reference">
<span dir="ltr">&#x05D0;</span> = <span dir="ltr">&#x05D1;</span>
</div>
</div>
<hr>
two opposite-to-base isolates with nothing in between.
<div>
<div class="reference">
<bdo dir="ltr">&#x05D0;&#x05D1;</bdo>
</div>
</div>
<hr>
same-as-base isolate preceded by opposite-to-base text and followed by number
<div dir="rtl">
<div class="reference">
see <span dir="ltr">&#x05D0;</span><sup>3</sup>
</div>
</div>
<hr>
same-as-base isolate surrounded by opposite-to-base text
<div dir="rtl">
<div class="reference">
with <span dir="ltr">&#x05D0;</span>=<span dir="ltr">&#x05D1;</span> everywhere
</div>
</div>
<hr>
chimeric isolate surrounded by chimeric text
<div>
<div class="reference">
about that <span dir="ltr">&#x05D0;</span> - &#x05D1;
</div>
</div>
<hr>
nested chimeric isolates surrounded by chimeric text
<div>
<div class="reference">
about that strange <span dir="ltr">&#x05D0;</span> - <span dir="ltr">&#x05D1;</span> - &#x05D2;
</div>
</div>
</body></html>

Просмотреть файл

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html><head>
<title>Test cases for unicode-bidi:isolate</title>
<style>
.isolate {
unicode-bidi: -webkit-isolate;
unicode-bidi: -moz-isolate;
unicode-bidi: isolate;
}
</style>
</head><body>
opposite-to-base isolate followed by number.
<div>
<div class="test">
<span class="isolate">&#x05D0;</span> (3 reviews)
</div>
</div>
<hr>
opposite-to-base isolate with opposite-to-base text before it with neutrals in between.
<div>
<div class="test">
&#x05D0;: <span class="isolate">&#x05D1;</span>
</div>
</div>
<hr>
opposite-to-base isolate with opposite-to-base text before it and nothing in between.
<div>
<div class="test">
&#x05D0;<span class="isolate">&#x05D1;</span>
</div>
</div>
<hr>
two opposite-to-base isolates with neutrals in between.
<div>
<div class="test">
<span class="isolate">&#x05D0;</span> = <span class="isolate">&#x05D1;</span>
</div>
</div>
<hr>
two opposite-to-base isolates with nothing in between.
<div>
<div class="test">
<span class="isolate">&#x05D0;</span><span class="isolate">&#x05D1;</span>
</div>
</div>
<hr>
same-as-base isolate preceded by opposite-to-base text and followed by number
<div dir="rtl">
<div class="test">
see <span class="isolate">&#x05D0;</span><sup>3</sup>
</div>
</div>
<hr>
same-as-base isolate surrounded by opposite-to-base text
<div dir="rtl">
<div class="test">
with <span class="isolate">&#x05D0;</span>=<span class="isolate">&#x05D1;</span> everywhere
</div>
</div>
<hr>
chimeric isolate surrounded by chimeric text
<div>
<div class="test">
about <span class="isolate">that &#x05D0;</span> - &#x05D1;
</div>
</div>
<hr>
nested chimeric isolates surrounded by chimeric text
<div>
<div class="test">
about <span class="isolate">that <span class="isolate">strange &#x05D0;</span> - &#x05D1;</span> - &#x05D2;
</div>
</div>
</body></html>

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="unicode-bidi-isolate-basic.js"></script>
<style>
.resultsDiv {
-moz-column-width: 3em;
-webkit-column-width: 3em;
-moz-column-gap: 5em;
-webkit-column-gap: 5em;
}
.enclosed { display: inline-block; }
</style>
</head>
<body onload="buildTable();">
<div id="resultsContainer" style="position: relative">
<div id="elem" class="resultsDiv"></div>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="unicode-bidi-isolate-basic.js"></script>
<style>
.resultsDiv {
-moz-column-width: 3em;
-webkit-column-width: 3em;
-moz-column-gap: 5em;
-webkit-column-gap: 5em;
}
.enclosed { unicode-bidi: -moz-isolate; }
</style>
</head>
<body onload="buildTable()">
<div id="resultsContainer" style="position: relative">
<div id="elem" class="resultsDiv"></div>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,44 @@
function buildTable()
{
var seed = 0;
var neutrals = ['"', ")", "("];
var strongRTLs = ['?', '?', '?', '?', '?', '?', '?'];
var strongLTRs = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
var neutral = function() { return neutrals[seed++ % neutrals.length]; }
var strongRTL = function() { return strongRTLs[seed++ % strongRTLs.length]; }
var strongLTR = function() { return strongLTRs[seed++ % strongLTRs.length]; }
var charClassExamples = [neutral, strongRTL, strongLTR];
var possibleDirs = ['ltr', 'rtl'];
var elem=document.getElementById("elem");
for (outerDirIndex in possibleDirs) {
var outerDir = possibleDirs[outerDirIndex];
for (beforeSpanIndex in charClassExamples) {
var beforeSpan = charClassExamples[beforeSpanIndex];
for (spanDirIndex in possibleDirs) {
var spanDir = possibleDirs[spanDirIndex];
for (inSpanIndex in charClassExamples) {
var inSpan = charClassExamples[inSpanIndex];
for (afterSpanIndex in charClassExamples) {
var afterSpan = charClassExamples[afterSpanIndex];
function caseWithStyle() {
seed = 0;
var outerDiv = document.createElement("div");
outerDiv.dir = outerDir;
outerDiv.appendChild(document.createTextNode(beforeSpan()));
var span = document.createElement("span");
span.dir = spanDir;
span.setAttribute("class", "enclosed")
span.appendChild(document.createTextNode(inSpan()));
outerDiv.appendChild(span);
outerDiv.appendChild(document.createTextNode(afterSpan()));
return outerDiv;
}
elem.appendChild(caseWithStyle());
}
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div>
!hello.<br>
<span dir=rtl>
!????.
</span><br>
<span dir=ltr>
hello, ???!
</span><br>
<span dir=rtl>
????, WebKit!</span><br>
<pre>
a
(
!WebKit ,????
hello, ???!
)
</pre>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html><head>
<title>unicode-bidi:plaintext</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<div>
The exclamation mark should be on the left side of the first line
and on the right side of the second line.
</div>
<textarea rows=4 cols=50 dir=auto>
????!
hello!
</textarea>
</body></html>

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html><head>
<title>unicode-bidi:plaintext</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.plaintext {
unicode-bidi:-webkit-plaintext;
unicode-bidi:-moz-plaintext;
unicode-bidi:plaintext;
}
</style>
</head><body>
<div>
The exclamation mark should be on the left side of the first line
and on the right side of the second line.
</div>
<textarea rows=4 cols=50 class="plaintext">
????!
hello!
</textarea>
</body></html>

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html><head>
<title>unicode-bidi:plaintext</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.plaintext {
unicode-bidi:-webkit-plaintext;
unicode-bidi:-moz-plaintext;
unicode-bidi:plaintext;
}
</style>
</head><body>
<div>
The exclamation mark should be on the left side of the first line
and on the right side of the second line.
</div>
<textarea rows=4 cols=50 dir="ltr" class="plaintext">
????!
hello!
</textarea>
</body></html>

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html><head>
<title>unicode-bidi:plaintext</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.plaintext {
unicode-bidi:-webkit-plaintext;
unicode-bidi:-moz-plaintext;
unicode-bidi:plaintext;
}
</style>
</head><body>
<div>
The exclamation mark should be on the left side of the first line
and on the right side of the second line.
</div>
<textarea rows=4 cols=50 dir="rtl" class="plaintext">
????!
hello!
</textarea>
</body></html>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>unicode-bidi:plaintext</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div>
The exclamation mark should be on the left side of the first line
and on the right side of the second line.
</div>
<textarea rows=4 cols=50 dir=ltr>
&#x202b;????!&#x202c;
&#x202a;hello!&#x202c
</textarea>
</body></html>

Просмотреть файл

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="unicode-bidi: -webkit-plaintext; unicode-bidi: -moz-plaintext; unicode-bidi: plaintext;">
!hello.
<br>
!????.
<br>
hello, ???!
<br>
????, WebKit!
</div>
<pre dir="auto">
a
(
????, WebKit!
hello, ???!
)
</pre>
</body>
</html>

Просмотреть файл

@ -141,6 +141,7 @@ _TEST_FILES = test_acid3_test46.html \
test_computed_style_no_pseudo.html \
test_css_cross_domain.html \
test_css_eof_handling.html \
test_default_bidi_css.html \
test_descriptor_storage.html \
test_descriptor_syntax_errors.html \
test_dont_use_document_colors.html \

Просмотреть файл

@ -0,0 +1,79 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for default bidi css **/
function styleOf(name, attributes) {
var element = document.createElement(name);
for (var name in attributes) {
var value = attributes[name];
element.setAttribute(name, value);
}
return getComputedStyle(element);
}
var tests = [
['div', {}, 'ltr', '-moz-isolate'],
['div', {'dir': 'ltr'}, 'ltr', 'embed'],
['div', {'dir': 'rtl'}, 'rtl', 'embed'],
['div', {'dir': 'auto'}, 'ltr', '-moz-isolate'],
['div', {'dir': ''}, 'ltr', 'embed'],
['span', {}, 'ltr', 'normal'],
['span', {'dir': 'ltr'}, 'ltr', 'embed'],
['span', {'dir': 'rtl'}, 'rtl', 'embed'],
['span', {'dir': 'auto'}, 'ltr', '-moz-isolate'],
['span', {'dir': ''}, 'ltr', 'embed'],
['bdi', {}, 'ltr', '-moz-isolate'],
['bdi', {'dir': 'ltr'}, 'ltr', '-moz-isolate'],
['bdi', {'dir': 'rtl'}, 'rtl', '-moz-isolate'],
['bdi', {'dir': 'auto'}, 'ltr', '-moz-isolate'],
['bdi', {'dir': ''}, 'ltr', '-moz-isolate'],
['output', {}, 'ltr', '-moz-isolate'],
['output', {'dir': 'ltr'}, 'ltr', '-moz-isolate'],
['output', {'dir': 'rtl'}, 'rtl', '-moz-isolate'],
['output', {'dir': 'auto'}, 'ltr', '-moz-isolate'],
['output', {'dir': ''}, 'ltr', '-moz-isolate'],
['bdo', {}, 'ltr', 'bidi-override'],
['bdo', {'dir': 'ltr'}, 'ltr', 'bidi-override'],
['bdo', {'dir': 'rtl'}, 'rtl', 'bidi-override'],
['bdo', {'dir': 'auto'}, 'ltr', '-moz-isolate bidi-override'],
['bdo', {'dir': ''}, 'ltr', 'bidi-override'],
['textarea', {}, 'ltr', 'normal'],
['textarea', {'dir': 'ltr'}, 'ltr', 'embed'],
['textarea', {'dir': 'rtl'}, 'rtl', 'embed'],
['textarea', {'dir': 'auto'}, 'ltr', '-moz-plaintext'],
['textarea', {'dir': ''}, 'ltr', 'embed'],
['pre', {}, 'ltr', 'normal'],
['pre', {'dir': 'ltr'}, 'ltr', 'embed'],
['pre', {'dir': 'rtl'}, 'rtl', 'embed'],
['pre', {'dir': 'auto'}, 'ltr', '-moz-plaintext'],
['pre', {'dir': ''}, 'ltr', 'embed'],
].forEach(function (test) {
var style = styleOf(test[0], test[1]);
is(style.direction, test[2], "default value for direction");
is(style.unicodeBidi, test[3], "default value for unicode-bidi");
});
</script>
</pre>
</body>
</html>