I'm going to go ahead and check this in for Phil.
Change maxcarlson-20100825-5k4 by maxcarl...@friendly on 2010-08-25 15:58:50 PDT
in /Users/maxcarlson/openlaszlo/trunk2
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: UPDATED: Add pmrpc cross-domain support for calling JS in loaded
iframes/html
Bugs Fixed: LPP-9324 - Add pmrpc to the html component
Technical Reviewer: promanik
QA Reviewer: hminsky
Details: Per our discussion, I reworked the pmrpc stuff to use a separate,
parallel API - callRPC(). The RTE now uses this, but callJavascript() calls
remain as-is. Also, I opted to use a plain-old Function for callbacks so you
can use a closure, which simplified addButton() quite a bit. Phil, perhaps you
can rework this to have rtemanager.js expose its methods directly? Right now,
the method we expose callJavascript() is essentially poking a gaping hole in
the browser cross-domain security model.
Otherwise:
This change makes it possible to call javascript inside and send events from
within iframes loaded from different domains. The technology to do this
(pmrpc) is completely callback based, which forced some changes with the way
callbacks work. html.callRPC() requires a callback argument if you need the
return value for a given call.
credits - Add license from pmrpc.js
html - Include JSON library to serialize callJavascript retrun values. Modify
SWF __iframecallback() and callJavascript() to store callbacks locally now that
return values come back asynchonously.
rte.lzx - Use callbacks where callJavascript() return values are required.
Reorient towards updating the rte.text attribute whenever text changes. Rework
destroy() to finish only after rte.text is updated one last time.
pmrpc - Include library
build - Add dependencies, build target for pmrpc
rtemanager - Rename destroy() -> __destroy(). addButton() expects a second
buttonid arg, which is echoed back. This allows the asynchronous return value
to associate the button ID with the correct callback in rte.lzx.
iframemanager-library - Include pmrpc.js.
iframemanager - Shorten lookups, remove unneeded getIDFromWindow() call, owner
-> __owner. Rework asyncCallback() to pass through the callback ID when
needed, see html.lzx __iframecallback() in swf. callJavascript() now uses
pmrpc to call into the iframe. Leave older direct iframe calling code intact.
Register as a pmrpc server for asyncCallback().
iframestub - Include pmrpc, register as a client for callJavascript() calls and
use iframemanager.asyncCallback(). Replace
parent.lz.embed.iframemanager.getIDFromWindow with window.name.
examples/extensions/html - Add test showing JS script injection failing.
examples/extensions/rte - Use this.text instead of getText().
Tests: examples/extensions/html.lzx and examples/extensions/rte.lzx run as
before.
Files:
M lps/components/extensions/html.lzx
M lps/components/extensions/rte.lzx
M lps/includes/source/build.xml
M lps/includes/source/rtemanager.js
M lps/includes/source/iframemanager-library.lzs
M lps/includes/source/iframemanager.js
M lps/includes/source/iframestub.js
M examples/extensions/html.lzx
M examples/extensions/rte.lzx
Changeset:
http://svn.openlaszlo.org/openlaszlo/patches/maxcarlson-20100825-5k4.tar