Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Ivan Tyagov
renderjs
Commits
9aa8ac8f
Commit
9aa8ac8f
authored
Jul 08, 2016
by
Klaus Wölfel
Committed by
Romain Courteaud
Jul 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On crash, display list of all errors
parent
cdf44572
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
2 deletions
+94
-2
renderjs.js
renderjs.js
+38
-2
test/error_gadget.html
test/error_gadget.html
+27
-0
test/renderjs_test.js
test/renderjs_test.js
+29
-0
No files found.
renderjs.js
View file @
9aa8ac8f
...
@@ -71,7 +71,12 @@
...
@@ -71,7 +71,12 @@
Monitor
,
Monitor
,
scope_increment
=
0
,
scope_increment
=
0
,
isAbsoluteOrDataURL
=
new
RegExp
(
'
^(?:[a-z]+:)?//|data:
'
,
'
i
'
),
isAbsoluteOrDataURL
=
new
RegExp
(
'
^(?:[a-z]+:)?//|data:
'
,
'
i
'
),
is_page_unloaded
=
false
;
is_page_unloaded
=
false
,
error_list
=
[];
window
.
addEventListener
(
'
error
'
,
function
(
error
)
{
error_list
.
push
(
error
);
});
window
.
addEventListener
(
'
beforeunload
'
,
function
()
{
window
.
addEventListener
(
'
beforeunload
'
,
function
()
{
// XXX If another listener cancel the page unload,
// XXX If another listener cancel the page unload,
...
@@ -91,6 +96,10 @@
...
@@ -91,6 +96,10 @@
}
}
function
letsCrash
(
e
)
{
function
letsCrash
(
e
)
{
var
i
,
body
,
container
,
paragraph
;
if
(
is_page_unloaded
)
{
if
(
is_page_unloaded
)
{
/*global console*/
/*global console*/
console
.
info
(
'
-- Error dropped, as page is unloaded
'
);
console
.
info
(
'
-- Error dropped, as page is unloaded
'
);
...
@@ -113,7 +122,34 @@
...
@@ -113,7 +122,34 @@
}
catch
(
ignore
)
{
}
catch
(
ignore
)
{
}
}
}
}
document
.
getElementsByTagName
(
'
body
'
)[
0
].
textContent
=
e
;
error_list
.
push
(
e
);
body
=
document
.
getElementsByTagName
(
'
body
'
)[
0
];
while
(
body
.
firstChild
)
{
body
.
removeChild
(
body
.
firstChild
);
}
for
(
i
=
0
;
i
<
error_list
.
length
;
i
+=
1
)
{
container
=
document
.
createElement
(
"
section
"
);
paragraph
=
document
.
createElement
(
"
h2
"
);
paragraph
.
textContent
=
error_list
[
i
].
message
;
container
.
appendChild
(
paragraph
);
if
(
error_list
[
i
].
fileName
!==
undefined
)
{
paragraph
=
document
.
createElement
(
"
p
"
);
paragraph
.
textContent
=
'
File:
'
+
error_list
[
i
].
fileName
+
'
:
'
+
error_list
[
i
].
lineNumber
;
container
.
appendChild
(
paragraph
);
}
if
(
error_list
[
i
].
stack
!==
undefined
)
{
paragraph
=
document
.
createElement
(
"
pre
"
);
paragraph
.
textContent
=
'
Stack:
'
+
error_list
[
i
].
stack
;
container
.
appendChild
(
paragraph
);
}
body
.
appendChild
(
container
);
}
// XXX Do not crash the application if it fails
// XXX Do not crash the application if it fails
// Where to write the error?
// Where to write the error?
/*global console*/
/*global console*/
...
...
test/error_gadget.html
0 → 100644
View file @
9aa8ac8f
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Error event 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>
window
.
getFoo
=
functypo
{
return
"
foo
"
;
};
</script>
<script>
rJS
(
window
)
.
declareService
(
function
()
{
return
this
.
getElement
()
.
push
(
function
(
elt
)
{
elt
.
textContent
=
getFoo
();
});
});
</script>
</head>
<body>
</body>
</html>
test/renderjs_test.js
View file @
9aa8ac8f
...
@@ -4229,5 +4229,34 @@
...
@@ -4229,5 +4229,34 @@
});
});
});
});
test
(
'
check page error
'
,
function
()
{
var
fixture
=
document
.
getElementById
(
"
qunit-fixture
"
),
iframe
;
fixture
.
innerHTML
=
"
<iframe id=renderjsIframe src='./error_gadget.html'></iframe>
"
;
iframe
=
document
.
getElementById
(
'
renderjsIframe
'
);
stop
();
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
iframe
.
addEventListener
(
"
load
"
,
function
(
evt
)
{
resolve
(
evt
.
target
.
result
);
});
})
.
then
(
function
()
{
var
iframe_body
=
iframe
.
contentWindow
.
document
.
body
,
iframe_text
=
iframe_body
.
textContent
;
ok
(
true
,
iframe_text
.
indexOf
(
'
SyntaxError
'
)
!==
-
1
,
iframe_text
);
ok
(
true
,
iframe_text
.
indexOf
(
'
getFoo
'
)
!==
-
1
,
iframe_text
);
ok
(
true
,
iframe_text
.
indexOf
(
'
error_gadget.html
'
)
!==
-
1
,
iframe_text
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
}(
document
,
renderJS
,
QUnit
,
sinon
,
URI
,
URL
));
}(
document
,
renderJS
,
QUnit
,
sinon
,
URI
,
URL
));
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