Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: third_party/WebKit/Source/core/events/ErrorEvent.h

Issue 2804533002: Update Error Event inside a worker to provide the exact exception value (Closed)
Patch Set: fix nits Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 namespace blink { 42 namespace blink {
43 43
44 class ErrorEvent final : public Event { 44 class ErrorEvent final : public Event {
45 DEFINE_WRAPPERTYPEINFO(); 45 DEFINE_WRAPPERTYPEINFO();
46 46
47 public: 47 public:
48 static ErrorEvent* create() { return new ErrorEvent; } 48 static ErrorEvent* create() { return new ErrorEvent; }
49 static ErrorEvent* create(const String& message, 49 static ErrorEvent* create(const String& message,
50 std::unique_ptr<SourceLocation> location, 50 std::unique_ptr<SourceLocation> location,
51 DOMWrapperWorld* world) { 51 DOMWrapperWorld* world) {
52 return new ErrorEvent(message, std::move(location), world); 52 return new ErrorEvent(message, std::move(location), ScriptValue(), world);
53 } 53 }
54
55 static ErrorEvent* create(const String& message,
56 std::unique_ptr<SourceLocation> location,
57 DOMWrapperWorld* world,
58 ScriptValue error) {
nhiroki 2017/04/06 01:50:35 nit: It'd be better to align the argument order wi
yiyix 2017/04/06 04:38:19 true, i forget to change the order in the previous
59 return new ErrorEvent(message, std::move(location), error, world);
60 }
61
54 static ErrorEvent* create(const AtomicString& type, 62 static ErrorEvent* create(const AtomicString& type,
55 const ErrorEventInit& initializer) { 63 const ErrorEventInit& initializer) {
56 return new ErrorEvent(type, initializer); 64 return new ErrorEvent(type, initializer);
57 } 65 }
58 static ErrorEvent* createSanitizedError(DOMWrapperWorld* world) { 66 static ErrorEvent* createSanitizedError(DOMWrapperWorld* world) {
59 return new ErrorEvent("Script error.", 67 return new ErrorEvent("Script error.",
60 SourceLocation::create(String(), 0, 0, nullptr), 68 SourceLocation::create(String(), 0, 0, nullptr),
61 world); 69 ScriptValue(), world);
62 } 70 }
63 ~ErrorEvent() override; 71 ~ErrorEvent() override;
64 72
65 // As 'message' is exposed to JavaScript, never return unsanitizedMessage. 73 // As 'message' is exposed to JavaScript, never return unsanitizedMessage.
66 const String& message() const { return m_sanitizedMessage; } 74 const String& message() const { return m_sanitizedMessage; }
67 const String& filename() const { return m_location->url(); } 75 const String& filename() const { return m_location->url(); }
68 unsigned lineno() const { return m_location->lineNumber(); } 76 unsigned lineno() const { return m_location->lineNumber(); }
69 unsigned colno() const { return m_location->columnNumber(); } 77 unsigned colno() const { return m_location->columnNumber(); }
70 ScriptValue error(ScriptState*) const; 78 ScriptValue error(ScriptState*) const;
71 79
(...skipping 10 matching lines...) Expand all
82 DOMWrapperWorld* world() const { return m_world.get(); } 90 DOMWrapperWorld* world() const { return m_world.get(); }
83 91
84 void setUnsanitizedMessage(const String&); 92 void setUnsanitizedMessage(const String&);
85 93
86 DECLARE_VIRTUAL_TRACE(); 94 DECLARE_VIRTUAL_TRACE();
87 95
88 private: 96 private:
89 ErrorEvent(); 97 ErrorEvent();
90 ErrorEvent(const String& message, 98 ErrorEvent(const String& message,
91 std::unique_ptr<SourceLocation>, 99 std::unique_ptr<SourceLocation>,
100 ScriptValue error,
92 DOMWrapperWorld*); 101 DOMWrapperWorld*);
93 ErrorEvent(const AtomicString&, const ErrorEventInit&); 102 ErrorEvent(const AtomicString&, const ErrorEventInit&);
94 103
95 String m_unsanitizedMessage; 104 String m_unsanitizedMessage;
96 String m_sanitizedMessage; 105 String m_sanitizedMessage;
97 std::unique_ptr<SourceLocation> m_location; 106 std::unique_ptr<SourceLocation> m_location;
98 ScriptValue m_error; 107 ScriptValue m_error;
99 108
100 RefPtr<DOMWrapperWorld> m_world; 109 RefPtr<DOMWrapperWorld> m_world;
101 }; 110 };
102 111
103 } // namespace blink 112 } // namespace blink
104 113
105 #endif // ErrorEvent_h 114 #endif // ErrorEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698