Bug 799323 - Make test from bug 793672 more reliable. r=past
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 09 Oct 2012 10:17:27 +0200
changeset 109726 aee9b902040882e31732d3063647862470828c0d
parent 109725 b992224cdd55d70e0bec80c68da428eeb7d3688e
child 109727 55585f89f069054b65fc464d8ba144cdb45459d3
push id16157
push usermh@glandium.org
push dateTue, 09 Oct 2012 08:17:54 +0000
treeherdermozilla-inbound@aee9b9020408 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs799323, 793672
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 799323 - Make test from bug 793672 more reliable. r=past
toolkit/devtools/debugger/tests/unit/test_profiler_actor.js
--- a/toolkit/devtools/debugger/tests/unit/test_profiler_actor.js
+++ b/toolkit/devtools/debugger/tests/unit/test_profiler_actor.js
@@ -109,26 +109,33 @@ function test_profile(aClient, aProfiler
     do_check_eq(typeof aResponse.profile, "object");
     do_check_eq(typeof aResponse.profile.meta, "object");
     do_check_eq(typeof aResponse.profile.meta.platform, "string");
     do_check_eq(typeof aResponse.profile.threads, "object");
     do_check_eq(typeof aResponse.profile.threads[0], "object");
     do_check_eq(typeof aResponse.profile.threads[0].samples, "object");
     do_check_neq(aResponse.profile.threads[0].samples.length, 0);
 
-    // A sample around the middle of the list is expected to have been
-    // in the busy wait above.
-    var sample = aResponse.profile.threads[0].samples[Math.floor(aResponse.profile.threads[0].samples.length / 2)];
-    do_check_eq(sample.name, "(root)");
-    do_check_eq(typeof sample.frames, "object");
-    do_check_neq(sample.frames.length, 0);
-    do_check_true(sample.frames.some(function(f) {
-                    return (f.line == stack.lineNumber) &&
-                           (f.location == stack.name + " (" + stack.filename + ":" + funcLine + ")");
-                  }));
+    function some(array, cb) {
+      for (var i = array.length; i; i--) {
+        if (cb(array[i - 1]))
+          return true;
+      }
+      return false;
+    }
+    // At least one sample is expected to have been in the busy wait above.
+    do_check_true(some(aResponse.profile.threads[0].samples, function(sample) {
+      return sample.name == "(root)" &&
+             typeof sample.frames == "object" &&
+             sample.frames.length != 0 &&
+             sample.frames.some(function(f) {
+               return (f.line == stack.lineNumber) &&
+                      (f.location == stack.name + " (" + stack.filename + ":" + funcLine + ")");
+             });
+    }));
 
     aClient.request({ to: aProfiler, type: "stopProfiler" }, function (aResponse) {
       do_check_eq(typeof aResponse.msg, "string");
       aClient.request({ to: aProfiler, type: "isActive" }, function (aResponse) {
         do_check_false(aResponse.isActive);
         aClient.close(function() {
           test_profiler_status();
         });