Commit 098ce602 authored by Sebastian's avatar Sebastian

Updated manual-inject tests to conform with naming conventions

parent 5c43f74a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"http://www.w3.org/TR/html4/loose.dtd"> "http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
<head> <head>
<script src="./inject_renderjs.js"></script> <script src="./inject_script.js"></script>
</head> </head>
<body></body> <body></body>
</html> </html>
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// can't use RSVP here because its not loaded (neccessarily) // can't use RSVP here because its not loaded (neccessarily)
function test_inject_lib(libsrc, resolve) { function inject_script(src, resolve) {
// inject RSVP // inject RSVP
var script = document.createElement("script"); var script = document.createElement("script");
script.onload = function() { script.onload = function() {
resolve(); resolve();
}; };
script.src = libsrc; script.src = src;
document.body.appendChild(script); document.body.appendChild(script);
} }
...@@ -5433,10 +5433,11 @@ ...@@ -5433,10 +5433,11 @@
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;
// The iframe for an isolated renderjs-free environment
// to test the manual inject
fixture.innerHTML = "<iframe id=renderjsIsolatedIframe " + fixture.innerHTML = "<iframe id=renderjsIsolatedIframe " +
"src='./inject_renderjs.html'></iframe>"; "src='./inject_script.html'></iframe>";
iframe = document.getElementById("renderjsIsolatedIframe"); iframe = document.getElementById("renderjsIsolatedIframe");
stop(); stop();
...@@ -5451,7 +5452,7 @@ ...@@ -5451,7 +5452,7 @@
"RJS NOT available before inject" "RJS NOT available before inject"
); );
return new RSVP.Promise(function (resolve, reject) { return new RSVP.Promise(function (resolve, reject) {
iframe.contentWindow.test_inject_lib( iframe.contentWindow.inject_script(
"../node_modules/rsvp/dist/rsvp-2.0.4.js", "../node_modules/rsvp/dist/rsvp-2.0.4.js",
resolve resolve
); );
...@@ -5459,7 +5460,7 @@ ...@@ -5459,7 +5460,7 @@
}) })
.then(function () { .then(function () {
return new RSVP.Promise(function (resolve, reject) { return new RSVP.Promise(function (resolve, reject) {
iframe.contentWindow.test_inject_lib( iframe.contentWindow.inject_script(
"../dist/renderjs-latest.js", "../dist/renderjs-latest.js",
resolve resolve
); );
...@@ -5476,25 +5477,24 @@ ...@@ -5476,25 +5477,24 @@
var parentDiv = iframe.contentDocument.createElement("div"); var parentDiv = iframe.contentDocument.createElement("div");
parentDiv.setAttribute( parentDiv.setAttribute(
"data-gadget-url", "data-gadget-url",
"./inject_parentgadget.html" "./trigger_rjsready_event_on_ready_gadget.html"
); );
iframe.contentDocument.body.appendChild(parentDiv); iframe.contentDocument.body.appendChild(parentDiv);
return new RSVP.Promise(function (resolve, reject) { return new RSVP.Promise(function (resolve, reject) {
// listen for an event fired in the ready function of the parent // listen for an event fired in the ready function of the parent
// gadget // gadget
parentDiv.addEventListener("rjsready", function (e) { parentDiv.addEventListener("rjsready", function (e) {
rjsReadyCalled = true;
resolve(); resolve();
}); });
// 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 () {
resolve(); reject("Timeout, RenderJS is not Ready");
}, 500); }, 500);
iframe.contentWindow.rJS.manualBootstrap(); iframe.contentWindow.rJS.manualBootstrap();
}); });
}) })
.then(function () { .then(function () {
ok(rjsReadyCalled, "RJS correctly bootstrapped and parent is ready"); ok(true, "RJS correctly bootstrapped and parent is ready");
}) })
.fail(function (error) { .fail(function (error) {
ok(false, error); ok(false, error);
...@@ -5506,3 +5506,4 @@ ...@@ -5506,3 +5506,4 @@
}(document, renderJS, QUnit, sinon, URI, URL, Event, }(document, renderJS, QUnit, sinon, URI, URL, Event,
MutationObserver)); MutationObserver));
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script src="../node_modules/rsvp/dist/rsvp-2.0.4.js"></script> <script src="../node_modules/rsvp/dist/rsvp-2.0.4.js"></script>
<script src="../dist/renderjs-latest.js"></script> <script src="../dist/renderjs-latest.js"></script>
<script src="inject_parentgadget.js" type="text/javascript"></script> <script src="trigger_rjsready_event_on_ready_gadget.js" type="text/javascript"></script>
</head> </head>
<body> <body>
</body> </body>
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
rJS(window) rJS(window)
.ready(function (gadget) { .ready(function (gadget) {
return gadget.getElement() return gadget.getElement()
.push(function (ele) { .push(function (element) {
ele.dispatchEvent(new Event("rjsready")); 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