diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/ErrorEvent.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/dom/ErrorEvent.cpp')
-rw-r--r-- | Source/WebCore/dom/ErrorEvent.cpp | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/Source/WebCore/dom/ErrorEvent.cpp b/Source/WebCore/dom/ErrorEvent.cpp index d0c337af3..ce7f8ca66 100644 --- a/Source/WebCore/dom/ErrorEvent.cpp +++ b/Source/WebCore/dom/ErrorEvent.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -31,37 +32,32 @@ #include "config.h" #include "ErrorEvent.h" +#include "DOMWrapperWorld.h" #include "EventNames.h" +#include <heap/HeapInlines.h> +#include <heap/StrongInlines.h> -namespace WebCore { +using namespace JSC; -ErrorEventInit::ErrorEventInit() - : message() - , filename() - , lineno(0) - , colno(0) -{ -} - -ErrorEvent::ErrorEvent() -{ -} +namespace WebCore { -ErrorEvent::ErrorEvent(const AtomicString& type, const ErrorEventInit& initializer) - : Event(type, initializer) +ErrorEvent::ErrorEvent(ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted) + : Event(type, initializer, isTrusted) , m_message(initializer.message) , m_fileName(initializer.filename) , m_lineNumber(initializer.lineno) , m_columnNumber(initializer.colno) + , m_error(state.vm(), initializer.error) { } -ErrorEvent::ErrorEvent(const String& message, const String& fileName, unsigned lineNumber, unsigned columnNumber) +ErrorEvent::ErrorEvent(const String& message, const String& fileName, unsigned lineNumber, unsigned columnNumber, JSC::Strong<JSC::Unknown> error) : Event(eventNames().errorEvent, false, true) , m_message(message) , m_fileName(fileName) , m_lineNumber(lineNumber) , m_columnNumber(columnNumber) + , m_error(error) { } @@ -74,4 +70,36 @@ EventInterface ErrorEvent::eventInterface() const return ErrorEventInterfaceType; } +JSValue ErrorEvent::error(ExecState& exec, JSGlobalObject& globalObject) +{ + auto error = m_error.get(); + if (!error) + return jsNull(); + + if (error.isObject() && &worldForDOMObject(error.getObject()) != ¤tWorld(&exec)) { + // We need to make sure ErrorEvents do not leak their error property across isolated DOM worlds. + // Ideally, we would check that the worlds have different privileges but that's not possible yet. + auto serializedError = trySerializeError(exec); + if (!serializedError) + return jsNull(); + return serializedError->deserialize(exec, &globalObject); + } + + return error; +} + +RefPtr<SerializedScriptValue> ErrorEvent::trySerializeError(ExecState& exec) +{ + if (!m_triedToSerialize) { + m_serializedDetail = SerializedScriptValue::create(exec, m_error.get(), SerializationErrorMode::NonThrowing); + m_triedToSerialize = true; + } + return m_serializedDetail; +} + +bool ErrorEvent::isErrorEvent() const +{ + return true; +} + } // namespace WebCore |