Backed out changesets fa9fe193778f and 3eaf867930dd (bug 1148593) for test_async_setTimeout_stack.html and test_async_setTimeout_stack_across_globals.html failures.

This commit is contained in:
Ryan VanderMeulen 2015-07-17 12:37:24 -04:00
Родитель aaecf611a3
Коммит b171b787bd
31 изменённых файлов: 69 добавлений и 419 удалений

Просмотреть файл

@ -28,10 +28,8 @@ function* ifTestingSupported() {
isnot($(".call-item-stack", callItem.target), null,
"There should be a stack container available now for the draw call.");
// We may have more than 4 functions, depending on whether async
// stacks are available.
ok($all(".call-item-stack-fn", callItem.target).length >= 4,
"There should be at least 4 functions on the stack for the draw call.");
is($all(".call-item-stack-fn", callItem.target).length, 4,
"There should be 4 functions on the stack for the draw call.");
ok($all(".call-item-stack-fn-name", callItem.target)[0].getAttribute("value")
.includes("C()"),

Просмотреть файл

@ -29,10 +29,8 @@ function* ifTestingSupported() {
isnot($(".call-item-stack", callItem.target), null,
"There should be a stack container available now for the draw call.");
// We may have more than 4 functions, depending on whether async
// stacks are available.
ok($all(".call-item-stack-fn", callItem.target).length >= 4,
"There should be at least 4 functions on the stack for the draw call.");
is($all(".call-item-stack-fn", callItem.target).length, 4,
"There should be 4 functions on the stack for the draw call.");
let jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER);
EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-location", callItem.target));

Просмотреть файл

@ -40,10 +40,8 @@ function* ifTestingSupported() {
"There should be a stack container available now for the draw call.");
is($(".call-item-stack", callItem.target).hidden, false,
"The stack container should now be visible.");
// We may have more than 4 functions, depending on whether async
// stacks are available.
ok($all(".call-item-stack-fn", callItem.target).length >= 4,
"There should be at least 4 functions on the stack for the draw call.");
is($all(".call-item-stack-fn", callItem.target).length, 4,
"There should be 4 functions on the stack for the draw call.");
EventUtils.sendMouseEvent({ type: "dblclick" }, contents, window);
@ -55,10 +53,8 @@ function* ifTestingSupported() {
"There should still be a stack container available for the draw call.");
is($(".call-item-stack", callItem.target).hidden, true,
"The stack container should now be hidden.");
// We may have more than 4 functions, depending on whether async
// stacks are available.
ok($all(".call-item-stack-fn", callItem.target).length >= 4,
"There should still be at least 4 functions on the stack for the draw call.");
is($all(".call-item-stack-fn", callItem.target).length, 4,
"There should still be 4 functions on the stack for the draw call.");
yield teardown(panel);
finish();

Просмотреть файл

@ -94,7 +94,7 @@ if (Services.prefs.getBoolPref("javascript.options.asyncstack")) {
let frame = markers[0].endStack;
ok(frame.parent.asyncParent !== null, "Parent frame has async parent");
is(frame.parent.asyncParent.asyncCause, "promise callback",
is(frame.parent.asyncParent.asyncCause, "Promise",
"Async parent has correct cause");
is(frame.parent.asyncParent.functionDisplayName, "makePromise",
"Async parent has correct function name");

Просмотреть файл

@ -5555,7 +5555,7 @@ nsGlobalWindow::RequestAnimationFrame(JS::Handle<JS::Value> aCallback,
JS::Rooted<JSObject*> callbackObj(cx, &aCallback.toObject());
nsRefPtr<FrameRequestCallback> callback =
new FrameRequestCallback(cx, callbackObj, GetIncumbentGlobal());
new FrameRequestCallback(callbackObj, GetIncumbentGlobal());
ErrorResult rv;
*aHandle = RequestAnimationFrame(*callback, rv);

Просмотреть файл

@ -246,8 +246,6 @@ support-files =
[test_anonymousContent_insert.html]
[test_anonymousContent_manipulate_content.html]
[test_appname_override.html]
[test_async_setTimeout_stack.html]
[test_async_setTimeout_stack_across_globals.html]
[test_audioWindowUtils.html]
[test_audioNotification.html]
skip-if = buildapp == 'mulet'

Просмотреть файл

@ -1,62 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1142577
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1142577 - Async stacks for setTimeout</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1142577">Mozilla Bug 1142577</a>
<pre id="stack"></pre>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("Testing async stacks across setTimeout");
function getFunctionName(frame) {
return frame.slice(0, frame.indexOf("@"));
}
function a() { b() }
function b() { c() }
function c() { setTimeout(d, 1) }
function d() { e() }
function e() { f() }
function f() { setTimeout(g, 1) }
function g() { h() }
function h() { i() }
function i() {
var stackString = Error().stack;
document.getElementById("stack").textContent = stackString;
var frames = stackString
.split("\n")
.map(getFunctionName)
.filter(function (name) { return !!name; });
is(frames[0], "i");
is(frames[1], "h");
is(frames[2], "g");
is(frames[3], "setTimeout handler*SimpleTest_setTimeoutShim");
is(frames[4], "f");
is(frames[5], "e");
is(frames[6], "d");
is(frames[7], "setTimeout handler*SimpleTest_setTimeoutShim");
is(frames[8], "c");
is(frames[9], "b");
is(frames[10], "a");
// One extra frame due to pushPrefEnv.
is(frames.length, 12);
SimpleTest.finish();
}
SpecialPowers.pushPrefEnv(
{"set": [['javascript.options.asyncstack', true]]},
a);
</script>
</body>
</html>

Просмотреть файл

@ -1,62 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1142577
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1142577 - Async stacks for setTimeout</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1142577">Mozilla Bug 1142577</a>
<pre id="stack"></pre>
<iframe id="iframe"></iframe>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var otherGlobal = document.getElementById("iframe").contentWindow;
function getFunctionName(frame) {
return frame.slice(0, frame.indexOf("@"));
}
function a() { b() }
function b() { c() }
function c() { otherGlobal.setTimeout(d, 1) }
function d() { e() }
function e() { f() }
function f() { otherGlobal.setTimeout(g, 1) }
function g() { h() }
function h() { i() }
function i() {
var stackString = Error().stack;
document.getElementById("stack").textContent = stackString;
var frames = stackString
.split("\n")
.map(getFunctionName)
.filter(function (name) { return !!name; });
is(frames[0], "i");
is(frames[1], "h");
is(frames[2], "g");
is(frames[3], "setTimeout handler*f");
is(frames[4], "e");
is(frames[5], "d");
is(frames[6], "setTimeout handler*c");
is(frames[7], "b");
is(frames[8], "a");
// One extra frame due to pushPrefEnv.
is(frames.length, 10);
SimpleTest.finish();
}
SpecialPowers.pushPrefEnv(
{"set": [['javascript.options.asyncstack', true]]},
a);
</script>
</body>
</html>

Просмотреть файл

@ -25,10 +25,9 @@ namespace dom {
class CallbackFunction : public CallbackObject
{
public:
// See CallbackObject for an explanation of the arguments.
explicit CallbackFunction(JSContext* aCx, JS::Handle<JSObject*> aCallable,
explicit CallbackFunction(JS::Handle<JSObject*> aCallable,
nsIGlobalObject* aIncumbentGlobal)
: CallbackObject(aCx, aCallable, aIncumbentGlobal)
: CallbackObject(aCallable, aIncumbentGlobal)
{
}

Просмотреть файл

@ -24,10 +24,9 @@ namespace dom {
class CallbackInterface : public CallbackObject
{
public:
// See CallbackObject for an explanation of the arguments.
explicit CallbackInterface(JSContext* aCx, JS::Handle<JSObject*> aCallback,
explicit CallbackInterface(JS::Handle<JSObject*> aCallback,
nsIGlobalObject *aIncumbentGlobal)
: CallbackObject(aCx, aCallback, aIncumbentGlobal)
: CallbackObject(aCallback, aIncumbentGlobal)
{
}

Просмотреть файл

@ -43,7 +43,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CallbackObject)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CallbackObject)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCreationStack)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mIncumbentJSGlobal)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
@ -170,16 +169,6 @@ CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
}
}
mAsyncStack.emplace(cx, aCallback->GetCreationStack());
if (*mAsyncStack) {
mAsyncCause.emplace(cx, JS_NewStringCopyZ(cx, aExecutionReason));
if (*mAsyncCause) {
mAsyncStackSetter.emplace(cx, *mAsyncStack, *mAsyncCause);
} else {
JS_ClearPendingException(cx);
}
}
// Enter the compartment of our callback, so we can actually work with it.
//
// Note that if the callback is a wrapper, this will not be the same

Просмотреть файл

@ -30,7 +30,6 @@
#include "nsWrapperCache.h"
#include "nsJSEnvironment.h"
#include "xpcpublic.h"
#include "jsapi.h"
namespace mozilla {
namespace dom {
@ -50,22 +49,10 @@ public:
// The caller may pass a global object which will act as an override for the
// incumbent script settings object when the callback is invoked (overriding
// the entry point computed from aCallback). If no override is required, the
// caller should pass null. |aCx| is used to capture the current
// stack, which is later used as an async parent when the callback
// is invoked. aCx can be nullptr, in which case no stack is
// captured.
explicit CallbackObject(JSContext* aCx, JS::Handle<JSObject*> aCallback,
nsIGlobalObject *aIncumbentGlobal)
// caller should pass null.
explicit CallbackObject(JS::Handle<JSObject*> aCallback, nsIGlobalObject *aIncumbentGlobal)
{
if (aCx && JS::RuntimeOptionsRef(aCx).asyncStack()) {
JS::RootedObject stack(aCx);
if (!JS::CaptureCurrentStack(aCx, &stack)) {
JS_ClearPendingException(aCx);
}
Init(aCallback, stack, aIncumbentGlobal);
} else {
Init(aCallback, nullptr, aIncumbentGlobal);
}
Init(aCallback, aIncumbentGlobal);
}
JS::Handle<JSObject*> Callback() const
@ -74,15 +61,6 @@ public:
return CallbackPreserveColor();
}
JSObject* GetCreationStack() const
{
JSObject* result = mCreationStack;
if (result) {
JS::ExposeObjectToActiveJS(result);
}
return result;
}
/*
* This getter does not change the color of the JSObject meaning that the
* object returned is not guaranteed to be kept alive past the next CC.
@ -130,8 +108,7 @@ protected:
explicit CallbackObject(CallbackObject* aCallbackObject)
{
Init(aCallbackObject->mCallback, aCallbackObject->mCreationStack,
aCallbackObject->mIncumbentGlobal);
Init(aCallbackObject->mCallback, aCallbackObject->mIncumbentGlobal);
}
bool operator==(const CallbackObject& aOther) const
@ -144,14 +121,12 @@ protected:
}
private:
inline void Init(JSObject* aCallback, JSObject* aCreationStack,
nsIGlobalObject* aIncumbentGlobal)
inline void Init(JSObject* aCallback, nsIGlobalObject* aIncumbentGlobal)
{
MOZ_ASSERT(aCallback && !mCallback);
// Set script objects before we hold, on the off chance that a GC could
// somehow happen in there... (which would be pretty odd, granted).
mCallback = aCallback;
mCreationStack = aCreationStack;
if (aIncumbentGlobal) {
mIncumbentGlobal = aIncumbentGlobal;
mIncumbentJSGlobal = aIncumbentGlobal->GetGlobalJSObject();
@ -168,14 +143,12 @@ protected:
MOZ_ASSERT_IF(mIncumbentJSGlobal, mCallback);
if (mCallback) {
mCallback = nullptr;
mCreationStack = nullptr;
mIncumbentJSGlobal = nullptr;
mozilla::DropJSObjects(this);
}
}
JS::Heap<JSObject*> mCallback;
JS::Heap<JSObject*> mCreationStack;
// Ideally, we'd just hold a reference to the nsIGlobalObject, since that's
// what we need to pass to AutoIncumbentScript. Unfortunately, that doesn't
// hold the actual JS global alive. So we maintain an additional pointer to
@ -236,11 +209,6 @@ protected:
// always within a request during its lifetime.
Maybe<JS::Rooted<JSObject*> > mRootedCallable;
// Members which are used to set the async stack.
Maybe<JS::Rooted<JSObject*>> mAsyncStack;
Maybe<JS::Rooted<JSString*>> mAsyncCause;
Maybe<JS::AutoSetAsyncStackForNewCalls> mAsyncStackSetter;
// Can't construct a JSAutoCompartment without a JSContext either. Also,
// Put mAc after mAutoEntryScript so that we exit the compartment before
// we pop the JSContext. Though in practice we'll often manually order

Просмотреть файл

@ -3976,7 +3976,7 @@ class CGCallbackTempRoot(CGGeneric):
define = dedent("""
{ // Scope for tempRoot
JS::Rooted<JSObject*> tempRoot(cx, &${val}.toObject());
${declName} = new %s(cx, tempRoot, mozilla::dom::GetIncumbentGlobal());
${declName} = new %s(tempRoot, mozilla::dom::GetIncumbentGlobal());
}
""") % name
CGGeneric.__init__(self, define=define)
@ -13908,7 +13908,7 @@ class CGJSImplClass(CGBindingImplClass):
destructor = ClassDestructor(virtual=False, visibility="private")
baseConstructors = [
("mImpl(new %s(nullptr, aJSImplObject, /* aIncumbentGlobal = */ nullptr))" %
("mImpl(new %s(aJSImplObject, /* aIncumbentGlobal = */ nullptr))" %
jsImplName(descriptor.name)),
"mParent(aParent)"]
parentInterface = descriptor.interface.parent
@ -14053,14 +14053,13 @@ class CGCallback(CGClass):
# CallbackObject does that already.
body = ""
return [ClassConstructor(
[Argument("JSContext*", "aCx"),
Argument("JS::Handle<JSObject*>", "aCallback"),
[Argument("JS::Handle<JSObject*>", "aCallback"),
Argument("nsIGlobalObject*", "aIncumbentGlobal")],
bodyInHeader=True,
visibility="public",
explicit=True,
baseConstructors=[
"%s(aCx, aCallback, aIncumbentGlobal)" % self.baseName,
"%s(aCallback, aIncumbentGlobal)" % self.baseName,
],
body=body)]

Просмотреть файл

@ -8,7 +8,6 @@ support-files =
file_proxies_via_xray.html
forOf_iframe.html
[test_async_stacks.html]
[test_ByteString.html]
[test_InstanceOf.html]
[test_bug560072.html]

Просмотреть файл

@ -1,108 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1148593
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1148593</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 1148593 **/
SimpleTest.waitForExplicitFinish();
var TESTS;
function nextTest() {
var t = TESTS.pop();
if (t) {
t();
} else {
SimpleTest.finish();
}
}
function checkStack(functionName) {
try {
noSuchFunction();
} catch (e) {
ok(e.stack.indexOf(functionName) >= 0, "stack includes " + functionName);
}
nextTest();
}
function eventListener() {
checkStack("registerEventListener");
}
function registerEventListener(link) {
link.onload = eventListener;
}
function eventTest() {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "data:text/css,";
registerEventListener(link);
document.body.appendChild(link);
}
function xhrListener() {
checkStack("xhrTest");
}
function xhrTest() {
var ourFile = location.href;
var x = new XMLHttpRequest();
x.onload = xhrListener;
x.open("get", ourFile, true);
x.send();
}
function rafListener() {
checkStack("rafTest");
}
function rafTest() {
requestAnimationFrame(rafListener);
}
var intervalId;
function intervalHandler() {
clearInterval(intervalId);
checkStack("intervalTest");
}
function intervalTest() {
intervalId = setInterval(intervalHandler, 5);
}
function postMessageHandler(ev) {
ev.stopPropagation();
checkStack("postMessageTest");
}
function postMessageTest() {
window.addEventListener("message", postMessageHandler, true);
window.postMessage("whatever", "*");
}
function runTests() {
TESTS = [postMessageTest, intervalTest, rafTest, xhrTest, eventTest];
nextTest();
}
addLoadEvent(function() {
SpecialPowers.pushPrefEnv(
{"set": [['javascript.options.asyncstack', true]]},
runTests);
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1148593">Mozilla Bug 1148593</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>

Просмотреть файл

@ -15,8 +15,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
SimpleTest.waitForExplicitFinish();
function doTest() {
var file = location.href;
var t = new TestInterfaceJS();
try {
t.testThrowError();
@ -27,12 +25,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
is(e.name, "Error", "Should not have an interesting name here");
is(e.message, "We are an Error", "Should have the right message");
is(e.stack,
`doTest@${file}:22:7\nAsync*@${file}:137:1\n`,
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:20:7\n",
"Exception stack should still only show our code");
is(e.fileName,
file,
"http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html",
"Should have the right file name");
is(e.lineNumber, 22, "Should have the right line number");
is(e.lineNumber, 20, "Should have the right line number");
is(e.columnNumber, 7, "Should have the right column number");
}
@ -47,12 +45,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
is(e.code, DOMException.NOT_SUPPORTED_ERR,
"Should have the right 'code'");
is(e.stack,
`doTest@${file}:40:7\nAsync*@${file}:137:1\n`,
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:38:7\n",
"Exception stack should still only show our code");
is(e.filename,
file,
"http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html",
"Should still have the right file name");
is(e.lineNumber, 40, "Should still have the right line number");
is(e.lineNumber, 38, "Should still have the right line number");
todo_isnot(e.columnNumber, 0,
"No column number support for DOMException yet");
}
@ -67,12 +65,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
is(e.message, "We are a TypeError",
"Should also have the right message (2)");
is(e.stack,
`doTest@${file}:61:7\nAsync*@${file}:137:1\n`,
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:59:7\n",
"Exception stack for TypeError should only show our code");
is(e.fileName,
file,
"http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html",
"Should still have the right file name for TypeError");
is(e.lineNumber, 61, "Should still have the right line number for TypeError");
is(e.lineNumber, 59, "Should still have the right line number for TypeError");
is(e.columnNumber, 7, "Should have the right column number for TypeError");
}
@ -86,12 +84,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
is(e.message, "missing argument 0 when calling function Array.indexOf",
"Should also have the right message (3)");
is(e.stack,
`doTest/<@${file}:80:45\ndoTest@${file}:80:7\nAsync*@${file}:137:1\n`,
"doTest/<@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:78:45\n" +
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:78:7\n"
,
"Exception stack for TypeError should only show our code (3)");
is(e.fileName,
file,
"http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html",
"Should still have the right file name for TypeError (3)");
is(e.lineNumber, 80, "Should still have the right line number for TypeError (3)");
is(e.lineNumber, 78, "Should still have the right line number for TypeError (3)");
is(e.columnNumber, 45, "Should have the right column number for TypeError (3)");
}
@ -104,10 +104,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
is(e.name, "NS_ERROR_UNEXPECTED", "Name should be sanitized (4)");
is(e.message, "", "Message should be sanitized (5)");
is(e.stack,
`doTest@${file}:99:7\nAsync*@${file}:137:1\n`,
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:99:7\n",
"Exception stack for sanitized exception should only show our code (4)");
is(e.filename,
file,
"http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html",
"Should still have the right file name for sanitized exception (4)");
is(e.lineNumber, 99, "Should still have the right line number for sanitized exception (4)");
todo_isnot(e.columnNumber, 0, "Should have the right column number for sanitized exception (4)");
@ -122,10 +122,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
is(e.name, "NS_ERROR_UNEXPECTED", "Name should be sanitized (5)");
is(e.message, "", "Message should be sanitized (5)");
is(e.stack,
`doTest@${file}:117:7\nAsync*@${file}:137:1\n`,
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:117:7\n",
"Exception stack for sanitized exception should only show our code (5)");
is(e.filename,
file,
"http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html",
"Should still have the right file name for sanitized exception (5)");
is(e.lineNumber, 117, "Should still have the right line number for sanitized exception (5)");
todo_isnot(e.columnNumber, 0, "Should have the right column number for sanitized exception (5)");

Просмотреть файл

@ -39,24 +39,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
var t = new TestInterfaceJS();
var asyncStack = SpecialPowers.getBoolPref("javascript.options.asyncstack");
var ourFile = "http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html";
var parentFrame = asyncStack ? "Async*@" + ourFile + ":110:1\n" : "";
Promise.all([
t.testPromiseWithThrowingChromePromiseInit().then(
ensurePromiseFail.bind(null, 1),
checkExn.bind(null, 45, "NS_ERROR_UNEXPECTED", "", undefined,
checkExn.bind(null, 44, "NS_ERROR_UNEXPECTED", "", undefined,
ourFile, 1,
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:45:7\n" +
parentFrame)),
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:44:7\n")),
t.testPromiseWithThrowingContentPromiseInit(function() {
thereIsNoSuchContentFunction1();
}).then(
ensurePromiseFail.bind(null, 2),
checkExn.bind(null, 52, "ReferenceError",
checkExn.bind(null, 50, "ReferenceError",
"thereIsNoSuchContentFunction1 is not defined",
undefined, ourFile, 2,
"doTest/<@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:52:11\ndoTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:51:7\n" +
parentFrame)),
"doTest/<@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:50:11\ndoTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:49:7\n")),
t.testPromiseWithThrowingChromeThenFunction().then(
ensurePromiseFail.bind(null, 3),
checkExn.bind(null, 0, "NS_ERROR_UNEXPECTED", "", undefined, "", 3, "")),
@ -64,12 +61,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
thereIsNoSuchContentFunction2();
}).then(
ensurePromiseFail.bind(null, 4),
checkExn.bind(null, 64, "ReferenceError",
checkExn.bind(null, 61, "ReferenceError",
"thereIsNoSuchContentFunction2 is not defined",
undefined, ourFile, 4,
"doTest/<@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:64:11\n" +
"Async*doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:63:7\n" +
parentFrame)),
"doTest/<@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:61:11\n" + (asyncStack ? "Async*doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:60:7\n" : ""))),
t.testPromiseWithThrowingChromeThenable().then(
ensurePromiseFail.bind(null, 5),
checkExn.bind(null, 0, "NS_ERROR_UNEXPECTED", "", undefined, "", 5, "")),
@ -77,24 +72,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
then: function() { thereIsNoSuchContentFunction3(); }
}).then(
ensurePromiseFail.bind(null, 6),
checkExn.bind(null, 77, "ReferenceError",
checkExn.bind(null, 72, "ReferenceError",
"thereIsNoSuchContentFunction3 is not defined",
undefined, ourFile, 6,
"doTest/<.then@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:77:32\n")),
"doTest/<.then@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:72:32\n")),
t.testPromiseWithDOMExceptionThrowingPromiseInit().then(
ensurePromiseFail.bind(null, 7),
checkExn.bind(null, 84, "NotFoundError",
checkExn.bind(null, 79, "NotFoundError",
"We are a second DOMException",
DOMException.NOT_FOUND_ERR, ourFile, 7,
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:84:7\n" +
parentFrame)),
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:79:7\n")),
t.testPromiseWithDOMExceptionThrowingThenFunction().then(
ensurePromiseFail.bind(null, 8),
checkExn.bind(null, asyncStack ? 91 : 0, "NetworkError",
checkExn.bind(null, asyncStack ? 85 : 0, "NetworkError",
"We are a third DOMException",
DOMException.NETWORK_ERR, asyncStack ? ourFile : "", 8,
(asyncStack ? "Async*doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:91:7\n" +
parentFrame : ""))),
asyncStack ? "Async*doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:85:7\n" : "")),
t.testPromiseWithDOMExceptionThrowingThenable().then(
ensurePromiseFail.bind(null, 9),
checkExn.bind(null, 0, "TypeMismatchError",

Просмотреть файл

@ -287,7 +287,7 @@ DOMEventTargetHelper::SetEventHandler(nsIAtom* aType,
nsRefPtr<EventHandlerNonNull> handler;
JS::Rooted<JSObject*> callable(aCx);
if (aValue.isObject() && JS::IsCallable(callable = &aValue.toObject())) {
handler = new EventHandlerNonNull(aCx, callable, dom::GetIncumbentGlobal());
handler = new EventHandlerNonNull(callable, dom::GetIncumbentGlobal());
}
SetEventHandler(aType, EmptyString(), handler);
return NS_OK;

Просмотреть файл

@ -950,15 +950,15 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
if (jsEventHandler->EventName() == nsGkAtoms::onerror && win) {
nsRefPtr<OnErrorEventHandlerNonNull> handlerCallback =
new OnErrorEventHandlerNonNull(nullptr, handler, /* aIncumbentGlobal = */ nullptr);
new OnErrorEventHandlerNonNull(handler, /* aIncumbentGlobal = */ nullptr);
jsEventHandler->SetHandler(handlerCallback);
} else if (jsEventHandler->EventName() == nsGkAtoms::onbeforeunload && win) {
nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handlerCallback =
new OnBeforeUnloadEventHandlerNonNull(nullptr, handler, /* aIncumbentGlobal = */ nullptr);
new OnBeforeUnloadEventHandlerNonNull(handler, /* aIncumbentGlobal = */ nullptr);
jsEventHandler->SetHandler(handlerCallback);
} else {
nsRefPtr<EventHandlerNonNull> handlerCallback =
new EventHandlerNonNull(nullptr, handler, /* aIncumbentGlobal = */ nullptr);
new EventHandlerNonNull(handler, /* aIncumbentGlobal = */ nullptr);
jsEventHandler->SetHandler(handlerCallback);
}

Просмотреть файл

@ -1312,7 +1312,7 @@ Promise::ResolveInternal(JSContext* aCx,
}
nsRefPtr<PromiseInit> thenCallback =
new PromiseInit(nullptr, thenObj, mozilla::dom::GetIncumbentGlobal());
new PromiseInit(thenObj, mozilla::dom::GetIncumbentGlobal());
nsRefPtr<ThenableResolverTask> task =
new ThenableResolverTask(this, valueObj, thenCallback);
DispatchToMicroTask(task);

Просмотреть файл

@ -316,7 +316,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
NS_ENSURE_TRUE(bound, NS_ERROR_FAILURE);
nsRefPtr<EventHandlerNonNull> handlerCallback =
new EventHandlerNonNull(nullptr, bound, /* aIncumbentGlobal = */ nullptr);
new EventHandlerNonNull(bound, /* aIncumbentGlobal = */ nullptr);
TypedEventHandler typedHandler(handlerCallback);

Просмотреть файл

@ -943,8 +943,7 @@ CallFunctionWithAsyncStack(JSContext* cx, unsigned argc, jsval* vp)
RootedObject stack(cx, &args[1].toObject());
RootedString asyncCause(cx, args[2].toString());
JS::AutoSetAsyncStackForNewCalls sas(cx, stack, asyncCause,
JS::AutoSetAsyncStackForNewCalls::AsyncCallKind::EXPLICIT);
JS::AutoSetAsyncStackForNewCalls sas(cx, stack, asyncCause);
return Call(cx, UndefinedHandleValue, function,
JS::HandleValueArray::empty(), args.rval());
}

Просмотреть файл

@ -4730,12 +4730,10 @@ JS_RestoreFrameChain(JSContext* cx)
}
JS::AutoSetAsyncStackForNewCalls::AutoSetAsyncStackForNewCalls(
JSContext* cx, HandleObject stack, HandleString asyncCause,
JS::AutoSetAsyncStackForNewCalls::AsyncCallKind kind)
JSContext* cx, HandleObject stack, HandleString asyncCause)
: cx(cx),
oldAsyncStack(cx, cx->runtime()->asyncStackForNewActivations),
oldAsyncCause(cx, cx->runtime()->asyncCauseForNewActivations),
oldAsyncCallIsExplicit(cx->runtime()->asyncCallIsExplicit)
oldAsyncCause(cx, cx->runtime()->asyncCauseForNewActivations)
{
CHECK_REQUEST(cx);
@ -4750,7 +4748,6 @@ JS::AutoSetAsyncStackForNewCalls::AutoSetAsyncStackForNewCalls(
cx->runtime()->asyncStackForNewActivations = asyncStack;
cx->runtime()->asyncCauseForNewActivations = asyncCause;
cx->runtime()->asyncCallIsExplicit = kind == AsyncCallKind::EXPLICIT;
}
JS::AutoSetAsyncStackForNewCalls::~AutoSetAsyncStackForNewCalls()
@ -4758,7 +4755,6 @@ JS::AutoSetAsyncStackForNewCalls::~AutoSetAsyncStackForNewCalls()
cx->runtime()->asyncCauseForNewActivations = oldAsyncCause;
cx->runtime()->asyncStackForNewActivations =
oldAsyncStack ? &oldAsyncStack->as<SavedFrame>() : nullptr;
cx->runtime()->asyncCallIsExplicit = oldAsyncCallIsExplicit;
}
/************************************************************************/

Просмотреть файл

@ -4033,25 +4033,14 @@ class MOZ_STACK_CLASS JS_PUBLIC_API(AutoSetAsyncStackForNewCalls)
JSContext* cx;
RootedObject oldAsyncStack;
RootedString oldAsyncCause;
bool oldAsyncCallIsExplicit;
public:
enum class AsyncCallKind {
// The ordinary kind of call, where we may apply an async
// parent if there is no ordinary parent.
IMPLICIT,
// An explicit async parent, e.g., callFunctionWithAsyncStack,
// where we always want to override any ordinary parent.
EXPLICIT
};
// The stack parameter cannot be null by design, because it would be
// ambiguous whether that would clear any scheduled async stack and make the
// normal stack reappear in the new call, or just keep the async stack
// already scheduled for the new call, if any.
AutoSetAsyncStackForNewCalls(JSContext* cx, HandleObject stack,
HandleString asyncCause,
AsyncCallKind kind = AsyncCallKind::IMPLICIT);
HandleString asyncCause);
~AutoSetAsyncStackForNewCalls();
};

Просмотреть файл

@ -128,7 +128,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
asmJSActivationStack_(nullptr),
asyncStackForNewActivations(nullptr),
asyncCauseForNewActivations(nullptr),
asyncCallIsExplicit(false),
entryMonitor(nullptr),
parentRuntime(parentRuntime),
interrupt_(false),

Просмотреть файл

@ -697,12 +697,6 @@ struct JSRuntime : public JS::shadow::Runtime,
*/
JSString* asyncCauseForNewActivations;
/*
* True if the async call was explicitly requested, e.g. via
* callFunctionWithAsyncStack.
*/
bool asyncCallIsExplicit;
/* If non-null, report JavaScript entry points to this monitor. */
JS::dbg::AutoEntryMonitor* entryMonitor;

Просмотреть файл

@ -912,17 +912,6 @@ SavedStacks::insertFrames(JSContext* cx, FrameIter& iter, MutableHandleSavedFram
while (!iter.done()) {
Activation& activation = *iter.activation();
if (asyncActivation && asyncActivation != &activation) {
// We found an async stack in the previous activation, and we
// walked past the oldest frame of that activation, we're done.
// However, we only want to use the async parent if it was
// explicitly requested; if we got here otherwise, we have
// a direct parent, which we prefer.
if (asyncActivation->asyncCallIsExplicit())
break;
asyncActivation = nullptr;
}
if (!asyncActivation) {
asyncStack = activation.asyncStack();
if (asyncStack) {
@ -934,6 +923,10 @@ SavedStacks::insertFrames(JSContext* cx, FrameIter& iter, MutableHandleSavedFram
asyncCause = activation.asyncCause();
asyncActivation = &activation;
}
} else if (asyncActivation != &activation) {
// We found an async stack in the previous activation, and we
// walked past the oldest frame of that activation, we're done.
break;
}
AutoLocationValueRooter location(cx);

Просмотреть файл

@ -868,13 +868,11 @@ Activation::Activation(JSContext* cx, Kind kind)
hideScriptedCallerCount_(0),
asyncStack_(cx, cx->runtime_->asyncStackForNewActivations),
asyncCause_(cx, cx->runtime_->asyncCauseForNewActivations),
asyncCallIsExplicit_(cx->runtime_->asyncCallIsExplicit),
entryMonitor_(cx->runtime_->entryMonitor),
kind_(kind)
{
cx->runtime_->asyncStackForNewActivations = nullptr;
cx->runtime_->asyncCauseForNewActivations = nullptr;
cx->runtime_->asyncCallIsExplicit = false;
cx->runtime_->entryMonitor = nullptr;
cx->runtime_->activation_ = this;
}
@ -888,7 +886,6 @@ Activation::~Activation()
cx_->runtime_->entryMonitor = entryMonitor_;
cx_->runtime_->asyncCauseForNewActivations = asyncCause_;
cx_->runtime_->asyncStackForNewActivations = asyncStack_;
cx_->runtime_->asyncCallIsExplicit = asyncCallIsExplicit_;
}
bool

Просмотреть файл

@ -1130,10 +1130,6 @@ class Activation
// Value of asyncCause to be attached to asyncStack_.
RootedString asyncCause_;
// True if the async call was explicitly requested, e.g. via
// callFunctionWithAsyncStack.
bool asyncCallIsExplicit_;
// The entry point monitor that was set on cx_->runtime() when this
// Activation was created. Subclasses should report their entry frame's
// function or script here.
@ -1219,10 +1215,6 @@ class Activation
return asyncCause_;
}
bool asyncCallIsExplicit() const {
return asyncCallIsExplicit_;
}
private:
Activation(const Activation& other) = delete;
void operator=(const Activation& other) = delete;

Просмотреть файл

@ -2824,8 +2824,7 @@ nsXPCComponents_Utils::CallFunctionWithAsyncStack(HandleValue function,
if (!asyncCauseString)
return NS_ERROR_OUT_OF_MEMORY;
JS::AutoSetAsyncStackForNewCalls sas(cx, asyncStackObj, asyncCauseString,
JS::AutoSetAsyncStackForNewCalls::AsyncCallKind::EXPLICIT);
JS::AutoSetAsyncStackForNewCalls sas(cx, asyncStackObj, asyncCauseString);
if (!JS_CallFunctionValue(cx, nullptr, function,
JS::HandleValueArray::empty(), retval))

Просмотреть файл

@ -43,10 +43,6 @@
let Cu = this.require ? require("chrome").Cu : Components.utils;
let Cc = this.require ? require("chrome").Cc : Components.classes;
let Ci = this.require ? require("chrome").Ci : Components.interfaces;
// If we can access Components, then we use it to capture an async
// parent stack trace; see scheduleWalkerLoop. However, as it might
// not be available (see above), users of this must check it first.
let Components_ = this.require ? require("chrome").components : Components;
// If Cu is defined, use it to lazily define the FinalizationWitnessService.
if (Cu) {
@ -741,15 +737,7 @@ this.PromiseWalker = {
// If Cu is defined, this file is loaded on the main thread. Otherwise, it
// is loaded on the worker thread.
if (Cu) {
let stack = Components_ ? Components_.stack : null;
if (stack) {
DOMPromise.resolve().then(() => {
Cu.callFunctionWithAsyncStack(this.walkerLoop.bind(this), stack,
"Promise")
});
} else {
DOMPromise.resolve().then(() => this.walkerLoop());
}
DOMPromise.resolve().then(() => this.walkerLoop());
} else {
setImmediate(this.walkerLoop);
}