You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2015/09/02 15:21:42 UTC
svn commit: r1700810 - in /sling/trunk/bundles/scripting/sightly:
js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/
testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/child/
testing-content/src/main...
Author: radu
Date: Wed Sep 2 13:21:42 2015
New Revision: 1700810
URL: http://svn.apache.org/r1700810
Log:
SLING-4989 - The JavaScript Use Provider fails to correctly load script using inheritance
* made sure that an included script can successfully call an inherited script
Added:
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/child/notoverlaid.html
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/grandparent/notoverlaid.js
Modified:
sling/trunk/bundles/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
Modified: sling/trunk/bundles/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java?rev=1700810&r1=1700809&r2=1700810&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java (original)
+++ sling/trunk/bundles/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java Wed Sep 2 13:21:42 2015
@@ -61,7 +61,7 @@ public class Utils {
}
}
if (scriptResource == null) {
- throw new SightlyException("Required script resource could not be located: " + path);
+ throw new SightlyException("Required script resource could not be located: " + path + ". The caller is " + caller.getPath());
}
return scriptResource;
}
@@ -81,6 +81,9 @@ public class Utils {
String parentResourceType = resourceA.getResourceType();
if ("nt:file".equals(parentResourceType)) {
parentResourceType = ResourceUtil.getParent(resourceA.getPath());
+ if (parentResourceType.equals(resourceB.getPath())) {
+ return true;
+ }
}
Resource parentB = resolver.getResource(resourceBSuperType);
while (parentB != null && !"/".equals(parentB.getPath()) && StringUtils.isNotEmpty(resourceBSuperType)) {
Added: sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/child/notoverlaid.html
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/child/notoverlaid.html?rev=1700810&view=auto
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/child/notoverlaid.html (added)
+++ sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/child/notoverlaid.html Wed Sep 2 13:21:42 2015
@@ -0,0 +1,17 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<div id="notoverlaid" data-sly-use.notoverlaid="notoverlaid.js">${notoverlaid.message}</div>
\ No newline at end of file
Added: sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/grandparent/notoverlaid.js
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/grandparent/notoverlaid.js?rev=1700810&view=auto
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/grandparent/notoverlaid.js (added)
+++ sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/useinheritance/grandparent/notoverlaid.js Wed Sep 2 13:21:42 2015
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/*global use*/
+use(function () {
+ 'use strict';
+ return {
+ message: 'notoverlaid'
+ }
+});
\ No newline at end of file
Modified: sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java?rev=1700810&r1=1700809&r2=1700810&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java (original)
+++ sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java Wed Sep 2 13:21:42 2015
@@ -38,7 +38,8 @@ public class SlingSpecificsSightlyIT {
private static final String SLING_TEMPLATE_BAD_IDENTIFIER = "/sightly/template.bad-id.html";
private static final String SLING_JS_USE = "/sightly/use.jsuse.html";
private static final String SLING_JS_DEPENDENCY_RESOLUTION = "/sightly/use-sibling-dependency-resolution.html";
- private static final String SLING_USE_INHERITANCE = "/sightly/useinheritance.html";
+ private static final String SLING_USE_INHERITANCE_WITHOVERLAY = "/sightly/useinheritance.html";
+ private static final String SLING_USE_INHERITANCE_WITHOUTOVERLAY = "/sightly/useinheritance.notoverlaid.html";
@BeforeClass
public static void init() {
@@ -117,8 +118,8 @@ public class SlingSpecificsSightlyIT {
}
@Test
- public void testUseAPIInheritance() {
- String url = launchpadURL + SLING_USE_INHERITANCE;
+ public void testUseAPIInheritanceOverlaying() {
+ String url = launchpadURL + SLING_USE_INHERITANCE_WITHOVERLAY;
String pageContent = client.getStringContent(url, 200);
assertEquals("child.javaobject", HTMLExtractor.innerHTML(url, pageContent, "#javaobj"));
assertEquals("child.javascriptobject", HTMLExtractor.innerHTML(url, pageContent, "#javascriptobj"));
@@ -126,4 +127,11 @@ public class SlingSpecificsSightlyIT {
assertEquals("child.template", HTMLExtractor.innerHTML(url, pageContent, "#templateobj"));
}
+ @Test
+ public void testUseAPIInheritanceWithoutOverlay() {
+ String url = launchpadURL + SLING_USE_INHERITANCE_WITHOUTOVERLAY;
+ String pageContent = client.getStringContent(url, 200);
+ assertEquals("notoverlaid", HTMLExtractor.innerHTML(url, pageContent, "#notoverlaid"));
+ }
+
}