Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 (function() { | 1 (function() { |
| 2 var templateParagraph = null; | 2 var templateParagraph = null; |
| 3 var templateRegion = null; | 3 var templateRegion = null; |
| 4 var DEFAULT_PARAGRAPH_COUNT = 100; | 4 var DEFAULT_PARAGRAPH_COUNT = 100; |
| 5 var DEFAULT_REGION_COUNT = 100; | 5 var DEFAULT_REGION_COUNT = 100; |
| 6 | 6 |
| 7 function createParagraphNode(breakChance) { | 7 function createParagraphNode(breakChance) { |
| 8 if (!templateParagraph) { | 8 if (!templateParagraph) { |
| 9 templateParagraph = document.createElement("p"); | 9 templateParagraph = document.createElement("p"); |
| 10 templateParagraph.innerHTML = "Lorem ipsum dolor sit amet, consectet ur adipiscing elit. Etiam at turpis placerat sapien congue viverra nec sed felis .\ | 10 templateParagraph.innerHTML = "Lorem ipsum dolor sit amet, consectet ur adipiscing elit. Etiam at turpis placerat sapien congue viverra nec sed felis .\ |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 }, | 81 }, |
| 82 done: function() { | 82 done: function() { |
| 83 document.body.removeChild(article); | 83 document.body.removeChild(article); |
| 84 document.body.removeChild(regions); | 84 document.body.removeChild(regions); |
| 85 templateParagraph = null; | 85 templateParagraph = null; |
| 86 templateRegion = null; | 86 templateRegion = null; |
| 87 } | 87 } |
| 88 }; | 88 }; |
| 89 } | 89 } |
| 90 | 90 |
| 91 function mouseMoveToRegionCenter(region) { | |
| 92 var rect = region.getBoundingClientRect(); | |
| 93 eventSender.mouseMoveTo(rect.left + (rect.width / 2), rect.top + (rect.h eight / 2)); | |
| 94 } | |
| 95 | |
| 96 function performSelection(regionCount) { | |
| 97 var regions = document.getElementsByClassName("region"); | |
| 98 | |
| 99 if (window.eventSender) { | |
| 100 mouseMoveToRegionCenter(regions[0]); | |
| 101 eventSender.mouseDown(); | |
| 102 | |
| 103 for (var i = 1; i < regionCount; i++) | |
| 104 mouseMoveToRegionCenter(regions[i]); | |
| 105 | |
| 106 eventSender.mouseUp(); | |
| 107 } | |
| 108 } | |
| 109 | |
| 110 function createRegionsSelectionTest(regionCount) { | |
|
Julien - ping for review
2013/11/20 05:31:55
Why don't you directly do the following?
window.c
| |
| 111 var article = createArticle(regionCount, 1); | |
| 112 article.className = "articleInFlow"; | |
| 113 var regions = createRegions("600px", "auto", regionCount, "auto"); | |
| 114 document.body.appendChild(article); | |
| 115 document.body.appendChild(regions); | |
| 116 return { | |
| 117 description: "Testing selection with " + regionCount + " regions. Se lect text from first region to last one passing through all the regions.", | |
| 118 run: function() { | |
| 119 performSelection(regionCount); | |
| 120 }, | |
| 121 setup: function() { | |
| 122 window.getSelection().removeAllRanges(); | |
| 123 }, | |
| 124 done: function() { | |
| 125 document.body.removeChild(article); | |
| 126 document.body.removeChild(regions); | |
| 127 templateParagraph = null; | |
| 128 templateRegion = null; | |
| 129 } | |
| 130 }; | |
| 131 } | |
| 132 | |
| 91 window.createRegionsTest = createRegionsTest; | 133 window.createRegionsTest = createRegionsTest; |
| 134 window.createRegionsSelectionTest = createRegionsSelectionTest; | |
| 135 | |
| 92 })(); | 136 })(); |
| OLD | NEW |