[Libreoffice-commits] online.git: loleaflet/html wsd/LOOLWSD.cpp

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 15 10:02:04 UTC 2020


 loleaflet/html/framed.doc.html |   44 +++++++++++++++++++++++++----------------
 loleaflet/html/framed.html     |   28 ++++++--------------------
 wsd/LOOLWSD.cpp                |   10 ++++++---
 3 files changed, 41 insertions(+), 41 deletions(-)

New commits:
commit 6305cc70fa964e400254b281a734b90c39fcb5e6
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Jan 14 16:54:08 2020 +0000
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Jan 15 11:01:41 2020 +0100

    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 <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

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.
-
 -->
 
 <html>
@@ -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 @@
 
   <body style="user-select: none;">
 
-    <p>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..</p>
+    <h3>PostMessage test harness</h3>
+
+    <h4>Run python InsertText.py script</h4>
     <form id="insert-text-form">
       Click <button onclick="insertText(document.forms['insert-text-form'].elements['source'].value); return false;">here</button> to insert the following text into the document:
       <textarea name="source" value="" rows="5" cols="50"></textarea>
     </form>
 
+    <h4>Run Capitalize.py script</h4>
     <form id="insert-text-form">
       Click <button onclick="capitalize(); return false;">here</button> to capitalize selected text in the document.</br></br>
+    </form>
+
+    <h4>Various other messages to post</h4>
+    <form>
       <button onclick="save(); return false;">Save</button>
       <button onclick="closeDocument(); return false;">Close</button></br></br>
       <button onclick="hide_commands('save'); return false;">Hide Save Commands</button>
@@ -144,15 +149,20 @@
       <button onclick="disable_default_uiaction('UI_Save', false); return false;">Enable default save action</button></br></br>
     </form>
 
-    <p>Modified Status:
-    <span id="ModifiedStatus">Saved</span>
-    </p>
+    <h3>Modified Status: <span id="ModifiedStatus">Saved</span></h3>
+
+    <h3>UI modification</h3>
+    <form id="menubar-toggle">
+      <button onclick="ShowMenubar(false); return false;">Hide Menubar</button>
+      <button onclick="ShowMenubar(true); return false;">Show Menubar</button>
+    </form>
 
-    <!-- The hostname and pathnames below are obviously specific to my
-    personal environment and need to be changed appropriately. Also
-    the hex string needs to be changed of course, to the right one as
-    shown by 'make run'. -->
+    <h3>Document frame</h3>
+    <iframe id="frame" height="1000" width="1000"></iframe>
 
-    <iframe src="http://localhost:9980/loleaflet/ef3c798/loleaflet.html?file_path=file:///home/ash/prj/lo/online/test/data/empty.odt&NotWOPIButIframe=true" height="1000" width="1000"></iframe>
+    <script>
+      var iframe = document.getElementById("frame");
+      iframe.src = "https://localhost:9980/loleaflet/42/loleaflet.html" + window.location.search + "&NotWOPIButIframe=true";
+    </script>
   </body>
 </html>
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
 -->
 
 <html>
@@ -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 <button onclick="callDeleteNamedRange(); return false;">here</button> to delete the named range called <input type="text" name="name">
     </form>
 
-    <h3>UI modification</h3>
-    <form id="menubar-toggle">
-      <button onclick="ShowMenubar(false); return false;">Hide Menubar</button>
-      <button onclick="ShowMenubar(true); return false;">Show Menubar</button>
-    </form>
-
-
     <h3>Document frame</h3>
 
     <!-- The hostname and pathnames below are obviously specific to my
     personal environment and need to be changed appropriately.  -->
 
-    <iframe src="http://localhost:9980/loleaflet/dist/loleaflet.html?file_path=file:///libreoffice/online/test/data/hello-world.ods&NotWOPIButIframe=true" height="1000" width="1000"></iframe>
+    <iframe id="frame" height="1000" width="1000"></iframe>
+    <script>
+      var iframe = document.getElementById("frame");
+      iframe.src = "https://localhost:9980/loleaflet/42/loleaflet.html" + window.location.search + "&NotWOPIButIframe=true";
+    </script>
   </body>
 </html>
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())


More information about the Libreoffice-commits mailing list