Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(925)

Issue 2927041: Inline feature to render gadget in inline

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 5 months ago by Kai Feng Zhang
Modified:
13 years, 5 months ago
Base URL:
https://svn.apache.org/repos/asf/shindig/trunk
Visibility:
Public.

Description

We originally posted inlining work directly into the existing container shindig-container/server side components... After reviewing some of these changes and learning more about the features, we've stepped back and refactored those changes as a feature on the common container. I add this new patch, which is based on new common container and its new patch: https://issues.apache.org/jira/browse/SHINDIG-1460 After apply the patch, access http://localhost:8080/container/helloworld_common3.html you would see the inline gadget and iframe gadget being rendered on same page, though they are helloworld gadgets. Jira url: https://issues.apache.org/jira/browse/SHINDIG-1402

Patch Set 1 #

Total comments: 14

Patch Set 2 : A new patch. (1) based on new common container (2) support user prefs for inline gadget #

Total comments: 18

Messages

Total messages: 9
Kai Feng Zhang
13 years, 5 months ago (2010-11-05 08:06:36 UTC) #1
Jasvir
Hi Kai, Some preliminary comments. Just a quick request - the base url for this ...
13 years, 5 months ago (2010-11-09 22:03:13 UTC) #2
Kai Feng Zhang
Thank you jasvir, I just replied your comments and attached a new patch for review. ...
13 years, 5 months ago (2010-11-11 08:08:38 UTC) #3
Kai Feng Zhang
A new patch. (1) based on new common container (2) support user prefs for inline ...
13 years, 5 months ago (2010-11-11 08:11:03 UTC) #4
Kai Feng Zhang
hi jasvir, Thank you very much for code review. Would you please have a time ...
13 years, 5 months ago (2010-11-15 13:29:33 UTC) #5
Jasvir
+fargo http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/features-extras/inline/inline_container.js File extras/src/main/javascript/features-extras/inline/inline_container.js (right): http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/features-extras/inline/inline_container.js#newcode58 extras/src/main/javascript/features-extras/inline/inline_container.js:58: if (this.securityToken_) { I don't understand the consequences ...
13 years, 5 months ago (2010-11-15 20:40:08 UTC) #6
Jasvir Nagra
On Mon, Nov 15, 2010 at 5:29 AM, <kf.zhang@gmail.com> wrote: > hi jasvir, > > ...
13 years, 5 months ago (2010-11-15 20:47:58 UTC) #7
johnfargo
Hi Kai Feng: A few comments on the container piece below -- most of which ...
13 years, 5 months ago (2010-11-17 23:14:01 UTC) #8
Kai Feng Zhang
13 years, 5 months ago (2010-11-19 13:43:07 UTC) #9
The basic idea of this inline implementation is, when shindig server render spec
xml into html and return to client side. Client side will strip html DOM part,
style part and script part, then inject each part into current document orderly.


As described above, we implement inline as a shindig feature now based on above
idea. And that's the only choice we have to support inline gadget for now. We
did look into Caja support in Shindig, but the result is not good enough, if we
have multiple inline gadgets on page with same spec xml, they still have
namespace(name/id conflicts) issues. What would you please suggest to do, to
support inline gadget besides Caja?

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
File extras/src/main/javascript/features-extras/inline/inline_container.js
(right):

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/inline_container.js:33: } else
if (!this.hasFeature_(gadgetInfo, 'pubsub-2') && this.hasFeature_(gadgetInfo,
'inline')) {
Thanks for the suggestion. Can I know how it's going for your caja inline work?
Is there any plan when you guys will contribute back to Shindig?


On 2010/11/17 23:14:01, johnfargo wrote:
> Back when iGoogle did inlining, it also originally OK'd any arbitrary gadget
> that asked to be inlined. Unfortunately, more was needed, since not all
gadgets
> behaved properly (the worst could manipulate page state such that the whole
> thing got borked).
> 
> The steps done were:
> 1. Added a whitelist of acceptable inlined gadgets.
> 2. Realized that one compromised (popular) gadget compromised the user's
entire
> data - ie. the security of the container becomes the min(security of all
> gadgets). Copied all inlined gadgets to a separate data store controlled
> internally.
> 3. Removed inlining altogether in favor of IFRAMEs and (hopefully, finally
> soon!) cajoled gadgets providing security guarantees by design.

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/inline_container.js:58: if
(this.securityToken_) {
This code/method is in common container, gadget_holder.js.

I just copied it here and overwrite it but adding new lines:

window.globals_inline[this.siteId_] = window.globals_inline[this.siteId_] || {};
window.globals_inline[this.siteId_].gadgetInfo = this.gadgetInfo_;
window.globals_inline[this.siteId_].ifrUrl = uri.toString();

To keep each inline gadget's iframe url, then it's able to get it back with
gadgets.util.getUrlParameter() method.

On 2010/11/15 20:40:08, jasvir wrote:
> I don't understand the consequences of messing with st.  Adding fargo.

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/inline_container.js:63:
uri.setQP('mid', String(this.siteId_));
Much clear, thanks.

I just copied method from gadget_holder.js to here for overwriting and added
some specific codes for inline rendering, see above comment.

On 2010/11/17 23:14:01, johnfargo wrote:
> FYI this is no longer really used, and mostly serves to bust caching (as would
> any query param).
> 
> mid was originally intended to disambiguate gadgets on the page, but now
> container code and gadgets.rpc can do so via its own means.
> 
> Past that, the main concept of module_id was invented to facilitate inlining
by
> letting gadget devs write constructs like
> var foo__MODULE_ID__ = "this varname is different for two of the same gadget
on
> the page";
> 
> however, this mechanism only helps two identical gadgets both inlined on the
> page disambiguate their symbols from one another. Symbols introduced by the
> containing page could still conflict.

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/inline_container.js:110: }
Thank you, I will change to use gadgets.io API for this request.

On 2010/11/17 23:14:01, johnfargo wrote:
> You should be able to use gadgets.io.makeNonProxiedRequest rather than
> reimplementing this

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/inline_container.js:113:
xhr.open("GET", this.getIframeUrl_(), true);
I will try to make some server codes, to allow gadget content returned from
metadata request directly. That will save us an extra request which is ifr url
sent to gadget rendering servlet.

On 2010/11/17 23:14:01, johnfargo wrote:
> Is this intended only to work on browsers that support cross-domain XHR, or is
> another implicit requirement that the gadget rendering API be installed on the
> same domain as the container?
> 
> If the latter, that would suggest that other security primitives, like
> locked-domain, are disabled for this as well, allowing any arbitrary gadget to
> be executed on the container's domain. I'd prefer to see gadget content
returned
> instead via the metadata APIs (GadgetsHandler et al)

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/inline_container.js:135: var
scriptsStripped = this.stripScriptAndHtml(strippedContent, stylesStripped);
Remove it soon, thanks.

On 2010/11/17 23:14:01, johnfargo wrote:
> scriptsStripped is unused

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/inline_container.js:173: var
scriptsStripped = stylesStripped.replace(regexp, function() {
On 2010/11/15 20:40:08, jasvir wrote:
> Thank you for fixing the regex to include spaces.  Unfortunately this is still
> insufficient - your regular expression for example matches the appearance of 
> "<script>" with a Turkish "i" which will turn an non-executable block into a
> executable one.
> 
I am just not sure how much possible it would happen for such a string
<script>xxx</script> with Turkish "i" would be rendered back by Shindig server,
and then be turned into an executable script.

> 
> Perhaps I am failing to understand the various strip and inject calls are
> intended to achieve.  Stripping a script block and moving it to the head
changes
> the semantics of the script - even if you ignore deferred scripts.  A script
> that appears at a particular point in an html file sees the DOM up to that
point
> - moving scripts into the head will break those scripts.  Trivial example is:
> 
> <div id="foo"></div>
> <script>alert(document.getElementById('foo'));</script>
> 
> If you move the script into head, the alert will now show null.
> 
The basic idea of this inline implementation is, when shindig server render spec
xml into html and return to client side. Client side will strip html DOM part,
style part and script part, then inject each part into current document orderly.
So for your above example, div#foo will be inject into document first and then
script be put into head and executed. Would you please give some suggestion what
we should do?

> The reason I am objecting is I'd really like to avoid a proliferation of
> different semantics depending on how a gadget is included on the page.  We
don't
> want to place on the gadget developer the burden on testing their gadget
inlined
> and iframed - besides the gadget spec defines the semantics of the Content tag
> to be html - we should break those semantics only for good reason.

As described above, we implement inline as a shindig feature now based on above
idea. And that's the only choice we have to support inline gadget for now. We
did look into Caja support in Shindig, but the result is not good enough, if we
have multiple inline gadgets on page with same spec xml, they still have
namespace(name/id conflicts) issues.

What would you please suggest to do, to support inline gadget besides Caja?

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/inline_container.js:179: var
externalSrc = ss[1].replace(/&amp;/ig, "&");
Good point thanks. We now only see unescaped chars in the script url, not in
other html entities. We would definitely handle them if have when returning from
server side.

On 2010/11/15 20:40:08, jasvir wrote:
> Ah ok so you're expecting to see unescaped html characters in the url.  Should
> you also be unescaping other html entities?

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
File extras/src/main/javascript/features-extras/inline/resource_sharing.js
(right):

http://codereview.appspot.com/2927041/diff/16001/extras/src/main/javascript/f...
extras/src/main/javascript/features-extras/inline/resource_sharing.js:37: var
params = q.toString().split(/[&;]/);
Semicolon is useless here, this line is to split params out with '&' or ';' as
the separator.

I will remove this semicolon. Thanks.

On 2010/11/15 20:40:08, jasvir wrote:
> Why split on semicolon?  Should this code use shindig.uri instead?
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b