Commit 292d2692 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_js_style: display the page content even if the failover css style loading fails

parent 7832dc0c
......@@ -457,14 +457,17 @@
showPage();
return;
}
function showContentAtAllCost() {
// Set again the page content after the css is loaded
// to prevent ugly rendering
// And if the css load fails,
// show the page content instead of a blank page
gadget.element.innerHTML = parsed_content.original_content;
// Ensure the page is visible in case of error
showPage();
}
return new RSVP.Queue(rJS.declareCSS(style_css_url, document.head))
.push(function () {
// Set again the page content after the css is loaded
// to prevent ugly rendering
gadget.element.innerHTML = parsed_content.original_content;
// Ensure the page is visible in case of error
showPage();
});
.push(showContentAtAllCost, showContentAtAllCost);
});
});
......
<?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="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>testJsStyleNotLoadingStyleAndNotLoadingDefaultCss</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_loading_style_and_default_css</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_loading.html']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>css=html[hidden]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//head/link[@rel='stylesheet' and @href='jsstyle.css']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//head/link[@rel='stylesheet' and @href='jsstyle.css']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//nav[@id='sitemap']/a[text()='Not Loading Style And Default CSS']</td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>css=html[hidden]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//nav[@id='sitemap']/a[text()='Not Loading Style And Default CSS']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//nav[@id='language']//a[@hreflang='en']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@class='input']/span[@class='headline' and text()='Not Loading Style And Default CSS']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -204,6 +204,12 @@ configuration_dict = {
'title': "Not Loading Style",
'site_map_section_parent': True
},
'not_loading_style_and_default_css': {
'configuration_style_gadget_url': "jsstyle_demo_not_loading.html",
'title': "Not Loading Style And Default CSS",
'site_map_section_parent': True
# create a web section with the css reference
},
'not_rendering': {
'configuration_style_gadget_url': "jsstyle_demo_not_rendering.html",
'title': "Not Rendering Style",
......@@ -330,4 +336,11 @@ if configuration in ('form', 'form_and_default_page'):
aggregate_value=web_site.getAggregateValue()
)
if configuration in ('not_loading_style_and_default_css', ):
web_site.newContent(
portal_type=web_section_portal_type,
id='jsstyle.css',
title="This web section does not return CSS"
)
return "Web Site created."
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