Commit 098ce602 authored by Sebastian's avatar Sebastian

Updated manual-inject tests to conform with naming conventions

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