[CSS Regions] Minor fixes in regions performance tests
[WebKit-https.git] / PerformanceTests / Layout / RegionsSelection.html
index f098fd92fb6fc751d9ef2e47fe4a39b10c5e7202..9862a9df4bf044d998bd947ea51e3430ff884609 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
     <head>
-        <link rel="stylesheet" href="resources/regions.css" TYPE="text/css"></link>
+        <link rel="stylesheet" href="resources/regions.css" type="text/css"></link>
         <script src="../resources/runner.js"></script>
         <script src="resources/regions.js"></script>
         <style type="text/css">
     <body>
         <pre id="log"></pre>
         <script>
+            function performSelection(paragraphCount) {
+                var paragraphs = document.getElementsByClassName("contentParagraph");
+                var selection = getSelection();
+
+                selection.collapse(paragraphs[0], 0);
+
+                for (var i = 1; i < paragraphCount; i++)
+                    selection.extend(paragraphs[i], 0);
+            }
+
+            function createRegionsSelectionTest(regionCount) {
+                var article = createArticle(regionCount, 1);
+                article.className = "articleInFlow";
+                var regions = createRegions("600px", "auto", regionCount, "auto");
+                document.body.appendChild(article);
+                document.body.appendChild(regions);
+                return {
+                    description: "Testing selection with " + regionCount + " regions. Select text from first region to last one passing through all the regions.",
+                    run: function() {
+                        performSelection(regionCount);
+                    },
+                    setup: function() {
+                        window.getSelection().removeAllRanges();
+                    },
+                    done: function() {
+                        document.body.removeChild(article);
+                        document.body.removeChild(regions);
+                        templateParagraph = null;
+                        templateRegion = null;
+                    }
+                };
+            }
+
             PerfTestRunner.measureTime(createRegionsSelectionTest(100));
         </script>
     </body>