Bug 1313972 - Avoid racing condition by making sure postMessage events are consumed by the correct tests. r=smaug

This commit is contained in:
Tobias Schneider 2017-04-12 10:20:05 -07:00
parent d4925f9157
commit 8287bed367
4 changed files with 27 additions and 11 deletions

View File

@ -0,0 +1,24 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
#target5 {
position: absolute;
top: 0px;
left: 0px;
width: 20px;
height: 20px;
background: #f00;
}
</style>
<body>
<div id="target5"></div>
<script>
var io = new IntersectionObserver(function (records) {
console.log(records[0].rootBounds, location.href);
window.parent.postMessage(records[0].rootBounds == null, 'http://mochi.test:8888');
}, {});
io.observe(document.getElementById("target5"));
</script>
</body>
</html>

View File

@ -13,12 +13,5 @@
</style>
<body>
<div id="target5"></div>
<script>
var io = new IntersectionObserver(function (records) {
window.parent.postMessage(records[0].rootBounds == null, 'http://mochi.test:8888');
io.disconnect();
}, {});
io.observe(document.getElementById("target5"));
</script>
</body>
</html>

View File

@ -27,7 +27,6 @@
records[0].rootBounds.bottom === viewportHeight &&
records[0].rootBounds.height === viewportHeight;
window.opener.postMessage(passed, '*');
io.disconnect();
});
io.observe(document.getElementById("target"));
</script>

View File

@ -921,7 +921,7 @@ limitations under the License.
callDelayed(function () {
expect(spy.callCount).to.be(1);
done();
}, ASYNC_TIMEOUT);
}, ASYNC_TIMEOUT * 3);
});
});
@ -970,11 +970,11 @@ limitations under the License.
it('rootBounds should is set to null for cross-origin observations', function(done) {
window.onmessage = function (e) {
expect(e.data).to.be.ok();
expect(e.data).to.be(true);
done();
};
targetEl4.src = "http://example.org/tests/dom/base/test/intersectionobserver_iframe.html";
targetEl4.src = "http://example.org/tests/dom/base/test/intersectionobserver_cross_domain_iframe.html";
});