mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1041646. Don't assume mStack is non-null in JSStackFrame, since people sometimes operate on them after unlinking. r=khuey
This commit is contained in:
parent
5e6d105dec
commit
4bf1640106
@ -71,7 +71,8 @@ public:
|
||||
|
||||
void GetName(nsString& retval);
|
||||
|
||||
// The XPCOM GetFilename does the right thing.
|
||||
// The XPCOM GetFilename does the right thing. It might throw, but we want to
|
||||
// return an empty filename in that case anyway, instead of throwing.
|
||||
|
||||
uint32_t LineNumber() const;
|
||||
|
||||
|
@ -359,7 +359,9 @@ NS_IMETHODIMP JSStackFrame::GetLanguageName(nsACString& aLanguageName)
|
||||
/* readonly attribute AString filename; */
|
||||
NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
|
||||
{
|
||||
if (!mFilenameInitialized) {
|
||||
// We can get called after unlink; in that case we can't do much
|
||||
// about producing a useful value.
|
||||
if (!mFilenameInitialized && mStack) {
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> stack(cx, mStack);
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
@ -395,7 +397,9 @@ NS_IMETHODIMP StackFrame::GetFilename(nsAString& aFilename)
|
||||
/* readonly attribute AString name; */
|
||||
NS_IMETHODIMP JSStackFrame::GetName(nsAString& aFunction)
|
||||
{
|
||||
if (!mFunnameInitialized) {
|
||||
// We can get called after unlink; in that case we can't do much
|
||||
// about producing a useful value.
|
||||
if (!mFunnameInitialized && mStack) {
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> stack(cx, mStack);
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
@ -435,7 +439,9 @@ NS_IMETHODIMP StackFrame::GetName(nsAString& aFunction)
|
||||
nsresult
|
||||
JSStackFrame::GetLineno(int32_t* aLineNo)
|
||||
{
|
||||
if (!mLinenoInitialized) {
|
||||
// We can get called after unlink; in that case we can't do much
|
||||
// about producing a useful value.
|
||||
if (!mLinenoInitialized && mStack) {
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> stack(cx, mStack);
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
@ -468,7 +474,9 @@ NS_IMETHODIMP StackFrame::GetSourceLine(nsACString& aSourceLine)
|
||||
/* readonly attribute nsIStackFrame caller; */
|
||||
NS_IMETHODIMP JSStackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
{
|
||||
if (!mCallerInitialized) {
|
||||
// We can get called after unlink; in that case we can't do much
|
||||
// about producing a useful value.
|
||||
if (!mCallerInitialized && mStack) {
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> stack(cx, mStack);
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
@ -501,7 +509,9 @@ NS_IMETHODIMP StackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetFormattedStack(nsAString& aStack)
|
||||
{
|
||||
if (!mFormattedStackInitialized) {
|
||||
// We can get called after unlink; in that case we can't do much
|
||||
// about producing a useful value.
|
||||
if (!mFormattedStackInitialized && mStack) {
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JS::Value> stack(cx, JS::ObjectValue(*mStack));
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
|
@ -21,6 +21,7 @@ support-files =
|
||||
# where we have our test component. So this should become skip-if = debug == false.
|
||||
[test_bug923904.html]
|
||||
skip-if = true
|
||||
[test_bug1041646.html]
|
||||
[test_barewordGetsWindow.html]
|
||||
[test_callback_default_thisval.html]
|
||||
[test_cloneAndImportNode.html]
|
||||
|
49
dom/bindings/test/test_bug1041646.html
Normal file
49
dom/bindings/test/test_bug1041646.html
Normal file
@ -0,0 +1,49 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1041646
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1041646</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1041646 **/
|
||||
// We need to reject the promise with a DOMException, so make sure we have
|
||||
// something that produces one.
|
||||
function throwException() {
|
||||
document.createTextNode("").appendChild(document);
|
||||
}
|
||||
try {
|
||||
throwException();
|
||||
} catch (e) {
|
||||
ok(e instanceof DOMException, "This test won't test what it should be testing");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// We want a new DOMException each time here.
|
||||
for (var i = 0; i < 100; ++i) {
|
||||
new Promise(throwException);
|
||||
}
|
||||
|
||||
// Now make sure we wait for all those promises above to reject themselves
|
||||
Promise.resolve(1).then(function() {
|
||||
SpecialPowers.gc(); // This should not assert or crash
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1041646">Mozilla Bug 1041646</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user