Commit 84bcf0e9 authored by Romain Courteaud's avatar Romain Courteaud

Iframe: ensure all channels are OK before calling ready

parent 987147b7
This diff is collapsed.
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
(modification_dict.foo === 'bar'); (modification_dict.foo === 'bar');
state_change_count += 1; state_change_count += 1;
}; };
gk.ready(function () {
gk.ready(function (g) {
ready_called = true; ready_called = true;
}) })
.setState(init_state) .setState(init_state)
......
...@@ -4868,7 +4868,8 @@ ...@@ -4868,7 +4868,8 @@
// Check that declare gadget returns the gadget // Check that declare gadget returns the gadget
var gadget = new RenderJSGadget(), var gadget = new RenderJSGadget(),
acquire_called = false, acquire_called = false,
url = "./embedded.html"; url = "./embedded.html",
new_gadget;
gadget.__aq_parent = function (method_name, argument_list) { gadget.__aq_parent = function (method_name, argument_list) {
acquire_called = true; acquire_called = true;
...@@ -4889,9 +4890,11 @@ ...@@ -4889,9 +4890,11 @@
stop(); stop();
gadget.declareGadget(url, { gadget.declareGadget(url, {
sandbox: 'iframe', sandbox: 'iframe',
element: document.getElementById('qunit-fixture') element: document.getElementById('qunit-fixture'),
scope: 'foobar'
}) })
.then(function (new_gadget) { .then(function (sub_gadget) {
new_gadget = sub_gadget;
return new RSVP.Queue() return new RSVP.Queue()
// Method returns an RSVP.Queue // Method returns an RSVP.Queue
...@@ -4901,12 +4904,14 @@ ...@@ -4901,12 +4904,14 @@
result instanceof RSVP.Queue, result instanceof RSVP.Queue,
"iframe method should return Queue" "iframe method should return Queue"
); );
return result;
}) })
/*
// Check that ready function are called // Check that ready function are called
.push(function () { .push(function () {
return new_gadget.wasReadyCalled(); return new_gadget.wasReadyCalled();
}) })
*/
.push(function (result) { .push(function (result) {
equal(result, true); equal(result, true);
}) })
...@@ -5776,7 +5781,7 @@ ...@@ -5776,7 +5781,7 @@
fixture.innerHTML = fixture.innerHTML =
"<iframe id=renderjsIframe src='./not_declared_gadget.html'></iframe>"; "<iframe id=renderjsIframe src='./not_declared_gadget.html'></iframe>";
stop(); stop();
return RSVP.delay(900) return RSVP.delay(1500)
.then(function () { .then(function () {
var iframe = document.getElementById('renderjsIframe'), var iframe = document.getElementById('renderjsIframe'),
acquisition_div = iframe.contentWindow. acquisition_div = iframe.contentWindow.
...@@ -5820,8 +5825,6 @@ ...@@ -5820,8 +5825,6 @@
return; return;
} }
iframe_text = iframe_body.textContent; iframe_text = iframe_body.textContent;
/*global console*/
// console.log(iframe_text);
if (iframe_text.indexOf('Page changed') !== -1) { if (iframe_text.indexOf('Page changed') !== -1) {
// Final page // Final page
ok(true, iframe_text); ok(true, iframe_text);
...@@ -5872,6 +5875,9 @@ ...@@ -5872,6 +5875,9 @@
iframe.addEventListener("load", function (evt) { iframe.addEventListener("load", function (evt) {
resolve(evt.target.result); resolve(evt.target.result);
}); });
})
.then(function () {
return RSVP.delay(1100);
}) })
.then(function () { .then(function () {
var iframe_body = iframe.contentWindow.document.body, var iframe_body = iframe.contentWindow.document.body,
...@@ -5946,7 +5952,7 @@ ...@@ -5946,7 +5952,7 @@
// if no event is fired within 500ms, just resolve and fail later // if no event is fired within 500ms, just resolve and fail later
window.setTimeout(function () { window.setTimeout(function () {
reject("Timeout, RenderJS is not Ready"); reject("Timeout, RenderJS is not Ready");
}, 500); }, 3000);
iframe.contentWindow.rJS.manualBootstrap(); iframe.contentWindow.rJS.manualBootstrap();
}); });
}) })
......
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
rJS(window) rJS(window)
.ready(function (gadget) { .ready(function (gadget) {
return gadget.getElement() return gadget.element.dispatchEvent(new Event("rjsready"));
.push(function (element) {
element.dispatchEvent(new Event("rjsready"));
});
}); });
}(window, rJS)); }(window, rJS));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment