Index: PerformanceTests/Layout/resources/character_fallback_test.js |
diff --git a/PerformanceTests/Layout/resources/character_fallback_test.js b/PerformanceTests/Layout/resources/character_fallback_test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d2fb2ad4e9053b73dc38182e6f6bc4bc78b627a0 |
--- /dev/null |
+++ b/PerformanceTests/Layout/resources/character_fallback_test.js |
@@ -0,0 +1,34 @@ |
+// Perf Tests run a maximum of 20 times, |
+// make sure we have an equal amount of characters |
+// for each run. |
+var selectionSize = fallbackChars.length / 21; |
+var target; |
+ |
+function test() { |
+ var charSelection = ""; |
+ for(var i=0; i < selectionSize; i++) { |
+ var selectedCharIndex = Math.floor(Math.random() * fallbackChars.length); |
+ if(!fallbackChars[selectedCharIndex]) |
+ continue; |
+ charSelection += fallbackChars[selectedCharIndex]; |
+ fallbackChars.splice(selectedCharIndex, 1); |
+ } |
+ if (charSelection.length) |
+ replaceTextAndWaitForLayout(charSelection); |
+} |
+ |
+function replaceTextAndWaitForLayout(charSelection) { |
+ while (target.firstChild) |
+ target.removeChild(target.firstChild); |
+ target.appendChild(document.createTextNode(charSelection)); |
+ target.offsetHeight; |
+} |
+ |
+function cleanup() { |
+ replaceTextAndWaitForLayout(""); |
+} |
+ |
+function startTest() { |
+ target = document.querySelector("#target"); |
+ PerfTestRunner.measureTime({ run: test, done: cleanup, description: "Per-character font fallback" }); |
+} |