snoopdave commented on code in PR #331:
URL: https://github.com/apache/roller/pull/331#discussion_r4636770774
##########
app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp:
##########
@@ -146,7 +155,19 @@
<%-- Rich text editor functions --%>
+ // Entries with HTML that Summernote would run or drop open in the textarea
+ // as HTML; see rich-editor-content.js. Summernote starts the editor on any
+ // call, so every call checks this first.
+ var richEditorStarted = false;
+
$(document).ready(function () {
+ if
(RollerRichEditor.hasActiveHtml(document.getElementById('edit_content').value))
{
+ $('#edit_content_html_notice').show();
+
RollerRichEditor.trackCursor(document.getElementById('edit_content'));
+ $("#edit_content").one("change", warnBeforeLeaving);
Review Comment:
**Important:** A textarea `change` event waits until the field loses focus.
If an author edits this fallback and closes the tab while it remains focused,
the leave-page warning has not been installed. Listen for the first `input`
event instead, and trigger that event after programmatic media insertion.
##########
it-selenium/src/test/java/org/apache/roller/selenium/editor/RichEditorContentIT.java:
##########
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.roller.selenium.editor;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.firefox.FirefoxOptions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Runs the entry editor's rich-editor-content.js in a blank page in Firefox,
+ * without a Roller server: which entries open in the HTML textarea instead of
+ * the rich editor, and where the textarea fallback inserts media files.
+ *
+ * <p>The module's verify phase starts Roller in Jetty first. To run just this
+ * class without it, from it-selenium:
+ * {@code mvn test-compile failsafe:integration-test failsafe:verify
-Dit.test=RichEditorContentIT}
+ */
+public class RichEditorContentIT {
+
+ private static final String[] OPEN_IN_THE_TEXTAREA = {
+ "<script>document.title = 'x'</script>",
+ "<p>text</p><img src=\"x.png\" onerror=\"document.title = 'x'\">",
+ "<p ONCLICK=\"go()\">text</p>",
+ "<a href=\"javascript:go()\">link</a>",
+ "<a href=\" JaVa	Script:go()\">link</a>",
+ "<a href=\"javascript:go()\">link</a>",
+ "<a href=\"vbscript:go\">link</a>",
+ "<img src=\"a.png\" srcset=\"a.png 1x, javascript:go() 2x\">",
+ "<svg><a xlink:href=\"javascript:go()\"><text>x</text></a></svg>",
+ "<form><button formaction=\"javascript:go()\">x</button></form>",
+ "<form action=\"javascript:go()\"></form>",
+ "<object data=\"x.swf\"></object>",
+ "<video poster=\"javascript:go()\"></video>",
+ "<table background=\"javascript:go()\"><tr><td>x</td></tr></table>",
+ "<blockquote cite=\"javascript:go()\">x</blockquote>",
+ "<iframe src=\"https://www.youtube.com/embed/x\"></iframe>",
+ "<style>body { display: none }</style>",
+ "<td onclick=\"go()\">cell outside a table</td>",
+ "<caption onmouseover=\"go()\">x</caption>",
+ "<template><img src=x onerror=\"go()\"></template>",
+ "<noscript><p title=\"</noscript><img src=x
onerror=go()>\"></noscript>",
+ "<textarea><img src=x onerror=go()></textarea>",
+ "<xmp><img src=x onerror=go()></xmp>",
+ "<noembed><img src=x onerror=go()></noembed>",
+ "<title><img src=x onerror=go()></title>",
+ "<form><math><mtext></form><form><mglyph><style></math><img src
onerror=go()>",
Review Comment:
**Important:** The browser test in #319 includes one additional MathML/table
parsing case beside these cases, but this Selenium test omits it. Add the
equivalent input to `OPEN_IN_THE_TEXTAREA` and check its expected result in
Firefox.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]