Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
renderjs
Commits
9d520789
Commit
9d520789
authored
Apr 22, 2014
by
Thibaut Frain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure redefining native acquired on the root gadget works
parent
b6682be2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
17 deletions
+56
-17
renderjs.js
renderjs.js
+20
-15
test/renderjs_test.js
test/renderjs_test.js
+36
-2
No files found.
renderjs.js
View file @
9d520789
...
@@ -711,7 +711,8 @@
...
@@ -711,7 +711,8 @@
embedded_channel
,
embedded_channel
,
notifyReady
,
notifyReady
,
notifyDeclareMethod
,
notifyDeclareMethod
,
gadget_ready
=
false
;
gadget_ready
=
false
,
last_acquisition_gadget
;
// Create the gadget class for the current url
// Create the gadget class for the current url
if
(
gadget_model_dict
.
hasOwnProperty
(
url
))
{
if
(
gadget_model_dict
.
hasOwnProperty
(
url
))
{
...
@@ -719,6 +720,21 @@
...
@@ -719,6 +720,21 @@
}
}
loading_gadget_promise
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
loading_gadget_promise
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
if
(
window
.
self
===
window
.
top
)
{
if
(
window
.
self
===
window
.
top
)
{
last_acquisition_gadget
=
new
RenderJSGadget
();
last_acquisition_gadget
.
__acquired_method_dict
=
{
getTopURL
:
function
()
{
return
url
;
}
};
// Stop acquisition on the last acquisition gadget
// Do not put this on the klass, as their could be multiple instances
last_acquisition_gadget
.
__aq_parent
=
function
(
method_name
)
{
throw
new
renderJS
.
AcquisitionError
(
"
No gadget provides
"
+
method_name
);
};
// XXX Copy/Paste from declareGadgetKlass
// XXX Copy/Paste from declareGadgetKlass
tmp_constructor
=
function
()
{
tmp_constructor
=
function
()
{
RenderJSGadget
.
call
(
this
);
RenderJSGadget
.
call
(
this
);
...
@@ -738,20 +754,8 @@
...
@@ -738,20 +754,8 @@
// Create the root gadget instance and put it in the loading stack
// Create the root gadget instance and put it in the loading stack
root_gadget
=
new
gadget_model_dict
[
url
]();
root_gadget
=
new
gadget_model_dict
[
url
]();
// Stop acquisition on the original root gadget
setAqParent
(
root_gadget
,
last_acquisition_gadget
);
// Do not put this on the klass, as their could be multiple instances
root_gadget
.
__aq_parent
=
function
(
method_name
)
{
throw
new
renderJS
.
AcquisitionError
(
"
No gadget provides
"
+
method_name
);
};
tmp_constructor
.
prototype
.
__acquired_method_dict
=
{};
// Allow acquisition of getTopURL returning the top gadget path
tmp_constructor
.
allowPublicAcquisition
(
'
getTopURL
'
,
function
()
{
return
root_gadget
.
__path
;
});
}
else
{
}
else
{
// Create the communication channel
// Create the communication channel
embedded_channel
=
Channel
.
build
({
embedded_channel
=
Channel
.
build
({
...
@@ -838,8 +842,9 @@
...
@@ -838,8 +842,9 @@
});
});
});
});
};
};
tmp_constructor
.
prototype
.
__acquired_method_dict
=
{};
}
}
tmp_constructor
.
prototype
.
__acquired_method_dict
=
{};
gadget_loading_klass
=
tmp_constructor
;
gadget_loading_klass
=
tmp_constructor
;
function
init
()
{
function
init
()
{
...
...
test/renderjs_test.js
View file @
9d520789
...
@@ -2765,10 +2765,22 @@
...
@@ -2765,10 +2765,22 @@
test
(
'
Check that the root gadget is cleanly implemented
'
,
function
()
{
test
(
'
Check that the root gadget is cleanly implemented
'
,
function
()
{
var
parsed
=
URI
.
parse
(
window
.
location
.
href
),
var
parsed
=
URI
.
parse
(
window
.
location
.
href
),
getTopURLCalled
=
false
,
parent_path
=
URI
.
build
({
protocol
:
parsed
.
protocol
,
parent_path
=
URI
.
build
({
protocol
:
parsed
.
protocol
,
hostname
:
parsed
.
hostname
,
hostname
:
parsed
.
hostname
,
port
:
parsed
.
port
,
port
:
parsed
.
port
,
path
:
parsed
.
path
}).
toString
();
path
:
parsed
.
path
}).
toString
();
root_gadget_klass
.
declareAcquiredMethod
(
'
getTopURL
'
,
'
getTopURL
'
)
.
allowPublicAcquisition
(
'
getTopURL
'
,
function
()
{
getTopURLCalled
=
true
;
this
.
getTopURL
().
then
(
function
(
topURL
)
{
equal
(
topURL
,
this
.
__path
);
});
return
this
.
getTopURL
();
});
stop
();
stop
();
root_gadget_defer
.
promise
root_gadget_defer
.
promise
.
then
(
function
(
root_gadget
)
{
.
then
(
function
(
root_gadget
)
{
...
@@ -2824,8 +2836,30 @@
...
@@ -2824,8 +2836,30 @@
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
,
{});
equal
(
root_gadget
.
__acquired_method_dict
.
getTopURL
(),
return
new
RSVP
.
Queue
()
window
.
location
.
href
);
.
push
(
function
()
{
return
root_gadget
.
getTopURL
().
then
(
function
(
topURL
)
{
equal
(
topURL
,
root_gadget
.
__path
);
});
})
.
push
(
function
()
{
return
root_gadget
.
declareGadget
(
"
./embedded.html
"
,
{
sandbox
:
'
iframe
'
,
element
:
document
.
querySelector
(
'
#qunit-fixture
'
)
})
.
then
(
function
(
new_gadget
)
{
return
new_gadget
.
__aq_parent
(
'
getTopURL
'
,
[]);
})
.
then
(
function
(
topURL
)
{
equal
(
topURL
,
root_gadget
.
__path
);
})
.
then
(
function
()
{
ok
(
getTopURLCalled
);
})
.
fail
(
function
()
{
ok
(
false
);
});
});
})
})
.
fail
(
function
(
e
)
{
.
fail
(
function
(
e
)
{
ok
(
false
,
e
);
ok
(
false
,
e
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment