Commit 68780336 authored by Romain Courteaud's avatar Romain Courteaud

aq_parent is not part of the API.

Use declareAcquiredMethod instead.
parent d267fc0e
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
if (error instanceof renderJS.AcquisitionError) { if (error instanceof renderJS.AcquisitionError) {
return gadget.aq_parent(method_name, argument_list); return gadget.__aq_parent(method_name, argument_list);
} }
throw error; throw error;
}); });
...@@ -359,8 +359,8 @@ ...@@ -359,8 +359,8 @@
// Set the HTML context // Set the HTML context
.push(function (gadget_instance) { .push(function (gadget_instance) {
var i; var i;
// Define aq_parent to reach parent gadget // Define __aq_parent to reach parent gadget
gadget_instance.aq_parent = function (method_name, argument_list) { gadget_instance.__aq_parent = function (method_name, argument_list) {
return acquire.apply(parent_gadget, [method_name, argument_list]); return acquire.apply(parent_gadget, [method_name, argument_list]);
}; };
// Drop the current loading klass info used by selector // Drop the current loading klass info used by selector
...@@ -723,7 +723,7 @@ ...@@ -723,7 +723,7 @@
// Stop acquisition on the original root gadget // Stop acquisition on the original root gadget
// Do not put this on the klass, as their could be multiple instances // Do not put this on the klass, as their could be multiple instances
root_gadget.aq_parent = function (method_name) { root_gadget.__aq_parent = function (method_name) {
throw new renderJS.AcquisitionError( throw new renderJS.AcquisitionError(
"No gadget provides " + method_name "No gadget provides " + method_name
); );
...@@ -796,8 +796,8 @@ ...@@ -796,8 +796,8 @@
tmp_constructor.allowPublicAcquisition = tmp_constructor.allowPublicAcquisition =
RenderJSGadget.allowPublicAcquisition; RenderJSGadget.allowPublicAcquisition;
// Define aq_parent to inform parent window // Define __aq_parent to inform parent window
tmp_constructor.prototype.aq_parent = function (method_name, tmp_constructor.prototype.__aq_parent = function (method_name,
argument_list) { argument_list) {
return new RSVP.Promise(function (resolve, reject) { return new RSVP.Promise(function (resolve, reject) {
embedded_channel.call({ embedded_channel.call({
......
...@@ -1306,7 +1306,7 @@ ...@@ -1306,7 +1306,7 @@
}); });
}); });
test('returns aq_parent result if acquired_method raises AcquisitionError', test('returns __aq_parent result if acquired_method raises AcquisitionError',
function () { function () {
// Subclass RenderJSGadget to not pollute its namespace // Subclass RenderJSGadget to not pollute its namespace
var Klass = function () { var Klass = function () {
...@@ -1314,7 +1314,7 @@ ...@@ -1314,7 +1314,7 @@
}, gadget, }, gadget,
i = 0, i = 0,
aq_dynamic_called = false, aq_dynamic_called = false,
aq_parent_called = false, __aq_parent_called = false,
original_method_name = "foo", original_method_name = "foo",
original_argument_list = ["foobar", "barfoo"]; original_argument_list = ["foobar", "barfoo"];
Klass.prototype = new RenderJSGadget(); Klass.prototype = new RenderJSGadget();
...@@ -1330,14 +1330,14 @@ ...@@ -1330,14 +1330,14 @@
aq_dynamic_called = true; aq_dynamic_called = true;
equal(i, 0, "aquired_method called first"); equal(i, 0, "aquired_method called first");
i += 1; i += 1;
throw new renderJS.AcquisitionError("please call aq_parent!"); throw new renderJS.AcquisitionError("please call __aq_parent!");
}; };
gadget = new Klass(); gadget = new Klass();
gadget.aq_parent = function (method_name, argument_list) { gadget.__aq_parent = function (method_name, argument_list) {
aq_parent_called = true; __aq_parent_called = true;
equal(i, 1, "aq_parent called after acquired_method"); equal(i, 1, "__aq_parent called after acquired_method");
equal(this, gadget, "Context should be kept"); equal(this, gadget, "Context should be kept");
equal(method_name, original_method_name, "Method name should be kept"); equal(method_name, original_method_name, "Method name should be kept");
deepEqual(argument_list, original_argument_list, deepEqual(argument_list, original_argument_list,
...@@ -1351,20 +1351,20 @@ ...@@ -1351,20 +1351,20 @@
.then(function (result) { .then(function (result) {
equal(result, "FOO"); equal(result, "FOO");
equal(aq_dynamic_called, true); equal(aq_dynamic_called, true);
equal(aq_parent_called, true); equal(__aq_parent_called, true);
}) })
.always(function () { .always(function () {
start(); start();
}); });
}); });
test('returns aq_parent result if acquired_method does not exists', test('returns __aq_parent result if acquired_method does not exists',
function () { function () {
// Subclass RenderJSGadget to not pollute its namespace // Subclass RenderJSGadget to not pollute its namespace
var Klass = function () { var Klass = function () {
RenderJSGadget.call(this); RenderJSGadget.call(this);
}, gadget, }, gadget,
aq_parent_called = false, __aq_parent_called = false,
original_method_name = "foo", original_method_name = "foo",
original_argument_list = ["foobar", "barfoo"]; original_argument_list = ["foobar", "barfoo"];
Klass.prototype = new RenderJSGadget(); Klass.prototype = new RenderJSGadget();
...@@ -1377,8 +1377,8 @@ ...@@ -1377,8 +1377,8 @@
gadget = new Klass(); gadget = new Klass();
gadget.aq_parent = function (method_name, argument_list) { gadget.__aq_parent = function (method_name, argument_list) {
aq_parent_called = true; __aq_parent_called = true;
equal(this, gadget, "Context should be kept"); equal(this, gadget, "Context should be kept");
equal(method_name, original_method_name, "Method name should be kept"); equal(method_name, original_method_name, "Method name should be kept");
deepEqual(argument_list, original_argument_list, deepEqual(argument_list, original_argument_list,
...@@ -1391,14 +1391,14 @@ ...@@ -1391,14 +1391,14 @@
gadget.checkIfAqDynamicIsUndefined("foobar", "barfoo") gadget.checkIfAqDynamicIsUndefined("foobar", "barfoo")
.then(function (result) { .then(function (result) {
equal(result, "FOO"); equal(result, "FOO");
equal(aq_parent_called, true); equal(__aq_parent_called, true);
}) })
.always(function () { .always(function () {
start(); start();
}); });
}); });
test('fails if aq_parent throws an error', function () { test('fails if __aq_parent throws an error', function () {
// Subclass RenderJSGadget to not pollute its namespace // Subclass RenderJSGadget to not pollute its namespace
var Klass = function () { var Klass = function () {
RenderJSGadget.call(this); RenderJSGadget.call(this);
...@@ -1413,7 +1413,7 @@ ...@@ -1413,7 +1413,7 @@
gadget = new Klass(); gadget = new Klass();
gadget.aq_parent = function () { gadget.__aq_parent = function () {
throw original_error; throw original_error;
}; };
...@@ -1428,7 +1428,7 @@ ...@@ -1428,7 +1428,7 @@
}); });
}); });
test('fails if aq_parent is not defined', function () { test('fails if __aq_parent is not defined', function () {
// Subclass RenderJSGadget to not pollute its namespace // Subclass RenderJSGadget to not pollute its namespace
var Klass = function () { var Klass = function () {
RenderJSGadget.call(this); RenderJSGadget.call(this);
...@@ -1447,7 +1447,7 @@ ...@@ -1447,7 +1447,7 @@
.fail(function (error) { .fail(function (error) {
ok(error instanceof TypeError); ok(error instanceof TypeError);
ok((error.message === ok((error.message ===
"gadget.aq_parent is not a function") || "gadget.__aq_parent is not a function") ||
(error.message === (error.message ===
"undefined is not a function"), error); "undefined is not a function"), error);
}) })
...@@ -1507,17 +1507,17 @@ ...@@ -1507,17 +1507,17 @@
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// RenderJSGadget.aq_parent // RenderJSGadget.__aq_parent
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
module("RenderJSGadget.aq_parent", { module("RenderJSGadget.__aq_parent", {
setup: function () { setup: function () {
renderJS.clearGadgetKlassList(); renderJS.clearGadgetKlassList();
} }
}); });
test('aq_parent does not exist by default', function () { test('__aq_parent does not exist by default', function () {
var gadget = new RenderJSGadget(); var gadget = new RenderJSGadget();
equal(gadget.aq_parent, undefined); equal(gadget.__aq_parent, undefined);
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -1761,7 +1761,7 @@ ...@@ -1761,7 +1761,7 @@
ok(gadget instanceof RenderJSGadget); ok(gadget instanceof RenderJSGadget);
ok(gadget instanceof RenderJSIframeGadget); ok(gadget instanceof RenderJSIframeGadget);
ok(RenderJSIframeGadget !== RenderJSGadget); ok(RenderJSIframeGadget !== RenderJSGadget);
ok(gadget.aq_parent === undefined); ok(gadget.__aq_parent === undefined);
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -1803,7 +1803,7 @@ ...@@ -1803,7 +1803,7 @@
ok(gadget instanceof RenderJSGadget); ok(gadget instanceof RenderJSGadget);
ok(gadget instanceof RenderJSEmbeddedGadget); ok(gadget instanceof RenderJSEmbeddedGadget);
ok(RenderJSEmbeddedGadget !== RenderJSGadget); ok(RenderJSEmbeddedGadget !== RenderJSGadget);
ok(gadget.aq_parent === undefined); ok(gadget.__aq_parent === undefined);
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -2302,15 +2302,15 @@ ...@@ -2302,15 +2302,15 @@
}); });
}); });
test('Generate aq_parent on created gadget', function () { test('Generate __aq_parent on created gadget', function () {
// Check that aq_parent returns parent gadget acquire result // Check that __aq_parent returns parent gadget acquire result
var gadget = new RenderJSGadget(), var gadget = new RenderJSGadget(),
acquire_called = false, acquire_called = false,
original_method_name = "foo", original_method_name = "foo",
original_argument_list = ["foobar", "barfoo"], original_argument_list = ["foobar", "barfoo"],
html_url = 'http://example.org/files/qunittest/test353.html'; html_url = 'http://example.org/files/qunittest/test353.html';
gadget.aq_parent = function (method_name, argument_list) { gadget.__aq_parent = function (method_name, argument_list) {
acquire_called = true; acquire_called = true;
equal(this, gadget, "Context should be kept"); equal(this, gadget, "Context should be kept");
equal(method_name, original_method_name, "Method name should be kept"); equal(method_name, original_method_name, "Method name should be kept");
...@@ -2327,7 +2327,7 @@ ...@@ -2327,7 +2327,7 @@
stop(); stop();
gadget.declareGadget(html_url) gadget.declareGadget(html_url)
.then(function (new_gadget) { .then(function (new_gadget) {
return new_gadget.aq_parent( return new_gadget.__aq_parent(
original_method_name, original_method_name,
original_argument_list original_argument_list
); );
...@@ -2517,7 +2517,7 @@ ...@@ -2517,7 +2517,7 @@
acquire_called = false, acquire_called = false,
url = "./embedded.html"; url = "./embedded.html";
gadget.aq_parent = function (method_name, argument_list) { gadget.__aq_parent = function (method_name, argument_list) {
acquire_called = true; acquire_called = true;
equal(this, gadget, "Context should be kept"); equal(this, gadget, "Context should be kept");
if (method_name === "acquireMethodRequested") { if (method_name === "acquireMethodRequested") {
...@@ -2791,7 +2791,7 @@ ...@@ -2791,7 +2791,7 @@
ok(/^<div>\s*<h1 id="qunit-header">/.test(html), html); ok(/^<div>\s*<h1 id="qunit-header">/.test(html), html);
ok(root_gadget instanceof RenderJSGadget); ok(root_gadget instanceof RenderJSGadget);
ok(root_gadget_klass, root_gadget.constructor); ok(root_gadget_klass, root_gadget.constructor);
ok(root_gadget.aq_parent !== undefined); ok(root_gadget.__aq_parent !== undefined);
ok(root_gadget.hasOwnProperty("__sub_gadget_dict")); ok(root_gadget.hasOwnProperty("__sub_gadget_dict"));
deepEqual(root_gadget.__sub_gadget_dict, {}); deepEqual(root_gadget.__sub_gadget_dict, {});
}) })
...@@ -2803,11 +2803,11 @@ ...@@ -2803,11 +2803,11 @@
}); });
}); });
test('aq_parent fails on the root gadget', function () { test('__aq_parent fails on the root gadget', function () {
stop(); stop();
root_gadget_defer.promise root_gadget_defer.promise
.then(function (root_gadget) { .then(function (root_gadget) {
return root_gadget.aq_parent("foo", "bar"); return root_gadget.__aq_parent("foo", "bar");
}) })
.fail(function (error) { .fail(function (error) {
ok(error instanceof renderJS.AcquisitionError); ok(error instanceof renderJS.AcquisitionError);
......
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