Bug 683262 - window.crypto throws if MOZ_DISABLE_DOMCRYPTO is turned on - revert nsIWindowCrypto patch r=jst

This commit is contained in:
David Dahl 2013-02-15 23:34:18 -06:00
parent b0632e9e66
commit 3bcc359caf
6 changed files with 37 additions and 67 deletions

View File

@ -481,12 +481,6 @@ static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
static const char kDOMStringBundleURL[] =
"chrome://global/locale/dom/dom.properties";
#ifdef MOZ_DISABLE_CRYPTOLEGACY
static const bool domCryptoEnabled = false;
#else
static const bool domCryptoEnabled = true;
#endif
// NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
// are defined in nsIDOMClassInfo.h.
@ -2067,8 +2061,7 @@ nsDOMClassInfo::RegisterExternalClasses()
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMWindowPerformance, \
nsGlobalWindow::HasPerformanceSupport()) \
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
nsDOMTouchEvent::PrefEnabled()) \
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIWindowCrypto, domCryptoEnabled)
nsDOMTouchEvent::PrefEnabled())
#else // !MOZ_B2G
#define DOM_CLASSINFO_WINDOW_MAP_ENTRIES(_support_indexed_db) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow) \
@ -2080,8 +2073,7 @@ nsDOMClassInfo::RegisterExternalClasses()
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMWindowPerformance, \
nsGlobalWindow::HasPerformanceSupport()) \
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
nsDOMTouchEvent::PrefEnabled()) \
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIWindowCrypto, domCryptoEnabled)
nsDOMTouchEvent::PrefEnabled())
#endif // MOZ_B2G
nsresult

View File

@ -1453,7 +1453,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMWindowPerformance)
NS_INTERFACE_MAP_ENTRY(nsITouchEventReceiver)
NS_INTERFACE_MAP_ENTRY(nsIInlineEventHandlers)
NS_INTERFACE_MAP_ENTRY(nsIWindowCrypto)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Window)
OUTER_WINDOW_ONLY
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY

View File

@ -260,8 +260,7 @@ class nsGlobalWindow : public mozilla::dom::EventTarget,
public PRCListStr,
public nsIDOMWindowPerformance,
public nsITouchEventReceiver,
public nsIInlineEventHandlers,
public nsIWindowCrypto
public nsIInlineEventHandlers
#ifdef MOZ_B2G
, public nsIDOMWindowB2G
#endif // MOZ_B2G
@ -332,9 +331,6 @@ public:
// nsIInlineEventHandlers
NS_DECL_NSIINLINEEVENTHANDLERS
// nsIWindowCrypto
NS_DECL_NSIWINDOWCRYPTO
// nsPIDOMWindow
virtual NS_HIDDEN_(nsPIDOMWindow*) GetPrivateRoot();
virtual NS_HIDDEN_(void) ActivateOrDeactivate(bool aActivate);

View File

@ -25,7 +25,7 @@ interface nsIVariant;
* @see <http://www.whatwg.org/html/#window>
*/
[scriptable, uuid(8d86d6b2-fc2c-416a-8085-f670d5a35832)]
[scriptable, uuid(39cb59d4-fba9-48a9-b70b-570a7ec2ebfa)]
interface nsIDOMWindow : nsISupports
{
// the current browsing context
@ -360,6 +360,9 @@ interface nsIDOMWindow : nsISupports
readonly attribute boolean closed;
readonly attribute nsIDOMCrypto crypto;
readonly attribute nsIDOMPkcs11 pkcs11;
// XXX Shouldn't this be in nsIDOMChromeWindow?
/* [replaceable] controllers */
readonly attribute nsIControllers controllers;
@ -499,17 +502,6 @@ interface nsIDOMWindowPerformance : nsISupports
readonly attribute nsISupports performance;
};
[scriptable, uuid(2ed9ace1-172c-443f-b92f-c4f74bf8f2c5)]
interface nsIWindowCrypto : nsISupports
{
/**
* A namespace to hold crypto related data and statistics.
* http://wiki.whatwg.org/wiki/Crypto
*/
readonly attribute nsIDOMCrypto crypto;
readonly attribute nsIDOMPkcs11 pkcs11;
};
/**
* Empty interface for compatibility with older versions.
* @deprecated Use nsIDOMWindow instead

View File

@ -18,8 +18,6 @@ MOZ_SERVICES_CRYPTO=1
MOZ_SERVICES_METRICS=1
MOZ_SERVICES_SYNC=1
MOZ_DISABLE_DOMCRYPTO=1
if test "$LIBXUL_SDK"; then
MOZ_XULRUNNER=1
else

View File

@ -478,52 +478,47 @@ nsNSSComponent::DispatchEvent(const nsAString &eventType,
nsresult
nsNSSComponent::DispatchEventToWindow(nsIDOMWindow *domWin,
const nsAString &eventType, const nsAString &tokenName)
const nsAString &eventType,
const nsAString &tokenName)
{
// first walk the children and dispatch their events
{
nsresult rv;
nsCOMPtr<nsIDOMWindowCollection> frames;
rv = domWin->GetFrames(getter_AddRefs(frames));
if (NS_FAILED(rv)) {
return rv;
}
if (!domWin) {
return NS_OK;
}
uint32_t length;
frames->GetLength(&length);
uint32_t i;
for (i = 0; i < length; i++) {
nsCOMPtr<nsIDOMWindow> childWin;
frames->Item(i, getter_AddRefs(childWin));
DispatchEventToWindow(childWin, eventType, tokenName);
}
// first walk the children and dispatch their events
nsresult rv;
nsCOMPtr<nsIDOMWindowCollection> frames;
rv = domWin->GetFrames(getter_AddRefs(frames));
if (NS_FAILED(rv)) {
return rv;
}
uint32_t length;
frames->GetLength(&length);
uint32_t i;
for (i = 0; i < length; i++) {
nsCOMPtr<nsIDOMWindow> childWin;
frames->Item(i, getter_AddRefs(childWin));
DispatchEventToWindow(childWin, eventType, tokenName);
}
// check if we've enabled smart card events on this window
// NOTE: it's not an error to say that we aren't going to dispatch
// the event.
{
nsCOMPtr<nsIWindowCrypto> domWindow = do_QueryInterface(domWin);
if (!domWindow) {
return NS_OK; // nope, it's not an internal window
}
nsCOMPtr<nsIDOMCrypto> crypto;
domWin->GetCrypto(getter_AddRefs(crypto));
if (!crypto) {
return NS_OK; // nope, it doesn't have a crypto property
}
nsCOMPtr<nsIDOMCrypto> crypto;
domWindow->GetCrypto(getter_AddRefs(crypto));
if (!crypto) {
return NS_OK; // nope, it doesn't have a crypto property
}
bool boolrv;
crypto->GetEnableSmartCardEvents(&boolrv);
if (!boolrv) {
return NS_OK; // nope, it's not enabled.
}
bool boolrv;
crypto->GetEnableSmartCardEvents(&boolrv);
if (!boolrv) {
return NS_OK; // nope, it's not enabled.
}
// dispatch the event ...
nsresult rv;
// find the document
nsCOMPtr<nsIDOMDocument> doc;
rv = domWin->GetDocument(getter_AddRefs(doc));
@ -545,9 +540,7 @@ nsNSSComponent::DispatchEventToWindow(nsIDOMWindow *domWin,
return rv;
}
bool boolrv;
rv = target->DispatchEvent(smartCardEvent, &boolrv);
return rv;
return target->DispatchEvent(smartCardEvent, &boolrv);
}
#endif // MOZ_DISABLE_CRYPTOLEGACY