Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
ebe6cd0e
Commit
ebe6cd0e
authored
Apr 30, 2020
by
Romain Courteaud
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add toJSON method on the Error object
Improve the verbosity of error when using iframe.
parent
8bf6b773
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
0 deletions
+131
-0
renderjs.js
renderjs.js
+21
-0
test/embedded_crashing_service.html
test/embedded_crashing_service.html
+33
-0
test/embedded_crashing_service.js
test/embedded_crashing_service.js
+28
-0
test/renderjs_test.js
test/renderjs_test.js
+49
-0
No files found.
renderjs.js
View file @
ebe6cd0e
...
...
@@ -27,6 +27,27 @@
Event
,
URL
)
{
"
use strict
"
;
// Error propagation in jschannel uses JSON.stringify
// Sadly, ...
// JSON.stringify(new TypeError('lala')) -> '{}'
// Change the browser default behaviour to propagate at least the message
// See https://stackoverflow.com/a/18391400
if
(
!
Error
.
prototype
.
hasOwnProperty
(
'
toJSON
'
))
{
Object
.
defineProperty
(
Error
.
prototype
,
'
toJSON
'
,
{
value
:
function
()
{
var
alt
=
{};
Object
.
getOwnPropertyNames
(
this
).
forEach
(
function
(
key
)
{
alt
[
key
]
=
this
[
key
];
},
this
);
return
alt
;
},
configurable
:
true
,
writable
:
true
});
}
/////////////////////////////////////////////////////////////////
// Error
/////////////////////////////////////////////////////////////////
...
...
test/embedded_crashing_service.html
0 → 100644
View file @
ebe6cd0e
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!--
Copyright 2014, Nexedi SA
This program is free software: you can Use, Study, Modify and Redistribute
it under the terms of the GNU General Public License version 3, or (at your
option) any later version, as published by the Free Software Foundation.
You can also Link and Combine this program with other software covered by
the terms of any of the Free Software licenses or any of the Open Source
Initiative approved licenses and Convey the resulting work. Corresponding
source of such a combination shall include the source code for all other
software used.
This program is distributed WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See COPYING file for full licensing terms.
See https://www.nexedi.com/licensing for rationale and options.
-->
<html>
<head>
<title>
Embedded page for renderJS test
</title>
<meta
name=
"viewport"
content=
"width=device-width, height=device-height"
/>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
/>
<script
src=
"../node_modules/rsvp/dist/rsvp-2.0.4.js"
type=
"text/javascript"
></script>
<script
src=
"../dist/renderjs-latest.js"
type=
"text/javascript"
></script>
<script
src=
"./embedded_crashing_service.js"
type=
"text/javascript"
></script>
</head>
<body>
</body>
</html>
test/embedded_crashing_service.js
0 → 100644
View file @
ebe6cd0e
/*
* Copyright 2014, Nexedi SA
*
* This program is free software: you can Use, Study, Modify and Redistribute
* it under the terms of the GNU General Public License version 3, or (at your
* option) any later version, as published by the Free Software Foundation.
*
* You can also Link and Combine this program with other software covered by
* the terms of any of the Free Software licenses or any of the Open Source
* Initiative approved licenses and Convey the resulting work. Corresponding
* source of such a combination shall include the source code for all other
* software used.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See COPYING file for full licensing terms.
* See https://www.nexedi.com/licensing for rationale and options.
*/
(
function
(
window
,
rJS
)
{
"
use strict
"
;
rJS
(
window
)
.
declareService
(
function
()
{
throw
new
TypeError
(
"
Cannot read property 'bar' of undefined
"
);
});
}(
window
,
rJS
));
test/renderjs_test.js
View file @
ebe6cd0e
...
...
@@ -3034,6 +3034,55 @@
});
});
test
(
'
Service error from iframe are reported to parent gadget
'
,
function
()
{
// Subclass RenderJSGadget to not pollute its namespace
var
ParentKlass
=
function
()
{
RenderJSGadget
.
call
(
this
);
},
gadget
,
defer
=
RSVP
.
defer
();
ParentKlass
.
prototype
=
new
RenderJSGadget
();
ParentKlass
.
prototype
.
constructor
=
ParentKlass
;
ParentKlass
.
prototype
.
__acquired_method_dict
=
{};
ParentKlass
.
allowPublicAcquisition
=
RenderJSGadget
.
allowPublicAcquisition
;
ParentKlass
.
allowPublicAcquisition
(
'
reportServiceError
'
,
function
(
argument_list
)
{
defer
.
resolve
(
argument_list
[
0
]);
});
gadget
=
new
ParentKlass
();
gadget
.
__sub_gadget_dict
=
{};
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
expect
(
3
);
return
gadget
.
declareGadget
(
'
embedded_crashing_service.html
'
,
{
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
.
querySelector
(
"
div
"
),
sandbox
:
'
iframe
'
}
)
.
then
(
function
()
{
return
defer
.
promise
;
})
.
then
(
function
(
catched_error
)
{
ok
(
catched_error
instanceof
Object
);
ok
(
!
(
catched_error
instanceof
Error
));
equal
(
catched_error
.
message
,
"
Cannot read property 'bar' of undefined
"
);
})
.
fail
(
function
(
e
)
{
ok
(
false
,
e
);
})
.
always
(
function
()
{
start
();
});
});
test
(
'
Service error stops the other services
'
,
function
()
{
// Subclass RenderJSGadget to not pollute its namespace
var
ParentKlass
=
function
()
{
...
...
Romain Courteaud
@romain
mentioned in merge request
erp5!1446
·
Oct 14, 2021
mentioned in merge request
erp5!1446
mentioned in merge request erp5!1446
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment