зеркало из https://github.com/mozilla/gecko-dev.git
Bug 580128. Add cross compartment JSObject clone hooks. r=jst@mozilla.org
This commit is contained in:
Родитель
6a4e9945b0
Коммит
09878ba8cc
|
@ -82,6 +82,10 @@ DOM_MSG_DEF(NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE, "The matrix could not be com
|
|||
DOM_MSG_DEF(NS_ERROR_DOM_INVALID_EXPRESSION_ERR, "The expression is not a legal expression.")
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_TYPE_ERR, "The expression cannot be converted to return the specified type.")
|
||||
|
||||
/* HTML5 error codes http://dev.w3.org/html5/spec/Overview.html */
|
||||
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_DATA_CLONE_ERR, "The object could not be cloned.")
|
||||
|
||||
/* DOM error codes defined by us */
|
||||
|
||||
/* XXX string should be specified by norris */
|
||||
|
|
|
@ -87,6 +87,10 @@
|
|||
#define NS_ERROR_DOM_INVALID_EXPRESSION_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_XPATH, 51)
|
||||
#define NS_ERROR_DOM_TYPE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_XPATH, 52)
|
||||
|
||||
/* HTML5 error codes http://dev.w3.org/html5/spec/Overview.html */
|
||||
|
||||
#define NS_ERROR_DOM_DATA_CLONE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,18)
|
||||
|
||||
/* DOM error codes defined by us */
|
||||
|
||||
#define NS_ERROR_DOM_SECURITY_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1000)
|
||||
|
|
|
@ -3980,6 +3980,35 @@ ObjectPrincipalFinder(JSContext *cx, JSObject *obj)
|
|||
return jsPrincipals;
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
DOMReadStructuredClone(JSContext* cx,
|
||||
JSStructuredCloneReader* reader,
|
||||
uint32 tag,
|
||||
uint32 data)
|
||||
{
|
||||
// We don't currently support any extensions to structured cloning.
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_DOM_DATA_CLONE_ERR);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
DOMWriteStructuredClone(JSContext* cx,
|
||||
JSStructuredCloneWriter* writer,
|
||||
JSObject* obj)
|
||||
{
|
||||
// We don't currently support any extensions to structured cloning.
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_DOM_DATA_CLONE_ERR);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
DOMStructuredCloneError(JSContext* cx,
|
||||
uint32 errorid)
|
||||
{
|
||||
// We don't currently support any extensions to structured cloning.
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_DOM_DATA_CLONE_ERR);
|
||||
}
|
||||
|
||||
//static
|
||||
nsresult
|
||||
nsJSRuntime::Init()
|
||||
|
@ -4018,6 +4047,14 @@ nsJSRuntime::Init()
|
|||
|
||||
callbacks->findObjectPrincipals = ObjectPrincipalFinder;
|
||||
|
||||
// Set up the structured clone callbacks.
|
||||
static JSStructuredCloneCallbacks cloneCallbacks = {
|
||||
DOMReadStructuredClone,
|
||||
DOMWriteStructuredClone,
|
||||
DOMStructuredCloneError
|
||||
};
|
||||
JS_SetStructuredCloneCallbacks(sRuntime, &cloneCallbacks);
|
||||
|
||||
// Set these global xpconnect options...
|
||||
nsContentUtils::RegisterPrefCallback("dom.max_script_run_time",
|
||||
MaxScriptRunTimePrefChangedCallback,
|
||||
|
|
|
@ -1542,8 +1542,7 @@ nsDOMWorker::PostMessageInternal(PRBool aToInner)
|
|||
JSAutoStructuredCloneBuffer buffer(cx);
|
||||
|
||||
if (!buffer.write(argv[0])) {
|
||||
NS_WARNING("Failed to serialize!");
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMWorkerMessageEvent> message = new nsDOMWorkerMessageEvent();
|
||||
|
|
|
@ -315,6 +315,9 @@ function onmessage(event) {
|
|||
postMessage(messages[index].value);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.result != 2152923154) {
|
||||
throw "Exception of the wrong type: " + e.result;
|
||||
}
|
||||
exception = e;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче