Bug 965898 - Implement an Xray subclass that we can use to implement HTML5 cross-origin semantics. r=gabor

This commit is contained in:
Bobby Holley 2014-07-30 12:23:01 -07:00
parent f90f3f7319
commit 971ad29192
3 changed files with 22 additions and 2 deletions

View File

@ -170,7 +170,15 @@ FilteringWrapper<Base, Policy>::enter(JSContext *cx, HandleObject wrapper,
return true;
}
#define XOW FilteringWrapper<SecurityXrayDOM, CrossOriginAccessiblePropertiesOnly>
CrossOriginXrayWrapper::CrossOriginXrayWrapper(unsigned flags) : SecurityXrayDOM(flags)
{
}
CrossOriginXrayWrapper::~CrossOriginXrayWrapper()
{
}
#define XOW FilteringWrapper<CrossOriginXrayWrapper, CrossOriginAccessiblePropertiesOnly>
#define NNXOW FilteringWrapper<CrossCompartmentSecurityWrapper, Opaque>
#define NNXOWC FilteringWrapper<CrossCompartmentSecurityWrapper, OpaqueWithCall>

View File

@ -7,6 +7,7 @@
#ifndef __FilteringWrapper_h__
#define __FilteringWrapper_h__
#include "XrayWrapper.h"
#include "mozilla/Attributes.h"
#include "jswrapper.h"
#include "js/CallNonGenericMethod.h"
@ -51,6 +52,17 @@ class FilteringWrapper : public Base {
static const FilteringWrapper singleton;
};
/*
* The HTML5 spec mandates very particular object behavior for cross-origin DOM
* objects (Window and Location), some of which runs contrary to the way that
* other XrayWrappers behave. We use this class to implement those semantics.
*/
class CrossOriginXrayWrapper : public SecurityXrayDOM {
public:
CrossOriginXrayWrapper(unsigned flags);
virtual ~CrossOriginXrayWrapper();
};
}
#endif /* __FilteringWrapper_h__ */

View File

@ -398,7 +398,7 @@ SelectWrapper(bool securityWrapper, bool wantXrays, XrayType xrayType,
// This is a security wrapper. Use the security versions and filter.
if (xrayType == XrayForDOMObject)
return &FilteringWrapper<SecurityXrayDOM,
return &FilteringWrapper<CrossOriginXrayWrapper,
CrossOriginAccessiblePropertiesOnly>::singleton;
// There's never any reason to expose other objects to non-subsuming actors.