Commit 4fa6d673 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_gadget_interface_validator] Use renderJS internal introspection to get the method list

Correctly handle multiple interface declarations

Reduce DOM modification.

Load gadget in an iframe to improve isolation

Delay gadget creation to prevent creating hundred of iframes in parallel, which slow down the browser
parent 67a7deb5
......@@ -13,5 +13,8 @@
<script src="gadget_interface.js" type="text/javascript"></script>
</head>
<body><pre>In Progress</pre></body>
<body>
<pre>In Progress</pre>
<div style="display:none"></div>
</body>
</html>
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.32633.6528.12782</string> </value>
<value> <string>968.41228.46964.12441</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1530266131.49</float>
<float>1536756313.04</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.37975.64169.12509</string> </value>
<value> <string>970.16725.23340.23244</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1534260072.07</float>
<float>1536917151.09</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Interface Gadget Loader</title>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_interface_loader.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*global rJS, window*/
(function (window, rJS) {
"use strict";
rJS(window)
.declareMethod("declareGadgetToCheck", function (url) {
return this.declareGadget(url, {
scope: 'gadget_to_check'
})
.push(function () {
// Do not return the loaded gadget.
// XXX This seems to break rJS iframe communication
return;
});
})
.declareMethod("getGadgetToCheckInterfaceList", function () {
return this.getDeclaredGadget('gadget_to_check')
.push(function (gadget_to_check) {
return gadget_to_check.getInterfaceList();
});
})
.declareMethod("getGadgetToCheckMethodList", function (name) {
return this.getDeclaredGadget('gadget_to_check')
.push(function (gadget_to_check) {
return gadget_to_check.getMethodList(name);
});
});
}(window, rJS));
\ No newline at end of file
......@@ -169,6 +169,8 @@ gadget_interface_validator_jio.html\n
gadget_interface_validator_jio.js\n
gadget_interface.html\n
gadget_interface.js\n
gadget_interface_loader.html\n
gadget_interface_loader.js\n
NETWORK:\n
*</string> </value>
</item>
......@@ -305,7 +307,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.41228.46964.12441</string> </value>
<value> <string>970.14054.33498.24268</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -323,7 +325,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1534260712.58</float>
<float>1536845892.77</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -37,7 +37,8 @@
sandbox: "",
renderjs_extra: JSON.stringify({
gadget_to_check_url: result.data.rows[i].value.url,
summary: true
summary: true,
delay: 200 * i
}),
key: "field_my_validation_state",
hidden: 0,
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.34322.25774.2099</string> </value>
<value> <string>970.16729.9437.60518</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1530195129.2</float>
<float>1536917386.61</float>
<string>UTC</string>
</tuple>
</state>
......
web_page_module/gadget_interface_js
web_page_module/gadget_interface_html
web_page_module/gadget_interface_loader_html
web_page_module/gadget_interface_loader_js
web_page_module/gadget_interface_validator_*
web_site_module/gadget_interface_validator
\ No newline at end of file
web_page_module/gadget_interface_html
web_page_module/gadget_interface_js
web_page_module/gadget_interface_loader_html
web_page_module/gadget_interface_loader_js
web_page_module/gadget_interface_validator_*
web_site_module/gadget_interface_validator
\ No newline at end of file
......@@ -88,7 +88,7 @@
<tr>
<td>assertText</td>
<td>//tbody/tr[3]/td[2]</td>
<td>N/A</td>
<td>Failure</td>
</tr>
<tr>
......@@ -106,26 +106,26 @@
</tr>
<tr>
<td colspan="3"><b>Check not existent gadget</b></td>
<td colspan="3"><b>Check correct use case for multiple interface</b></td>
</tr>
<tr>
<td>assertText</td>
<td>//tbody/tr[5]/td</td>
<td>gadget_interface_validator_test_nonexistent_gadget.html</td>
<td>gadget_interface_validator_test_multiple_interface_correct_implemented_gadget.html</td>
</tr>
<tr>
<td>assertText</td>
<td>//tbody/tr[5]/td[2]</td>
<td>Error with gadget loading</td>
<td>Success</td>
</tr>
<tr>
<td colspan="3"><b>Check unknown method declaration</b></td>
<td colspan="3"><b>Check duplicated method name declaration</b></td>
</tr>
<tr>
<td>assertText</td>
<td>//tbody/tr[6]/td</td>
<td>gadget_interface_validator_test_unknown_method_declaration_gadget.html</td>
<td>gadget_interface_validator_test_multiple_interface_duplicated_method_name.html</td>
</tr>
<tr>
<td>assertText</td>
......@@ -133,6 +133,34 @@
<td>Failure</td>
</tr>
<tr>
<td colspan="3"><b>Check not existent gadget</b></td>
</tr>
<tr>
<td>assertText</td>
<td>//tbody/tr[7]/td</td>
<td>gadget_interface_validator_test_nonexistent_gadget.html</td>
</tr>
<tr>
<td>assertText</td>
<td>//tbody/tr[7]/td[2]</td>
<td>Failure</td>
</tr>
<tr>
<td colspan="3"><b>Check unknown method declaration</b></td>
</tr>
<tr>
<td>assertText</td>
<td>//tbody/tr[8]/td</td>
<td>gadget_interface_validator_test_unknown_method_declaration_gadget.html</td>
</tr>
<tr>
<td>assertText</td>
<td>//tbody/tr[8]/td[2]</td>
<td>Failure</td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -115,6 +115,10 @@ gadget_interface_validator_test_missing_interface_declaration_gadget.html\n
gadget_interface_validator_test_missing_interface_declaration_gadget.js\n
gadget_interface_validator_test_missing_method_declaration_gadget.html\n
gadget_interface_validator_test_missing_method_declaration_gadget.js\n
gadget_interface_validator_test_multiple_interface_correct_implemented_gadget.html\n
gadget_interface_validator_test_multiple_interface_correct_implemented_gadget.js\n
gadget_interface_validator_test_multiple_interface_duplicated_method_name.html\n
gadget_interface_validator_test_multiple_interface_duplicated_method_name.js\n
gadget_interface_validator_test_unknown_method_declaration_gadget.html\n
gadget_interface_validator_test_unknown_method_declaration_gadget.js\n
i18next.js\n
......@@ -259,7 +263,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.14266.18355.13568</string> </value>
<value> <string>970.12316.58397.42922</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -277,7 +281,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1529048876.03</float>
<float>1536652656.93</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Correct Implemented With Multiple Interace Test Gadget</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_test_dummy_interface1.html">
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_test_dummy_interface2.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_interface_validator_test_multiple_interface_correct_implemented_gadget.js" type="text/javascript"></script>
</head>
<body> </body>
</html>
\ No newline at end of file
/*global window, rJS*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) {
"use strict";
rJS(window)
.declareMethod("method1", function (param1, param2) {
return;
})
.declareMethod("method2", function (param1) {
return;
})
.declareMethod("method3", function () {
return;
})
.declareMethod("method4", function () {
return;
});
}(window, rJS));
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Dummy Interface 2</title>
</head>
<body>
<h1>interface2</h1>
<h3>description of interface2</h3>
<dl>
<dt>method4</dt>
<dd>description of method4</dd>
<dl>
</dl>
</dl>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Duplicated Interface Test Gadget</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_test_dummy_interface1.html">
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_test_dummy_interface1.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_interface_validator_test_correct_implemented_gadget.js" type="text/javascript"></script>
</head>
<body> </body>
</html>
\ No newline at end of file
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