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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.cpp

Issue 2138363002: Throw exception instead of crashing when creating a wrong wrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 // TODO(jochen): Currently, Location is the only object for which we can reach this code path. Should be generalized. 119 // TODO(jochen): Currently, Location is the only object for which we can reach this code path. Should be generalized.
120 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Loca tion", contextForWrapper->Global(), isolate); 120 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Loca tion", contextForWrapper->Global(), isolate);
121 // We can't create a better message for a detached frame. 121 // We can't create a better message for a detached frame.
122 exceptionState.throwSecurityError(String(), String()); 122 exceptionState.throwSecurityError(String(), String());
123 exceptionState.throwIfNeeded(); 123 exceptionState.throwIfNeeded();
124 return; 124 return;
125 } 125 }
126 const DOMWrapperWorld& currentWorld = DOMWrapperWorld::world(m_context); 126 const DOMWrapperWorld& currentWorld = DOMWrapperWorld::world(m_context);
127 RELEASE_ASSERT(currentWorld.worldId() == DOMWrapperWorld::world(contextForWr apper).worldId()); 127 RELEASE_ASSERT(currentWorld.worldId() == DOMWrapperWorld::world(contextForWr apper).worldId());
128 if (currentWorld.isMainWorld()) { 128 if (currentWorld.isMainWorld() && !BindingSecurity::shouldAllowAccessToFrame (isolate, currentDOMWindow(isolate), frame, DoNotReportSecurityError)) {
129 RELEASE_ASSERT(BindingSecurity::shouldAllowAccessToFrame(isolate, curren tDOMWindow(isolate), frame, DoNotReportSecurityError)); 129 // TODO(jochen): Add the interface name here once this is generalized.
130 ExceptionState exceptionState(ExceptionState::ConstructionContext, nullp tr, contextForWrapper->Global(), isolate);
131 exceptionState.throwSecurityError(String(), String());
132 exceptionState.throwIfNeeded();
133 return;
130 } 134 }
131 } 135 }
132 136
133 void V8WrapperInstantiationScope::convertException() 137 void V8WrapperInstantiationScope::convertException()
134 { 138 {
135 v8::Isolate* isolate = m_context->GetIsolate(); 139 v8::Isolate* isolate = m_context->GetIsolate();
136 // TODO(jochen): Currently, Location is the only object for which we can rea ch this code path. Should be generalized. 140 // TODO(jochen): Currently, Location is the only object for which we can rea ch this code path. Should be generalized.
137 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Location ", isolate->GetCurrentContext()->Global(), isolate); 141 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Location ", isolate->GetCurrentContext()->Global(), isolate);
138 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); 142 LocalDOMWindow* callingWindow = currentDOMWindow(isolate);
139 DOMWindow* targetWindow = toDOMWindow(m_context); 143 DOMWindow* targetWindow = toDOMWindow(m_context);
140 exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessEr rorMessage(callingWindow), targetWindow->crossDomainAccessErrorMessage(callingWi ndow)); 144 exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessEr rorMessage(callingWindow), targetWindow->crossDomainAccessErrorMessage(callingWi ndow));
141 exceptionState.throwIfNeeded(); 145 exceptionState.throwIfNeeded();
142 } 146 }
143 147
144 } // namespace blink 148 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698