Bug 1354163 - Wait until there are intersection records to observe. Prevents an intermittent test failure, r=jet
authorTobias Schneider <schneider@jancona.com>
Fri, 14 Apr 2017 16:08:09 -0700
changeset 401519 65cf5283b925a94c31519729a0fe81507b92dc98
parent 401518 940919c5af9026b3c347b0225abdfc07a0b99a42
child 401520 e0f666b2d3c22e70dc1ad18d7777cb501067a208
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjet
bugs1354163
milestone55.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 1354163 - Wait until there are intersection records to observe. Prevents an intermittent test failure, r=jet
dom/base/test/test_intersectionobservers.html
--- a/dom/base/test/test_intersectionobservers.html
+++ b/dom/base/test/test_intersectionobservers.html
@@ -979,39 +979,41 @@ limitations under the License.
         targetEl4.src = "http://example.org/tests/dom/base/test/intersectionobserver_cross_domain_iframe.html";
 
       });
     
     });
 
     describe('takeRecords', function() {
 
-      it('supports getting records before the callback is invoked',
-          function(done) {
+      it('supports getting records before the callback is invoked', function(done) {
 
         var lastestRecords = [];
         io = new IntersectionObserver(function(records) {
           lastestRecords = lastestRecords.concat(records);
         }, {root: rootEl});
         io.observe(targetEl1);
 
-        window.requestAnimationFrame && requestAnimationFrame(function() {
+        window.requestAnimationFrame && requestAnimationFrame(function wait() {
           lastestRecords = lastestRecords.concat(io.takeRecords());
+          if (!lastestRecords.length) {
+            requestAnimationFrame(wait);
+            return;
+          }
+          callDelayed(function() {
+            expect(lastestRecords.length).to.be(1);
+            expect(lastestRecords[0].intersectionRatio).to.be(1);
+            done();
+          }, ASYNC_TIMEOUT);
         });
-
-        callDelayed(function() {
-          expect(lastestRecords.length).to.be(1);
-          expect(lastestRecords[0].intersectionRatio).to.be(1);
-          done();
-        }, ASYNC_TIMEOUT);
+        
       });
 
     });
 
-
     describe('unobserve', function() {
 
       it('removes targets from the internal store', function(done) {
 
         var spy = sinon.spy();
         io = new IntersectionObserver(spy, {root: rootEl});
 
         runSequence([