Commit 67f4bc2a authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_js_style: ensure the page is visible in case of loading/rendering error

parent a9f126a2
...@@ -453,6 +453,8 @@ ...@@ -453,6 +453,8 @@
if (style_css_url === null) { if (style_css_url === null) {
// Compatibility with old html format (like in google cache) // Compatibility with old html format (like in google cache)
gadget.element.innerHTML = parsed_content.original_content; gadget.element.innerHTML = parsed_content.original_content;
// Ensure the page is visible in case of error
showPage();
return; return;
} }
return new RSVP.Queue(rJS.declareCSS(style_css_url, document.head)) return new RSVP.Queue(rJS.declareCSS(style_css_url, document.head))
...@@ -460,6 +462,8 @@ ...@@ -460,6 +462,8 @@
// Set again the page content after the css is loaded // Set again the page content after the css is loaded
// to prevent ugly rendering // to prevent ugly rendering
gadget.element.innerHTML = parsed_content.original_content; gadget.element.innerHTML = parsed_content.original_content;
// Ensure the page is visible in case of error
showPage();
}); });
}); });
}); });
......
...@@ -37,12 +37,22 @@ ...@@ -37,12 +37,22 @@
<td>//head/link[@rel='prerender' and @href='jsstyle_demo.html']</td> <td>//head/link[@rel='prerender' and @href='jsstyle_demo.html']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>assertElementPresent</td>
<td>css=html[hidden]</td>
<td></td>
</tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
<td>//header/h1[text()='JS Style Demo']</td> <td>//header/h1[text()='JS Style Demo']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>assertElementNotPresent</td>
<td>css=html[hidden]</td>
<td></td>
</tr>
<tr> <tr>
<td>assertElementPresent</td> <td>assertElementPresent</td>
<td>//header/h1[text()='JS Style Demo']</td> <td>//header/h1[text()='JS Style Demo']</td>
......
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
<td>//head/link[@rel='prerender' and @href='jsstyle_demo_not_loading.html']</td> <td>//head/link[@rel='prerender' and @href='jsstyle_demo_not_loading.html']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>assertElementPresent</td>
<td>css=html[hidden]</td>
<td></td>
</tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
...@@ -55,6 +60,11 @@ ...@@ -55,6 +60,11 @@
<td>//nav[@id='sitemap']/a[text()='Not Loading Style']</td> <td>//nav[@id='sitemap']/a[text()='Not Loading Style']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>assertElementNotPresent</td>
<td>css=html[hidden]</td>
<td></td>
</tr>
<tr> <tr>
<td>assertElementPresent</td> <td>assertElementPresent</td>
<td>//nav[@id='sitemap']/a[text()='Not Loading Style']</td> <td>//nav[@id='sitemap']/a[text()='Not Loading Style']</td>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testJsStyleRenderErrorStyle</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test JS Style Demo Style</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test JS Style Demo Style</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/ERP5Site_createWebJSStyleZuiteTestData?configuration=not_rendering</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Web Site created.</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<!-- Initialize -->
<tr>
<td>open</td>
<td>${base_url}/web_site_module/erp5_web_js_style_test_site/</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//head/link[@rel='prerender' and @href='jsstyle_demo_not_rendering.html']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>css=html[hidden]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//h1[text()='Unhandled Error']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//h1[text()='Unhandled Error']</td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>css=html[hidden]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//h2[text()='Demo error during render']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
...@@ -199,6 +199,11 @@ configuration_dict = { ...@@ -199,6 +199,11 @@ configuration_dict = {
'title': "Not Loading Style", 'title': "Not Loading Style",
'site_map_section_parent': True 'site_map_section_parent': True
}, },
'not_rendering': {
'configuration_style_gadget_url': "jsstyle_demo_not_rendering.html",
'title': "Not Rendering Style",
'site_map_section_parent': True
},
'favicon': { 'favicon': {
'title': 'Favicon', 'title': 'Favicon',
'configuration_favicon_url': "favicon.ico", 'configuration_favicon_url': "favicon.ico",
......
<html>
<head>
<script src="portal_skins/erp5_xhtml_style/rsvp.js"></script>
<script src="portal_skins/erp5_xhtml_style/renderjs.js"></script>
<script src="jsstyle_demo_not_rendering.js"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>jsstyle_demo_not_rendering.html</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*globals window, rJS*/
/*jslint indent: 2, maxlen: 80*/
(function (window, rJS) {
"use strict";
rJS(window)
.declareMethod("render", function () {
throw new Error('Demo error during render');
});
}(window, rJS));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>jsstyle_demo_not_rendering.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment