ToString from https://hg.mozilla.org/mozilla-central/file/005980552224/dom/workers/Location.cpp#l147 contains:
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
JSClass* classPtr;
if (!obj || ((classPtr = JS_GET_CLASS(aCx, obj)) != &sClass)) {
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
JSMSG_INCOMPATIBLE_PROTO, sClass.name, "toString",
classPtr ? classPtr->name : "object");
return false;
}
As JS_THIS_OBJECT reports errors (OOM) on its own, reporting JSMSG_INCOMPATIBLE_PROTO again is wrong after JS_THIS_OBJECT fails.
Another issue that I sported when looking for a similar pattern is the following comment in many GetInstancePrivate implementations:
// JS_GetInstancePrivate is ok to be called with a null aObj, so this should
// be too.
The implication is the comment is wrong. JS_GetInstancePrivate allows null aObj only for compatibility. The new code should never pass null there. As in all cases workers' GetInstancePrivate are not used with null aObj, for code simplicity the implementation should assume that aObj is not null.

Created attachment 594125[details][diff][review]
v1
The patch fixes ToString implementation and changes GetInstancePrivate to assume that obj is not null. The patch also removed few checks for null result of JS_GET_CLASS(obj). That is not possible.