зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1031945. Don't expose showModalDialog on Window if it's preffed off. r=smaug
This commit is contained in:
Родитель
8e9ec70e42
Коммит
531e8ee54e
|
@ -4371,6 +4371,21 @@ nsGlobalWindow::IsChromeWindow(JSContext* aCx, JSObject* aObj)
|
|||
return xpc::WindowOrNull(aObj)->IsChromeWindow();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
nsGlobalWindow::IsShowModalDialogEnabled(JSContext*, JSObject*)
|
||||
{
|
||||
static bool sAddedPrefCache = false;
|
||||
static bool sIsDisabled;
|
||||
static const char sShowModalDialogPref[] = "dom.disable_window_showModalDialog";
|
||||
|
||||
if (!sAddedPrefCache) {
|
||||
Preferences::AddBoolVarCache(&sIsDisabled, sShowModalDialogPref, false);
|
||||
sAddedPrefCache = true;
|
||||
}
|
||||
|
||||
return !sIsDisabled;
|
||||
}
|
||||
|
||||
nsIDOMOfflineResourceList*
|
||||
nsGlobalWindow::GetApplicationCache(ErrorResult& aError)
|
||||
{
|
||||
|
@ -9127,7 +9142,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
|
|||
(aUrl, aArgument, aOptions, aError), aError,
|
||||
nullptr);
|
||||
|
||||
if (Preferences::GetBool("dom.disable_window_showModalDialog", false)) {
|
||||
if (!IsShowModalDialogEnabled()) {
|
||||
aError.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -512,6 +512,9 @@ public:
|
|||
|
||||
static bool IsChromeWindow(JSContext* /* unused */, JSObject* aObj);
|
||||
|
||||
static bool IsShowModalDialogEnabled(JSContext* /* unused */ = nullptr,
|
||||
JSObject* /* unused */ = nullptr);
|
||||
|
||||
bool DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JSPropertyDescriptor> aDesc);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Properties of the window object</title>
|
||||
<link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
|
||||
<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
|
||||
<link rel="help" href="http://ecma-international.org/ecma-262/5.1/#sec-15.1">
|
||||
<link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#interface-prototype-object">
|
||||
<link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#es-attributes">
|
||||
<link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#es-operations">
|
||||
<link rel="help" href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventtarget">
|
||||
<link rel="help" href="http://heycam.github.io/webidl/#interface-prototype-object">
|
||||
<link rel="help" href="http://heycam.github.io/webidl/#es-attributes">
|
||||
<link rel="help" href="http://heycam.github.io/webidl/#es-operations">
|
||||
<link rel="help" href="http://dom.spec.whatwg.org/#eventtarget">
|
||||
<link rel="help" href="http://www.whatwg.org/html/#window">
|
||||
<link rel="help" href="http://www.whatwg.org/html/#windowtimers">
|
||||
<link rel="help" href="http://www.whatwg.org/html/#windowbase64">
|
||||
|
@ -64,7 +64,7 @@ var methods = [
|
|||
"confirm",
|
||||
"prompt",
|
||||
"print",
|
||||
"showModalDialog",
|
||||
// See below: "showModalDialog",
|
||||
"postMessage",
|
||||
|
||||
// WindowBase64
|
||||
|
@ -90,6 +90,12 @@ var methods = [
|
|||
"scrollBy"
|
||||
];
|
||||
|
||||
// We would like to remove showModalDialog from the platform,
|
||||
// see <https://www.w3.org/Bugs/Public/show_bug.cgi?id=26437>.
|
||||
if ("showModalDialog" in window) {
|
||||
methods.push("showModalDialog");
|
||||
}
|
||||
|
||||
var readonlyAttributes = [
|
||||
"history",
|
||||
"parent",
|
||||
|
|
|
@ -79,7 +79,8 @@ typedef any Transferable;
|
|||
[Throws] DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
|
||||
[Throws] void print();
|
||||
//[Throws] any showModalDialog(DOMString url, optional any argument);
|
||||
[Throws] any showModalDialog(DOMString url, optional any argument, optional DOMString options = "");
|
||||
[Throws, Func="nsGlobalWindow::IsShowModalDialogEnabled"]
|
||||
any showModalDialog(DOMString url, optional any argument, optional DOMString options = "");
|
||||
|
||||
[Throws, CrossOriginCallable] void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer);
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 328897;
|
||||
var summary = 'JS_ReportPendingException should';
|
||||
|
||||
var actual = 'No Error';
|
||||
var expect = 'No Error';
|
||||
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
if (typeof window == 'undefined')
|
||||
{
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
||||
else
|
||||
{
|
||||
expect = /TypeError: Not enough arguments to Window.showModalDialog./;
|
||||
|
||||
window._onerror = window.onerror;
|
||||
window.onerror = (function (msg, page, line) {
|
||||
actual = msg;
|
||||
gDelayTestDriverEnd = false;
|
||||
jsTestDriverEnd();
|
||||
reportMatch(expect, actual, summary);
|
||||
});
|
||||
|
||||
gDelayTestDriverEnd = true;
|
||||
|
||||
// Trying to set call window.showModalDialog() without any arguments will throw.
|
||||
window.showModalDialog();
|
||||
actual = 'No Error';
|
||||
}
|
||||
|
||||
function onload()
|
||||
{
|
||||
if (actual == 'No Error')
|
||||
{
|
||||
gDelayTestDriverEnd = false;
|
||||
jsTestDriverEnd();
|
||||
reportCompare(expect, actual, summary);
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче