Commit 00b9ee5a authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Make Chinese linebreaking tests more robust against rounding

These tests were comparing offsetLeft, but there were pixel differences
which made some of the tests fails. Using a less than 1
getClientBoundingRect().left difference instead, cleaning up the code
and removing expectations file due to these robustly passing now. The
pixel differences are not relevant to the intention of the test.

Bug: 927287
Change-Id: I74fe8d64edb1a52de4fd0dbb3143843b305f8156
Reviewed-on: https://chromium-review.googlesource.com/c/1448215
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Auto-Submit: Dominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#627968}
parent 537fbc9b
...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may appear at line start if zh and loose'); }, lines[i]+' may appear at line start if zh and loose');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and normal'); }, lines[i]+' may NOT appear at line start if zh and normal');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and strict'); }, lines[i]+' may NOT appear at line start if zh and strict');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -42,17 +42,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -42,17 +42,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may appear at line start if zh and loose'); }, lines[i]+' may appear at line start if zh and loose');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -42,17 +42,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -42,17 +42,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may appear at line start if zh and normal'); }, lines[i]+' may appear at line start if zh and normal');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -42,17 +42,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -42,17 +42,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and strict'); }, lines[i]+' may NOT appear at line start if zh and strict');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -43,17 +43,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -43,17 +43,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may appear at line start if zh and loose'); }, lines[i]+' may appear at line start if zh and loose');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -43,17 +43,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -43,17 +43,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and normal'); }, lines[i]+' may NOT appear at line start if zh and normal');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -43,17 +43,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -43,17 +43,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and strict'); }, lines[i]+' may NOT appear at line start if zh and strict');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -44,17 +44,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -44,17 +44,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may appear at line start if zh and loose'); }, lines[i]+' may appear at line start if zh and loose');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -44,17 +44,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -44,17 +44,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and normal'); }, lines[i]+' may NOT appear at line start if zh and normal');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -44,17 +44,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -44,17 +44,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and strict'); }, lines[i]+' may NOT appear at line start if zh and strict');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文文<br/>&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may appear at line start if zh and loose'); }, lines[i]+' may appear at line start if zh and loose');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and normal'); }, lines[i]+' may NOT appear at line start if zh and normal');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) { ...@@ -48,17 +48,26 @@ for (var i=0;i<lines.length;i++) {
'<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' + '<div class="ref" id="ref'+i+'" lang="zh">文文文文文<br/>文&#x'+hex+';字<span id="refSpan'+i+'">字</span></div>' +
'</div>' '</div>'
} }
function spansNearEnough(counter) {
return Math.abs( document.getElementById('testSpan'+counter).getBoundingClientRect().left
- document.getElementById('refSpan'+counter).getBoundingClientRect().left ) < 1;
}
document.querySelector('body').innerHTML = out document.querySelector('body').innerHTML = out
// hide successful tests setup({explicit_done: true});
for (i=0;i<lines.length;i++) {
if (document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft) document.getElementById('test'+i).parentNode.style.display = 'none' document.fonts.ready.then(validate);
}
// run the test framework function validate() {
for (i=0;i<lines.length;i++) { for (i=0;i<lines.length;i++) {
test(function() { test(function() {
assert_true(document.getElementById('testSpan'+i).offsetLeft === document.getElementById('refSpan'+i).offsetLeft); assert_true(spansNearEnough(i));
}, lines[i]+' may NOT appear at line start if zh and strict'); }, lines[i]+' may NOT appear at line start if zh and strict');
} // Hide successful tests.
if (spansNearEnough(i)) document.getElementById('test'+i).parentNode.style.display = 'none'
}
done();
}
</script> </script>
<!--Notes: <!--Notes:
The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited. The test creates a box with room for 6 characters, causing wrapping to occur either between the 6th and the 7th character, or before the 6th if the breaks after the 6th or before the 7th are prohibited.
......
This is a testharness.js-based test.
PASS 30FB KATAKANA MIDDLE DOT may appear at line start if zh and loose
PASS FF1A FULLWIDTH COLON may appear at line start if zh and loose
PASS FF1B FULLWIDTH SEMICOLON may appear at line start if zh and loose
PASS FF65 HALFWIDTH KATAKANA MIDDLE DOT may appear at line start if zh and loose
PASS 203C DOUBLE EXCLAMATION MARK may appear at line start if zh and loose
FAIL 2047 DOUBLE QUESTION MARK may appear at line start if zh and loose assert_true: expected true got false
FAIL 2048 QUESTION EXCLAMATION MARK may appear at line start if zh and loose assert_true: expected true got false
PASS 2049 EXCLAMATION QUESTION MARK may appear at line start if zh and loose
PASS FF01 FULLWIDTH EXCLAMATION MARK may appear at line start if zh and loose
PASS FF1F FULLWIDTH QUESTION MARK may appear at line start if zh and loose
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS 00B0 DEGREE SIGN may appear at line start if zh and loose
PASS 2030 PER MILLE SIGN may appear at line start if zh and loose
PASS 2032 PRIME may appear at line start if zh and loose
PASS 2033 DOUBLE PRIME may appear at line start if zh and loose
PASS 2035 REVERSED PRIME may appear at line start if zh and loose
FAIL 2103 DEGREE CELSIUS may appear at line start if zh and loose assert_true: expected true got false
FAIL 2109 DEGREE FAHRENHEIT may appear at line start if zh and loose assert_true: expected true got false
PASS FE6A SMALL PERCENT SIGN may appear at line start if zh and loose
PASS FF05 FULLWIDTH PERCENT SIGN may appear at line start if zh and loose
PASS FFE0 FULLWIDTH CENT SIGN may appear at line start if zh and loose
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS 00B0 DEGREE SIGN may appear at line start if zh and loose
PASS 2030 PER MILLE SIGN may appear at line start if zh and loose
PASS 2032 PRIME may appear at line start if zh and loose
PASS 2033 DOUBLE PRIME may appear at line start if zh and loose
PASS 2035 REVERSED PRIME may appear at line start if zh and loose
FAIL 2103 DEGREE CELSIUS may appear at line start if zh and loose assert_true: expected true got false
FAIL 2109 DEGREE FAHRENHEIT may appear at line start if zh and loose assert_true: expected true got false
PASS FE6A SMALL PERCENT SIGN may appear at line start if zh and loose
PASS FF05 FULLWIDTH PERCENT SIGN may appear at line start if zh and loose
PASS FFE0 FULLWIDTH CENT SIGN may appear at line start if zh and loose
Harness: the test ran to completion.
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