зеркало из https://github.com/mozilla/gecko-dev.git
Bug 965154. Make the global scope polluter handle WebIDL Window objects. r=peterv
This commit is contained in:
Родитель
a1296ea4d4
Коммит
488ea07b51
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WindowNamedPropertiesHandler.h"
|
||||
#include "mozilla/dom/WindowBinding.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
|
@ -68,6 +69,19 @@ ShouldExposeChildWindow(nsString& aNameBeingResolved, nsIDOMWindow *aChild)
|
|||
aNameBeingResolved, eCaseMatters);
|
||||
}
|
||||
|
||||
static nsGlobalWindow*
|
||||
GetWindowFromGlobal(JSObject* aGlobal)
|
||||
{
|
||||
nsGlobalWindow* win;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(Window, aGlobal, win))) {
|
||||
return win;
|
||||
}
|
||||
XPCWrappedNative* wrapper = XPCWrappedNative::Get(aGlobal);
|
||||
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryWrappedNative(wrapper);
|
||||
MOZ_ASSERT(piWin);
|
||||
return static_cast<nsGlobalWindow*>(piWin.get());
|
||||
}
|
||||
|
||||
bool
|
||||
WindowNamedPropertiesHandler::getOwnPropertyDescriptor(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aProxy,
|
||||
|
@ -88,10 +102,7 @@ WindowNamedPropertiesHandler::getOwnPropertyDescriptor(JSContext* aCx,
|
|||
nsDependentJSString str(aId);
|
||||
|
||||
// Grab the DOM window.
|
||||
XPCWrappedNative* wrapper = XPCWrappedNative::Get(global);
|
||||
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryWrappedNative(wrapper);
|
||||
MOZ_ASSERT(piWin);
|
||||
nsGlobalWindow* win = static_cast<nsGlobalWindow*>(piWin.get());
|
||||
nsGlobalWindow* win = GetWindowFromGlobal(global);
|
||||
if (win->Length() > 0) {
|
||||
nsCOMPtr<nsIDOMWindow> childWin = win->GetChildWindow(str);
|
||||
if (childWin && ShouldExposeChildWindow(str, childWin)) {
|
||||
|
@ -162,11 +173,7 @@ WindowNamedPropertiesHandler::getOwnPropertyNames(JSContext* aCx,
|
|||
JS::AutoIdVector& aProps)
|
||||
{
|
||||
// Grab the DOM window.
|
||||
JSObject* global = JS_GetGlobalForObject(aCx, aProxy);
|
||||
XPCWrappedNative* wrapper = XPCWrappedNative::Get(global);
|
||||
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryWrappedNative(wrapper);
|
||||
MOZ_ASSERT(piWin);
|
||||
nsGlobalWindow* win = static_cast<nsGlobalWindow*>(piWin.get());
|
||||
nsGlobalWindow* win = GetWindowFromGlobal(JS_GetGlobalForObject(aCx, aProxy));
|
||||
nsTArray<nsString> names;
|
||||
win->GetSupportedNames(names);
|
||||
if (!AppendNamedPropertyIds(aCx, aProxy, names, false, aProps)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче