Index: distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/ScriptingTest.java
===================================================================
--- distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/ScriptingTest.java	(revision 0)
+++ distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/ScriptingTest.java	(revision 0)
@@ -0,0 +1,110 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.it.ui;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.xwiki.it.ui.elements.WikiEditPage;
+import org.xwiki.it.ui.framework.AbstractAdminAuthenticatedTest;
+
+/**
+ * Test script macros.
+ * 
+ * @version $Id$
+ * @since 2.4
+ */
+public class ScriptingTest extends AbstractAdminAuthenticatedTest
+{
+    private WikiEditPage page;
+
+    @Override
+    @Before
+    public void setUp()
+    {
+        super.setUp();
+
+        page = new WikiEditPage();
+        page.switchToEdit("Test", "ScriptTest");
+        page.setTitle("Test");
+        page.clickSaveAndView();
+    }
+
+    @Test
+    public void testNestedEvaluation()
+    {
+        page.switchToEdit("Test", "ScriptTest");
+        page.setContent("{{html wiki=\"true\"}}\n{{velocity}}\n#set($x = \"script test\")\n$x\n"
+            + "{{/velocity}}\n{{/html}}\n");
+        page.clickSaveAndView();
+
+        // check that the nested script is evaluated
+        WebElement content = getDriver().findElement(By.xpath("//div[@id='xwikicontent']/p"));
+        Assert.assertEquals("Invalid content", "script test", content.getText());
+    }
+
+    @Test
+    public void testNestedInline()
+    {
+        page.switchToEdit("Test", "ScriptTest");
+        page.setContent("text {{velocity}}\n\n{{html}}<strong>$doc.fullName</strong>{{/html}}\n\n{{/velocity}} text");
+        page.clickSaveAndView();
+
+        // check that the inner text is inline despite having empty lines around html
+        WebElement content = getDriver().findElement(By.id("xwikicontent"));
+        Assert.assertEquals("Invalid content", "text Test.ScriptTest text", content.getText());
+        long numParagraphs = getDriver().findElements(By.xpath("//div[@id='xwikicontent']//p")).size();
+        Assert.assertEquals("Content is not inline", 1, numParagraphs);
+    }
+
+    @Test
+    public void testNestedNotInline()
+    {
+        page.switchToEdit("Test", "ScriptTest");
+        page.setContent("text\n\n{{velocity}}{{html}}<strong>$doc.fullName</strong>{{/html}}{{/velocity}}\n\ntext");
+        page.clickSaveAndView();
+
+        // check that inner text is not inline
+        WebElement content = getDriver().findElement(By.id("xwikicontent"));
+        Assert.assertEquals("Invalid content", "text\nTest.ScriptTest\ntext", content.getText());
+        long numParagraphs = getDriver().findElements(By.xpath("//div[@id='xwikicontent']//p")).size();
+        Assert.assertEquals("Invalid number of paragraphs", 3, numParagraphs);
+    }
+
+    @Test
+    public void testNoNestedScripts()
+    {
+        page.switchToEdit("Test", "ScriptTest");
+        page.setContent("{{velocity}}\n{{html wiki=\"true\"}}<strong>"
+            + "{{velocity}}\\$doc.fullName{{/velocity}}</strong>{{/html}}\n{{/velocity}}");
+        page.clickSaveAndView();
+
+        // check that the content does not contain Test.ScriptTest anywhere
+        WebElement content = getDriver().findElement(By.id("xwikicontent"));
+        Assert.assertFalse("The nested script was evaluated", content.getText().contains("Test.ScriptTest"));
+
+        // check that the nested script produced an error message
+        WebElement error = getDriver().findElement(By.xpath("//div[@id='xwikicontent']/p/strong"
+            + "/span[@class='xwikirenderingerror']"));
+        Assert.assertNotNull("No error message on nested scripts", error);
+    }
+}

Property changes on: distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/ScriptingTest.java
___________________________________________________________________
Added: svn:keywords
   + Author Id Revision HeadURL
Added: svn:eol-style
   + native

