Commit 272bb541 authored by Sebastian's avatar Sebastian

added last test, slight modification to renderjs itself

parent fbb8c3fe
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
Node, FileReader, Blob, navigator, Event, URL) { Node, FileReader, Blob, navigator, Event, URL) {
"use strict"; "use strict";
if (window.hasOwnProperty("renderJS")) {
return;
}
function readBlobAsDataURL(blob) { function readBlobAsDataURL(blob) {
var fr = new FileReader(); var fr = new FileReader();
return new RSVP.Promise(function (resolve, reject) { return new RSVP.Promise(function (resolve, reject) {
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Test Gadget</title>
<script src="../node_modules/rsvp/dist/rsvp-2.0.4.js"></script>
<script src="../dist/renderjs-latest.js"></script>
<script src="inject_parentgadget.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
/*global window, rJS, jIO, FormData */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS) {
"use strict";
rJS(window)
.ready(function (gadget) {
return gadget.getElement()
.push(function (ele) {
ele.dispatchEvent(new Event("rjsready"));
});
});
}(window, rJS));
...@@ -5433,6 +5433,7 @@ ...@@ -5433,6 +5433,7 @@
test('check manual bootstrap', function () { test('check manual bootstrap', function () {
var fixture = document.getElementById("qunit-fixture"), var fixture = document.getElementById("qunit-fixture"),
rjsReadyCalled = false,
iframe; iframe;
fixture.innerHTML = "<iframe id=renderjsIsolatedIframe " + fixture.innerHTML = "<iframe id=renderjsIsolatedIframe " +
"src='./inject_renderjs.html'></iframe>"; "src='./inject_renderjs.html'></iframe>";
...@@ -5465,14 +5466,36 @@ ...@@ -5465,14 +5466,36 @@
}); });
}) })
.then(function () { .then(function () {
var rjsLoaded = iframe.contentWindow.rJS !== undefined;
ok( ok(
iframe.contentWindow.hasOwnProperty("renderJS"), iframe.contentWindow.hasOwnProperty("renderJS"),
"RJS available after inject" "RJS available after inject"
); );
}) })
.then(function () { .then(function () {
// create parentGadget in iframe, then initialize RJS
var parentDiv = iframe.contentDocument.createElement("div"),
tEle;
parentDiv.setAttribute(
"data-gadget-url",
"./inject_parentgadget.html"
);
iframe.contentDocument.body.appendChild(parentDiv);
return new RSVP.Promise(function (resolve, reject) {
// listen for an event fired in the ready function of the parent
// gadget
parentDiv.addEventListener("rjsready", function (e) {
rjsReadyCalled = true;
resolve();
});
// if no event is fired within 500ms, just resolve and fail later
setTimeout(function () {
resolve();
}, 500);
iframe.contentWindow.rJS.manualBootstrap(); iframe.contentWindow.rJS.manualBootstrap();
});
})
.then(function () {
ok(rjsReadyCalled, "RJS correctly bootstrapped and parent is ready");
}) })
.fail(function (error) { .fail(function (error) {
ok(false, error); ok(false, error);
...@@ -5484,4 +5507,3 @@ ...@@ -5484,4 +5507,3 @@
}(document, renderJS, QUnit, sinon, URI, URL, Event, }(document, renderJS, QUnit, sinon, URI, URL, Event,
MutationObserver)); MutationObserver));
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