mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 758563 - Warn when __exposedProps__ is missing. r=bz
This commit is contained in:
parent
71a31c7b67
commit
35b5448ba4
@ -45,4 +45,5 @@ DEPRECATED_OPERATION(InputEncoding)
|
||||
DEPRECATED_OPERATION(MozBeforePaint)
|
||||
DEPRECATED_OPERATION(MozBlobBuilder)
|
||||
DEPRECATED_OPERATION(DOMExceptionCode)
|
||||
DEPRECATED_OPERATION(NoExposedProps)
|
||||
DEPRECATED_OPERATION(MutationEvent)
|
||||
|
@ -120,5 +120,7 @@ MediaLoadDecodeError=Media resource %S could not be decoded.
|
||||
MozBlobBuilderWarning=Use of MozBlobBuilder is deprecated. Use Blob constructor instead.
|
||||
# LOCALIZATION NOTE: Do not translate "DOMException", "code" and "name"
|
||||
DOMExceptionCodeWarning=Use of DOMException's code attribute is deprecated. Use name instead.
|
||||
# LOCALIZATION NOTE: Do not translate "__exposedProps__"
|
||||
NoExposedPropsWarning=Exposing chrome JS objects to content without __exposedProps__ is insecure and deprecated. See https://developer.mozilla.org/en/XPConnect_wrappers for more information.
|
||||
# LOCALIZATION NOTE: Do not translate "Mutation Event" and "MutationObserver"
|
||||
MutationEventWarning=Use of Mutation Events is deprecated. Use MutationObserver instead.
|
||||
|
@ -47,6 +47,7 @@ _CHROME_FILES = \
|
||||
test_exnstack.xul \
|
||||
test_weakref.xul \
|
||||
test_bug726949.xul \
|
||||
test_bug758563.xul \
|
||||
$(NULL)
|
||||
|
||||
# Disabled until this test gets updated to test the new proxy based
|
||||
|
80
js/xpconnect/tests/chrome/test_bug758563.xul
Normal file
80
js/xpconnect/tests/chrome/test_bug758563.xul
Normal file
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=758563
|
||||
-->
|
||||
<window title="Mozilla Bug 758563"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=758563"
|
||||
target="_blank">Mozilla Bug 758563</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for deprecation warnings for non-__exposedProps__ COWs. **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// Set up our console listener.
|
||||
var gWarnings = 0;
|
||||
function onWarning(consoleMessage) {
|
||||
if (/__exposedProps__/.test(consoleMessage.message))
|
||||
gWarnings++;
|
||||
}
|
||||
var gListener = {
|
||||
observe: onWarning,
|
||||
QueryInterface: function (iid) {
|
||||
if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
|
||||
!iid.equals(Components.interfaces.nsISupports)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
var gConsoleService = Components.classes["@mozilla.org/consoleservice;1"]
|
||||
.getService(Components.interfaces.nsIConsoleService);
|
||||
gConsoleService.registerListener(gListener);
|
||||
|
||||
// Wait for both child frame to load.
|
||||
var gLoadCount = 0;
|
||||
function frameLoaded() {
|
||||
if (++gLoadCount == 2)
|
||||
go();
|
||||
}
|
||||
|
||||
function go() {
|
||||
testFor('frame1');
|
||||
testFor('frame2');
|
||||
|
||||
// Warnings are dispatched async, so stick ourselves at the end of the event
|
||||
// queue.
|
||||
setTimeout(done, 0);
|
||||
}
|
||||
|
||||
function testFor(id) {
|
||||
var win = document.getElementById(id).contentWindow.wrappedJSObject;
|
||||
win.chromeObj = {a: 42};
|
||||
win.ok = ok;
|
||||
win.is = is;
|
||||
win.doAccess();
|
||||
}
|
||||
|
||||
function done() {
|
||||
gConsoleService.unregisterListener(gListener);
|
||||
is(gWarnings, 2, "Got the right number of warnings");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
]]>
|
||||
|
||||
</script>
|
||||
<iframe id="frame1" onload="frameLoaded();" type="content" src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_bug758563.html" />
|
||||
<iframe id="frame2" onload="frameLoaded();" type="content" src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_bug758563.html" />
|
||||
</window>
|
@ -63,6 +63,7 @@ _TEST_FILES = bug500931_helper.html \
|
||||
test_bug655297.html \
|
||||
test_bug691059.html \
|
||||
test_bug745483.html \
|
||||
file_bug758563.html \
|
||||
file_nodelists.html \
|
||||
file_bug706301.html \
|
||||
file_exnstack.html \
|
||||
|
19
js/xpconnect/tests/mochitest/file_bug758563.html
Normal file
19
js/xpconnect/tests/mochitest/file_bug758563.html
Normal file
@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/javascript">
|
||||
function doAccess() {
|
||||
// Access the variable twice.
|
||||
oneAccess();
|
||||
oneAccess();
|
||||
}
|
||||
|
||||
function oneAccess() {
|
||||
try {
|
||||
is(window.chromeObj.a, 42, "Successfully read chrome property");
|
||||
} catch (e) { ok(false, "Threw while trying to access chrome property"); };
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -13,6 +13,7 @@
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
|
||||
#include "XPCWrapper.h"
|
||||
#include "XrayWrapper.h"
|
||||
@ -489,6 +490,21 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper:
|
||||
if (!found) {
|
||||
// For now, only do this on functions.
|
||||
if (!JS_ObjectIsFunction(cx, wrappedObject)) {
|
||||
|
||||
// This little loop hole will go away soon! See bug 553102.
|
||||
JSAutoEnterCompartment innerAc;
|
||||
if (!innerAc.enter(cx, wrapper))
|
||||
return false;
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(cx, wrapper));
|
||||
if (win) {
|
||||
nsCOMPtr<nsIDocument> doc =
|
||||
do_QueryInterface(win->GetExtantDocument());
|
||||
if (doc) {
|
||||
doc->WarnOnceAbout(nsIDocument::eNoExposedProps);
|
||||
}
|
||||
}
|
||||
|
||||
perm = PermitPropertyAccess;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user