From 6305cc70fa964e400254b281a734b90c39fcb5e6 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 14 Jan 2020 16:54:08 +0000 Subject: [PATCH] postMessage tests - advertise them, and do some cleaning. Set the iframe's src in a script so we can pass on a filename cleanly. add a postMessage: sample URI at the end of 'make run' Move some of the more obvious pieces into framed.doc.html. Change-Id: I2bd8215f083bcb16369421ed88acb198808c1fdb Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86787 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky --- loleaflet/html/framed.doc.html | 44 +++++++++++++++++++++------------- loleaflet/html/framed.html | 28 ++++++---------------- wsd/LOOLWSD.cpp | 10 +++++--- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/loleaflet/html/framed.doc.html b/loleaflet/html/framed.doc.html index df0207c84..df68f69fe 100644 --- a/loleaflet/html/framed.doc.html +++ b/loleaflet/html/framed.doc.html @@ -7,14 +7,6 @@ This demonstrates using the Python InsertText.py and Capitalise.py scripts from javascript across iframes. - - To test this, do 'make run', and then in your browser open the - equivalent of - http://snorken.local:9980/loleaflet/3304e9093/framed.doc.html if the - browser is running on a different machine, or - http://localhost:9980/loleaflet/3304e9093/framed.doc.html if running - on the same machine. - --> @@ -82,6 +74,12 @@ }); } + function ShowMenubar(visible) { + var messageId = visible ? 'Show_Menubar' : 'Hide_Menubar'; + window.frames[0].postMessage(JSON.stringify({'MessageId': 'Host_PostmessageReady'}), '*'); + window.frames[0].postMessage(JSON.stringify({'MessageId': messageId}), '*'); + } + // This function is invoked when the iframe posts a message back. function receiveMessage(event) { @@ -126,14 +124,21 @@ -

Note: Set net/frame_ancestors in loolwsd.xml to contain 'file:' (without the quotes, but with the colon), otherwise you will get CSP violation. And force reload, or clear caches, otherwise you might get served from the browser cache..

+

PostMessage test harness

+ +

Run python InsertText.py script

Click to insert the following text into the document:
+

Run Capitalize.py script

Click to capitalize selected text in the document.

+
+ +

Various other messages to post

+


@@ -144,15 +149,20 @@

-

Modified Status: - Saved -

+

Modified Status: Saved

- +

UI modification

+ - +

Document frame

+ + + diff --git a/loleaflet/html/framed.html b/loleaflet/html/framed.html index cee6b610a..036cc8019 100644 --- a/loleaflet/html/framed.html +++ b/loleaflet/html/framed.html @@ -24,13 +24,8 @@ invoke Python functions that list, add, and delete named ranges in a Calc document being edited. - To test this, do 'make run', and then in your browser open the - equivalent of - http://snorken.local:9980/loleaflet/3304e9093/framed.html if the - browser is running on a different machine, or - http://localhost:9980/loleaflet/3304e9093/framed.html if running - on the same machine. - + To test this, do 'make run', and then in your browser open: + https://localhost:9980/loleaflet/dist/framed.html?file_path=/opt/libreoffice/online/test/data/hello-world.ods --> @@ -117,12 +112,6 @@ '*'); } - function ShowMenubar(visible) { - var messageId = visible ? 'Show_Menubar' : 'Hide_Menubar'; - window.frames[0].postMessage(JSON.stringify({'MessageId': 'Host_PostmessageReady'}), '*'); - window.frames[0].postMessage(JSON.stringify({'MessageId': messageId}), '*'); - } - // This function is invoked when the iframe posts a message back. function receiveMessage(event) { @@ -205,18 +194,15 @@ Click to delete the named range called -

UI modification

- - -

Document frame

- + + diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 3efed76e9..0538759ba 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1202,10 +1202,14 @@ void LOOLWSD::initialize(Application& self) Admin::instance().setDefDocProcSettings(docProcSettings, false); #if ENABLE_DEBUG + std::string postMessageURI = + getServiceURI("/loleaflet/dist/framed.doc.html?file_path=" + DEBUG_ABSSRCDIR "/" LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_CALC); std::cerr << "\nLaunch one of these in your browser:\n\n" - << " Writer: " << getLaunchURI(LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_WRITER) << '\n' - << " Calc: " << getLaunchURI(LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_CALC) << '\n' - << " Impress: " << getLaunchURI(LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_IMPRESS) << std::endl; + << " Writer: " << getLaunchURI(LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_WRITER) << '\n' + << " Calc: " << getLaunchURI(LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_CALC) << '\n' + << " Impress: " << getLaunchURI(LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH_IMPRESS) << '\n' + << " postMessage: " << postMessageURI << std::endl; const std::string adminURI = getServiceURI(LOOLWSD_TEST_ADMIN_CONSOLE, true); if (!adminURI.empty())