Bug 1276490 - Do not use Math.random() to create unique values to avoid intermittent failrues. r?jgraham draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Tue, 31 May 2016 06:51:27 +0900
changeset 373056 635efa0b0ce8807099899dccd0d810bfe0da1a36
parent 372909 3435dd7ad71fe9003bdeee18fd38d815e033beef
child 522315 7ce4e0d19f0b81e52fb4a84b21da112a6592476a
push id19667
push userhiikezoe@mozilla-japan.org
push dateMon, 30 May 2016 21:55:36 +0000
reviewersjgraham
bugs1276490
milestone49.0a1
Bug 1276490 - Do not use Math.random() to create unique values to avoid intermittent failrues. r?jgraham MozReview-Commit-ID: 3QHrpCTpEzM
testing/web-platform/tests/performance-timeline/po-resource.html
--- a/testing/web-platform/tests/performance-timeline/po-resource.html
+++ b/testing/web-platform/tests/performance-timeline/po-resource.html
@@ -10,21 +10,25 @@ New resources will <a href="https://w3c.
 </p>
 <div id="log"></div>
 <script>
   async_test(function (t) {
     function path(pathname) {
       var filename = pathname.substring(pathname.lastIndexOf('/')+1);
       return pathname.substring(0, pathname.length - filename.length);
     }
+    var gUniqueCounter = 0;
+    function generateUniqueValues() {
+      return Date.now() + "-" + (++gUniqueCounter);
+    }
     var stored_entries = [];
     var img_location = document.location.origin + path(document.location.pathname)
        + "resources/square.png?random=";
-    var img1 = img_location + Math.floor(Math.random() * 100);
-    var img2 = img_location + Math.floor(Math.random() * 1000);
+    var img1 = img_location + generateUniqueValues();
+    var img2 = img_location + generateUniqueValues();
     var observer = new PerformanceObserver(
         t.step_func(function (entryList, obs) {
           stored_entries =
             stored_entries.concat(entryList.getEntriesByType("resource"));
           if (stored_entries.length >= 2) {
             checkEntries(stored_entries,
               [{ entryType: "resource", name: img1},
                { entryType: "resource", name: img2}]);