Issue #1366 - Completely remove showModalDialog

pull/24/head
Gaming4JC 3 years ago committed by Roy Tam
parent abb2afe2a7
commit 8d600c51ed
  1. 17
      docshell/base/nsDocShell.cpp
  2. 1
      dom/base/nsDeprecatedOperationList.h
  3. 333
      dom/base/nsGlobalWindow.cpp
  4. 61
      dom/base/nsGlobalWindow.h
  5. 10
      dom/base/nsPIDOMWindow.h
  6. 3
      dom/base/nsSandboxFlags.h
  7. 4
      dom/base/test/mochitest.ini
  8. 62
      dom/base/test/mutationobserver_dialog.html
  9. 31
      dom/base/test/test_dialogArguments.html
  10. 22
      dom/base/test/test_mutationobservers.html
  11. 11
      dom/html/test/file_iframe_sandbox_c_if4.html
  12. 30
      dom/html/test/file_iframe_sandbox_j_if1.html
  13. 28
      dom/html/test/file_iframe_sandbox_j_if2.html
  14. 27
      dom/html/test/file_iframe_sandbox_j_if3.html
  15. 10
      dom/html/test/mochitest.ini
  16. 25
      dom/html/test/test_bug391777.html
  17. 2
      dom/html/test/test_iframe_sandbox_general.html
  18. 122
      dom/html/test/test_iframe_sandbox_modal.html
  19. 2
      dom/locales/en-US/chrome/dom/dom.properties
  20. 4
      dom/media/webspeech/recognition/test/test_nested_eventloop.html
  21. 28
      dom/tests/mochitest/bugs/file_bug291653.html
  22. 22
      dom/tests/mochitest/bugs/file_bug504862.html
  23. 12
      dom/tests/mochitest/bugs/mochitest.ini
  24. 56
      dom/tests/mochitest/bugs/test_bug291653.html
  25. 37
      dom/tests/mochitest/bugs/test_bug406375.html
  26. 6
      dom/tests/mochitest/bugs/test_bug414291.html
  27. 72
      dom/tests/mochitest/bugs/test_bug437361.html
  28. 44
      dom/tests/mochitest/bugs/test_bug479143.html
  29. 45
      dom/tests/mochitest/bugs/test_bug504862.html
  30. 22
      dom/tests/mochitest/bugs/test_bug61098.html
  31. 38
      dom/tests/mochitest/bugs/test_bug735237.html
  32. 35
      dom/tests/mochitest/general/file_showModalDialog.html
  33. 3
      dom/tests/mochitest/general/mochitest.ini
  34. 60
      dom/tests/mochitest/general/test_showModalDialog.html
  35. 14
      dom/webidl/Window.webidl
  36. 3
      embedding/browser/nsIWebBrowserChrome.idl
  37. 24
      embedding/components/windowwatcher/nsWindowWatcher.cpp
  38. 1
      modules/libpref/init/all.js

@ -13356,24 +13356,9 @@ nsDocShell::EnsureScriptEnvironment()
uint32_t chromeFlags;
browserChrome->GetChromeFlags(&chromeFlags);
bool isModalContentWindow =
(mItemType == typeContent) &&
(chromeFlags & nsIWebBrowserChrome::CHROME_MODAL_CONTENT_WINDOW);
// There can be various other content docshells associated with the
// top-level window, like sidebars. Make sure that we only create an
// nsGlobalModalWindow for the primary content shell.
if (isModalContentWindow) {
nsCOMPtr<nsIDocShellTreeItem> primaryItem;
nsresult rv =
mTreeOwner->GetPrimaryContentShell(getter_AddRefs(primaryItem));
NS_ENSURE_SUCCESS(rv, rv);
isModalContentWindow = (primaryItem == this);
}
// If our window is modal and we're not opened as chrome, make
// this window a modal content window.
mScriptGlobal =
NS_NewScriptGlobalObject(mItemType == typeChrome, isModalContentWindow);
mScriptGlobal = NS_NewScriptGlobalObject(mItemType == typeChrome);
MOZ_ASSERT(mScriptGlobal);
mScriptGlobal->SetDocShell(this);

@ -34,7 +34,6 @@ DEPRECATED_OPERATION(UseOfCaptureEvents)
DEPRECATED_OPERATION(UseOfReleaseEvents)
DEPRECATED_OPERATION(UseOfDOM3LoadMethod)
DEPRECATED_OPERATION(ChromeUseOfDOM3LoadMethod)
DEPRECATED_OPERATION(ShowModalDialog)
DEPRECATED_OPERATION(Window_Content)
DEPRECATED_OPERATION(SyncXMLHttpRequest)
DEPRECATED_OPERATION(DataContainerEvent)

@ -909,7 +909,6 @@ nsPIDOMWindow<T>::nsPIDOMWindow(nsPIDOMWindowOuter *aOuterWindow)
mMayHaveMouseEnterLeaveEventListener(false),
mMayHavePointerEnterLeaveEventListener(false),
mInnerObjectsFreed(false),
mIsModalContentWindow(false),
mIsActive(false), mIsBackground(false),
mMediaSuspend(Preferences::GetBool("media.block-autoplay-until-in-foreground", true) ?
nsISuspendedTypes::SUSPENDED_BLOCK : nsISuspendedTypes::NONE_SUSPENDED),
@ -1957,7 +1956,6 @@ nsGlobalWindow::CleanUp()
}
mArguments = nullptr;
mDialogArguments = nullptr;
CleanupCachedXBLHandlers(this);
@ -2195,7 +2193,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mArguments)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDialogArguments)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReturnValue)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNavigator)
@ -2274,7 +2271,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mArguments)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDialogArguments)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mReturnValue)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mNavigator)
@ -3019,8 +3015,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
} else {
if (thisChrome) {
newInnerWindow = nsGlobalChromeWindow::Create(this);
} else if (mIsModalContentWindow) {
newInnerWindow = nsGlobalModalWindow::Create(this);
} else {
newInnerWindow = nsGlobalWindow::Create(this);
}
@ -3871,31 +3865,16 @@ nsGlobalWindow::SetArguments(nsIArray *aArguments)
MOZ_ASSERT(IsOuterWindow());
nsresult rv;
// Historically, we've used the same machinery to handle openDialog arguments
// (exposed via window.arguments) and showModalDialog arguments (exposed via
// window.dialogArguments), even though the former is XUL-only and uses an XPCOM
// array while the latter is web-exposed and uses an arbitrary JS value.
// Moreover, per-spec |dialogArguments| is a property of the browsing context
// (outer), whereas |arguments| lives on the inner.
//
// We've now mostly separated them, but the difference is still opaque to
// nsWindowWatcher (the caller of SetArguments in this little back-and-forth
// embedding waltz we do here).
//
// So we need to demultiplex the two cases here.
nsGlobalWindow *currentInner = GetCurrentInnerWindowInternal();
if (mIsModalContentWindow) {
// nsWindowWatcher blindly converts the original nsISupports into an array
// of length 1. We need to recover it, and then cast it back to the concrete
// object we know it to be.
nsCOMPtr<nsISupports> supports = do_QueryElementAt(aArguments, 0, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mDialogArguments = static_cast<DialogValueHolder*>(supports.get());
} else {
mArguments = aArguments;
rv = currentInner->DefineArgumentsProperty(aArguments);
NS_ENSURE_SUCCESS(rv, rv);
}
mArguments = aArguments;
rv = currentInner->DefineArgumentsProperty(aArguments);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -3904,7 +3883,6 @@ nsresult
nsGlobalWindow::DefineArgumentsProperty(nsIArray *aArguments)
{
MOZ_ASSERT(IsInnerWindow());
MOZ_ASSERT(!mIsModalContentWindow); // Handled separately.
nsIScriptContext *ctx = GetOuterWindowInternal()->mContext;
NS_ENSURE_TRUE(aArguments && ctx, NS_ERROR_NOT_INITIALIZED);
@ -5040,21 +5018,6 @@ nsGlobalWindow::IsPrivilegedChromeWindow(JSContext* aCx, JSObject* aObj)
nsContentUtils::ObjectPrincipal(aObj) == nsContentUtils::GetSystemPrincipal();
}
/* 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 && !XRE_IsContentProcess();
}
nsIDOMOfflineResourceList*
nsGlobalWindow::GetApplicationCache(ErrorResult& aError)
{
@ -9741,126 +9704,6 @@ nsGlobalWindow::ConvertDialogOptions(const nsAString& aOptions,
}
}
already_AddRefed<nsIVariant>
nsGlobalWindow::ShowModalDialogOuter(const nsAString& aUrl,
nsIVariant* aArgument,
const nsAString& aOptions,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
if (mDoc) {
mDoc->WarnOnceAbout(nsIDocument::eShowModalDialog);
}
if (!IsShowModalDialogEnabled()) {
aError.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
RefPtr<DialogValueHolder> argHolder =
new DialogValueHolder(&aSubjectPrincipal, aArgument);
// Before bringing up the window/dialog, unsuppress painting and flush
// pending reflows.
EnsureReflowFlushAndPaint();
if (!AreDialogsEnabled()) {
// We probably want to keep throwing here; silently doing nothing is a bit
// weird given the typical use cases of showModalDialog().
aError.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
if (ShouldPromptToBlockDialogs() && !ConfirmDialogIfNeeded()) {
aError.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
nsCOMPtr<nsPIDOMWindowOuter> dlgWin;
nsAutoString options(NS_LITERAL_STRING("-moz-internal-modal=1,status=1"));
ConvertDialogOptions(aOptions, options);
options.AppendLiteral(",scrollbars=1,centerscreen=1,resizable=0");
EnterModalState();
uint32_t oldMicroTaskLevel = nsContentUtils::MicroTaskLevel();
nsContentUtils::SetMicroTaskLevel(0);
aError = OpenInternal(aUrl, EmptyString(), options,
false, // aDialog
true, // aContentModal
true, // aCalledNoScript
true, // aDoJSFixups
true, // aNavigate
nullptr, argHolder, // args
nullptr, // aLoadInfo
false, // aForceNoOpener
getter_AddRefs(dlgWin));
nsContentUtils::SetMicroTaskLevel(oldMicroTaskLevel);
LeaveModalState();
if (aError.Failed()) {
return nullptr;
}
nsCOMPtr<nsIDOMModalContentWindow> dialog = do_QueryInterface(dlgWin);
if (!dialog) {
return nullptr;
}
nsCOMPtr<nsIVariant> retVal;
aError = dialog->GetReturnValue(getter_AddRefs(retVal));
MOZ_ASSERT(!aError.Failed());
return retVal.forget();
}
already_AddRefed<nsIVariant>
nsGlobalWindow::ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
const nsAString& aOptions,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(ShowModalDialogOuter,
(aUrl, aArgument, aOptions, aSubjectPrincipal,
aError), aError, nullptr);
}
void
nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
JS::Handle<JS::Value> aArgument,
const nsAString& aOptions,
JS::MutableHandle<JS::Value> aRetval,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
MOZ_ASSERT(IsInnerWindow());
nsCOMPtr<nsIVariant> args;
aError = nsContentUtils::XPConnect()->JSToVariant(aCx,
aArgument,
getter_AddRefs(args));
if (aError.Failed()) {
return;
}
nsCOMPtr<nsIVariant> retVal =
ShowModalDialog(aUrl, args, aOptions, aSubjectPrincipal, aError);
if (aError.Failed()) {
return;
}
JS::Rooted<JS::Value> result(aCx);
if (retVal) {
aError = nsContentUtils::XPConnect()->VariantToJS(aCx,
FastGetGlobalJSObject(),
retVal, aRetval);
} else {
aRetval.setNull();
}
}
class ChildCommandDispatcher : public Runnable
{
public:
@ -14613,174 +14456,6 @@ nsGlobalChromeWindow::TakeOpenerForInitialContentBrowser(mozIDOMWindowProxy** aO
return NS_OK;
}
// nsGlobalModalWindow implementation
// QueryInterface implementation for nsGlobalModalWindow
NS_INTERFACE_MAP_BEGIN(nsGlobalModalWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMModalContentWindow)
NS_INTERFACE_MAP_END_INHERITING(nsGlobalWindow)
NS_IMPL_ADDREF_INHERITED(nsGlobalModalWindow, nsGlobalWindow)
NS_IMPL_RELEASE_INHERITED(nsGlobalModalWindow, nsGlobalWindow)
void
nsGlobalWindow::GetDialogArgumentsOuter(JSContext* aCx,
JS::MutableHandle<JS::Value> aRetval,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
MOZ_ASSERT(IsModalContentWindow(),
"This should only be called on modal windows!");
if (!mDialogArguments) {
MOZ_ASSERT(mIsClosed, "This window should be closed!");
aRetval.setUndefined();
return;
}
// This does an internal origin check, and returns undefined if the subject
// does not subsumes the origin of the arguments.
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
JSAutoCompartment ac(aCx, wrapper);
mDialogArguments->Get(aCx, wrapper, &aSubjectPrincipal, aRetval, aError);
}
void
nsGlobalWindow::GetDialogArguments(JSContext* aCx,
JS::MutableHandle<JS::Value> aRetval,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(GetDialogArgumentsOuter,
(aCx, aRetval, aSubjectPrincipal, aError),
aError, );
}
/* static */ already_AddRefed<nsGlobalModalWindow>
nsGlobalModalWindow::Create(nsGlobalWindow *aOuterWindow)
{
RefPtr<nsGlobalModalWindow> window = new nsGlobalModalWindow(aOuterWindow);
window->InitWasOffline();
return window.forget();
}
NS_IMETHODIMP
nsGlobalModalWindow::GetDialogArguments(nsIVariant **aArguments)
{
FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(GetDialogArguments, (aArguments),
NS_ERROR_NOT_INITIALIZED);
// This does an internal origin check, and returns undefined if the subject
// does not subsumes the origin of the arguments.
return mDialogArguments->Get(nsContentUtils::SubjectPrincipal(), aArguments);
}
/* static */ already_AddRefed<nsGlobalWindow>
nsGlobalWindow::Create(nsGlobalWindow *aOuterWindow)
{
RefPtr<nsGlobalWindow> window = new nsGlobalWindow(aOuterWindow);
window->InitWasOffline();
return window.forget();
}
void
nsGlobalWindow::InitWasOffline()
{
mWasOffline = NS_IsOffline();
}
void
nsGlobalWindow::GetReturnValueOuter(JSContext* aCx,
JS::MutableHandle<JS::Value> aReturnValue,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
MOZ_ASSERT(IsModalContentWindow(),
"This should only be called on modal windows!");
if (mReturnValue) {
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
JSAutoCompartment ac(aCx, wrapper);
mReturnValue->Get(aCx, wrapper, &aSubjectPrincipal, aReturnValue, aError);
} else {
aReturnValue.setUndefined();
}
}
void
nsGlobalWindow::GetReturnValue(JSContext* aCx,
JS::MutableHandle<JS::Value> aReturnValue,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(GetReturnValueOuter,
(aCx, aReturnValue, aSubjectPrincipal, aError),
aError, );
}
NS_IMETHODIMP
nsGlobalModalWindow::GetReturnValue(nsIVariant **aRetVal)
{
FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(GetReturnValue, (aRetVal), NS_OK);
if (!mReturnValue) {
nsCOMPtr<nsIVariant> variant = CreateVoidVariant();
variant.forget(aRetVal);
return NS_OK;
}
return mReturnValue->Get(nsContentUtils::SubjectPrincipal(), aRetVal);
}
void
nsGlobalWindow::SetReturnValueOuter(JSContext* aCx,
JS::Handle<JS::Value> aReturnValue,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
MOZ_ASSERT(IsModalContentWindow(),
"This should only be called on modal windows!");
nsCOMPtr<nsIVariant> returnValue;
aError =
nsContentUtils::XPConnect()->JSToVariant(aCx, aReturnValue,
getter_AddRefs(returnValue));
if (!aError.Failed()) {
mReturnValue = new DialogValueHolder(&aSubjectPrincipal, returnValue);
}
}
void
nsGlobalWindow::SetReturnValue(JSContext* aCx,
JS::Handle<JS::Value> aReturnValue,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(SetReturnValueOuter,
(aCx, aReturnValue, aSubjectPrincipal, aError),
aError, );
}
NS_IMETHODIMP
nsGlobalModalWindow::SetReturnValue(nsIVariant *aRetVal)
{
FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(SetReturnValue, (aRetVal), NS_OK);
mReturnValue = new DialogValueHolder(nsContentUtils::SubjectPrincipal(),
aRetVal);
return NS_OK;
}
/* static */
bool
nsGlobalWindow::IsModalContentWindow(JSContext* aCx, JSObject* aGlobal)
{
return xpc::WindowOrNull(aGlobal)->IsModalContentWindow();
}
#if defined(MOZ_WIDGET_ANDROID)
int16_t
nsGlobalWindow::Orientation(CallerType aCallerType) const

@ -458,9 +458,6 @@ public:
static bool IsPrivilegedChromeWindow(JSContext* /* unused */, JSObject* aObj);
static bool IsShowModalDialogEnabled(JSContext* /* unused */ = nullptr,
JSObject* /* unused */ = nullptr);
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
JS::Handle<jsid> aId,
JS::MutableHandle<JS::PropertyDescriptor> aDesc);
@ -583,9 +580,6 @@ public:
return mIsChrome;
}
using nsPIDOMWindow::IsModalContentWindow;
static bool IsModalContentWindow(JSContext* aCx, JSObject* aGlobal);
// GetScrollFrame does not flush. Callers should do it themselves as needed,
// depending on which info they actually want off the scrollable frame.
nsIScrollableFrame *GetScrollFrame();
@ -950,12 +944,6 @@ public:
mozilla::ErrorResult& aRv);
void PrintOuter(mozilla::ErrorResult& aError);
void Print(mozilla::ErrorResult& aError);
void ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
JS::Handle<JS::Value> aArgument,
const nsAString& aOptions,
JS::MutableHandle<JS::Value> aRetval,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const nsAString& aTargetOrigin,
const mozilla::dom::Optional<mozilla::dom::Sequence<JS::Value > >& aTransfer,
@ -1227,12 +1215,6 @@ public:
mozilla::dom::Element* aPanel,
mozilla::ErrorResult& aError);
void GetDialogArgumentsOuter(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
void GetDialogArguments(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
void GetReturnValueOuter(JSContext* aCx, JS::MutableHandle<JS::Value> aReturnValue,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
@ -1681,18 +1663,6 @@ protected:
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
already_AddRefed<nsIVariant>
ShowModalDialogOuter(const nsAString& aUrl, nsIVariant* aArgument,
const nsAString& aOptions,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
already_AddRefed<nsIVariant>
ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
const nsAString& aOptions,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
// Ask the user if further dialogs should be blocked, if dialogs are currently
// being abused. This is used in the cases where we have no modifiable UI to
// show, in that case we show a separate dialog to ask this question.
@ -1832,9 +1802,6 @@ protected:
// For |window.arguments|, via |openDialog|.
nsCOMPtr<nsIArray> mArguments;
// For |window.dialogArguments|, via |showModalDialog|.
RefPtr<DialogValueHolder> mDialogArguments;
// Only used in the outer.
RefPtr<DialogValueHolder> mReturnValue;
@ -2067,40 +2034,14 @@ public:
nsCOMPtr<mozIDOMWindowProxy> mOpenerForInitialContentBrowser;
};
/*
* nsGlobalModalWindow inherits from nsGlobalWindow. It is the global
* object created for a modal content windows only (i.e. not modal
* chrome dialogs).
*/
class nsGlobalModalWindow : public nsGlobalWindow,
public nsIDOMModalContentWindow
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMMODALCONTENTWINDOW
static already_AddRefed<nsGlobalModalWindow> Create(nsGlobalWindow *aOuterWindow);
protected:
explicit nsGlobalModalWindow(nsGlobalWindow *aOuterWindow)
: nsGlobalWindow(aOuterWindow)
{
mIsModalContentWindow = true;
}
~nsGlobalModalWindow() {}
};
/* factory function */
inline already_AddRefed<nsGlobalWindow>
NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow)
NS_NewScriptGlobalObject(bool aIsChrome)
{
RefPtr<nsGlobalWindow> global;
if (aIsChrome) {
global = nsGlobalChromeWindow::Create(nullptr);
} else if (aIsModalContentWindow) {
global = nsGlobalModalWindow::Create(nullptr);
} else {
global = nsGlobalWindow::Create(nullptr);
}

@ -303,11 +303,6 @@ public:
virtual bool CanClose() = 0;
virtual void ForceClose() = 0;
bool IsModalContentWindow() const
{
return mIsModalContentWindow;
}
/**
* Call this to indicate that some node (this window, its document,
* or content in that document) has a paint event listener.
@ -629,11 +624,6 @@ protected:
// This member is only used by inner windows.
bool mInnerObjectsFreed;
// This variable is used on both inner and outer windows (and they
// should match).
bool mIsModalContentWindow;
// Tracks activation state that's used for :-moz-window-inactive.
// Only used on outer windows.
bool mIsActive;

@ -29,8 +29,7 @@ const unsigned long SANDBOXED_NAVIGATION = 0x1;
/**
* This flag prevents content from creating new auxiliary browsing contexts,
* e.g. using the target attribute, the window.open() method, or the
* showModalDialog() method.
* e.g. using the target attribute, or the window.open() method.
*/
const unsigned long SANDBOXED_AUXILIARY_NAVIGATION = 0x2;

@ -196,7 +196,6 @@ support-files =
formReset.html
invalid_accesscontrol.resource
invalid_accesscontrol.resource^headers^
mutationobserver_dialog.html
orientationcommon.js
script-1_bug597345.sjs
script-2_bug597345.js
@ -627,9 +626,6 @@ subsuite = clipboard
skip-if = toolkit == 'android' #bug 904183
[test_createHTMLDocument.html]
[test_declare_stylesheet_obsolete.html]
[test_dialogArguments.html]
tags = openwindow
skip-if = toolkit == 'android' || e10s # showmodaldialog
[test_document.all_iteration.html]
[test_document.all_unqualified.html]
[test_document_constructor.html]

@ -1,62 +0,0 @@
<html>
<head>
<title></title>
<script>
var div = document.createElement("div");
var M;
if ("MozMutationObserver" in window) {
M = window.MozMutationObserver;
} else if ("WebKitMutationObserver" in window) {
M = window.WebKitMutationObserver;
} else {
M = window.MutationObserver;
}
var didCall1 = false;
var didCall2 = false;
function testMutationObserverInDialog() {
div.innerHTML = "<span>1</span><span>2</span>";
m = new M(function(records, observer) {
opener.is(records[0].type, "childList", "Should have got childList");
opener.is(records[0].removedNodes.length, 2, "Should have got removedNodes");
opener.is(records[0].addedNodes.length, 1, "Should have got addedNodes");
observer.disconnect();
m = null;
didCall1 = true;
});
m.observe(div, { childList: true });
div.innerHTML = "<span><span>foo</span></span>";
}
function testMutationObserverInDialog2() {
div.innerHTML = "<span>1</span><span>2</span>";
m = new M(function(records, observer) {
opener.is(records[0].type, "childList", "Should have got childList");
opener.is(records[0].removedNodes.length, 2, "Should have got removedNodes");
opener.is(records[0].addedNodes.length, 1, "Should have got addedNodes");
observer.disconnect();
m = null;
didCall2 = true;
});
m.observe(div, { childList: true });
div.innerHTML = "<span><span>foo</span></span>";
}
window.addEventListener("load", testMutationObserverInDialog);
window.addEventListener("load", testMutationObserverInDialog2);
window.addEventListener("load",
function() {
opener.ok(didCall1, "Should have called 1st mutation callback");
opener.ok(didCall2, "Should have called 2nd mutation callback");
window.close();
});
</script>
<style>
</style>
</head>
<body>
<input type="button" onclick="window.close()" value="close">
</body>
</html>

@ -1,31 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test for Bug 1019761</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<script type="application/javascript">
/*
Tests whether Firefox crashes when accessing the dialogArguments property
of a modal window that has been closed.
*/
SimpleTest.waitForExplicitFinish();
function openModal() {
showModalDialog("javascript:opener.winRef = window; \
window.opener.setTimeout(\'winRef.dialogArguments;\', 0);\
window.close();");
ok(true, "dialogArguments did not cause a crash.");
SimpleTest.finish();
}
window.onload = openModal;
</script>
</body>
</html>

@ -484,28 +484,6 @@ function testSyncXHR() {
function testSyncXHR2() {
ok(callbackHandled, "Should have called the mutation callback!");
then(testModalDialog);
}
function testModalDialog() {
var didHandleCallback = false;
div.innerHTML = "<span>1</span><span>2</span>";
m = new M(function(records, observer) {
is(records[0].type, "childList", "Should have got childList");
is(records[0].removedNodes.length, 2, "Should have got removedNodes");
is(records[0].addedNodes.length, 1, "Should have got addedNodes");
observer.disconnect();
m = null;
didHandleCallback = true;
});
m.observe(div, { childList: true });
div.innerHTML = "<span><span>foo</span></span>";
try {
window.showModalDialog("mutationobserver_dialog.html");
ok(didHandleCallback, "Should have called the callback while showing modal dialog!");
} catch(e) {
todo(false, "showModalDialog not implemented on this platform");
}
then(testTakeRecords);
}

@ -12,7 +12,7 @@
}
function doStuff() {
// try to open a new window via target="_blank", target="BC341604", window.open(), and showModalDialog()
// try to open a new window via target="_blank", target="BC341604", and window.open()
// the window we try to open closes itself once it opens
sendMouseEvent({type:'click'}, 'target_blank');
sendMouseEvent({type:'click'}, 'target_BC341604');
@ -25,15 +25,6 @@
}
ok(threw, "window.open threw a JS exception and was not allowed");
threw = false;
try {
window.showModalDialog("about:blank");
} catch(error) {
threw = true;
}
ok(threw, "window.showModalDialog threw a JS exception and was not allowed");
}
</script>
<body onLoad="doStuff()">

@ -1,30 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 766282</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<script type="text/javascript">
function doStuff() {
// Open a new window via showModalDialog().
try {
window.showModalDialog("file_iframe_sandbox_k_if5.html");
} catch(e) {
window.parent.ok_wrapper(false, "iframes sandboxed with allow-popups and allow-modals should be able to open a modal dialog");
}
// Open a new window via showModalDialog().
try {
window.showModalDialog("file_iframe_sandbox_k_if7.html");
} catch(e) {
window.parent.ok_wrapper(false, "iframes sandboxed with allow-popups and allow-modals should be able to open a modal dialog");
}
}
</script>
<body onLoad="doStuff()">
I am sandboxed with "allow-scripts allow-popups allow-same-origin allow-forms allow-top-navigation".
</body>
</html>

@ -1,28 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 766282</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<script type="text/javascript">
function doSubOpens() {
// Open a new window showModalDialog().
try {
window.showModalDialog("file_iframe_sandbox_k_if9.html");
} catch(e) {
window.parent.ok_wrapper(false, "iframes sandboxed with allow-popups and allow-modals should be able to open a modal dialog");
}
}
window.doSubOpens = doSubOpens;
</script>
<body>
I am sandboxed but with "allow-scripts allow-popups allow-same-origin".
After my initial load, "allow-same-origin" is removed and then I open file_iframe_sandbox_k_if9.html,
which attemps to call a function in my parent.
This should succeed since the new sandbox flags shouldn't have taken affect on me until I'm reloaded.
</body>
</html>

@ -1,27 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tests for Bug 766282</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<script type="text/javascript">
function ok(result, desc) {
window.parent.ok_wrapper(result, desc);
}
function doStuff() {
// Try to open a new window via showModalDialog().
// The window we try to open closes itself once it opens.
try {
window.showModalDialog("file_iframe_sandbox_open_window_pass.html");
} catch(e) {
ok(false, "iframes sandboxed with allow-popups and allow-modals should be able to open a modal dialog");
}
}
</script>
<body onLoad="doStuff()">
I am sandboxed but with "allow-popups allow-scripts allow-same-origin"
</body>
</html>

@ -154,9 +154,6 @@ support-files =
file_iframe_sandbox_form_pass.html
file_iframe_sandbox_g_if1.html
file_iframe_sandbox_h_if1.html
file_iframe_sandbox_j_if1.html
file_iframe_sandbox_j_if2.html
file_iframe_sandbox_j_if3.html
file_iframe_sandbox_k_if1.html
file_iframe_sandbox_k_if2.html
file_iframe_sandbox_k_if3.html
@ -471,9 +468,6 @@ skip-if = toolkit == 'android' # just copy the conditions from the test above
tags = openwindow
[test_iframe_sandbox_inheritance.html]
tags = openwindow
[test_iframe_sandbox_modal.html]
tags = openwindow
skip-if = toolkit == 'android' || e10s #modal tests fail on android
[test_iframe_sandbox_navigation.html]
tags = openwindow
[test_iframe_sandbox_navigation2.html]
@ -540,8 +534,6 @@ skip-if = toolkit == 'android' #bug 811644
[test_bug369370.html]
skip-if = toolkit == "android" || toolkit == "windows" # disabled on Windows because of bug 1234520
[test_bug380383.html]
[test_bug391777.html]
skip-if = toolkit == 'android' || e10s
[test_bug402680.html]
[test_bug403868.html]
[test_bug403868.xhtml]
@ -607,4 +599,4 @@ skip-if = os == "android" # up/down arrow keys not supported on android
[test_script_module.html]
support-files =
file_script_module.html
file_script_nomodule.html
file_script_nomodule.html

@ -1,25 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=391777
-->
<head>
<title>Test for Bug 391777</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=391777">Mozilla Bug 391777</a>
<p id="display"></p>
<script class="testbody" type="text/javascript">
/** Test for Bug 391777 **/
var arg = {};
arg.testVal = "foo";
var result = window.showModalDialog("javascript:window.returnValue = window.dialogArguments.testVal; window.close(); 'This window should close on its own.';", arg);
ok(true, "We should get here without user interaction");
is(result, "foo", "Unexpected result from showModalDialog");
</script>
</body>
</html>

@ -41,7 +41,7 @@ function ok_wrapper(result, desc) {
passedTests++;
}
if (completedTests == 33) {
if (completedTests == 32) {
is(passedTests, completedTests, "There are " + completedTests + " general tests that should pass");
SimpleTest.finish();
}

@ -1,122 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=766282
implement allow-popups directive for iframe sandbox
-->
<head>
<meta charset="utf-8">
<title>Tests for Bug 766282</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
// A postMessage handler that is used by sandboxed iframes without
// 'allow-same-origin' to communicate pass/fail back to this main page.
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
switch (event.data.type) {
case "attempted":
testAttempted();
break;
case "ok":
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
break;
default:
// allow for old style message
if (event.data.ok != undefined) {
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
}
}
}
var attemptedTests = 0;
var passedTests = 0;
var totalTestsToPass = 5;
var totalTestsToAttempt = 5;
function ok_wrapper(result, desc, addToAttempted = true) {
ok(result, desc);
if (result) {
passedTests++;
}
if (addToAttempted) {
testAttempted();
}
}
// Added so that tests that don't register unless they fail,
// can at least notify that they've attempted to run.
function testAttempted() {
attemptedTests++;
if (attemptedTests == totalTestsToAttempt) {
// Make sure all tests have had a chance to complete.
setTimeout(function() {finish();}, 1000);
}
}
var finishCalled = false;
function finish() {
if (!finishCalled) {
finishCalled = true;
is(passedTests, totalTestsToPass, "There are " + totalTestsToPass + " modal tests that should pass");
SimpleTest.finish();
}
}
function doTest() {
// passes if good and fails if bad
// 1) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
// allow-same-origin" should not have its origin sandbox flag set and be able to access
// document.cookie. (Done by file_iframe_sandbox_k_if5.html opened from
// file_iframe_sandbox_j_if1.html) using showModalDialog.)
// passes if good
// 2) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
// allow-top-navigation" should not have its top-level navigation sandbox flag set and be able to
// navigate top. (Done by file_iframe_sandbox_k_if5.html (and if6) opened from
// file_iframe_sandbox_j_if1.html) using showModalDialog.)
// passes if good
// 3) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
// all-forms" should not have its forms sandbox flag set and be able to submit forms.
// (Done by file_iframe_sandbox_k_if7.html opened from
// file_iframe_sandbox_j_if1.html) using showModalDialog.)
// passes if good
// 4) Make sure that the sandbox flags copied to a new browsing context are taken from the
// current active document not the browsing context (iframe / docShell).
// This is done by removing allow-same-origin and calling doSubOpens from file_iframe_sandbox_j_if2.html,
// which opens file_iframe_sandbox_k_if9.html using showModalDialog.
var if_2 = document.getElementById('if_2');
if_2.sandbox = 'allow-scripts allow-popups';
if_2.contentWindow.doSubOpens();
// passes if good
// 5) Test that a sandboxed iframe with "allow-popups" can open a new window using window.ShowModalDialog.
// This is done via file_iframe_sandbox_j_if3.html which is sandboxed with "allow-popups allow-scripts
// allow-same-origin". The window it attempts to open calls window.opener.ok(true, ...) and
// file_iframe_j_if3.html has an ok() function that calls window.parent.ok_wrapper.
}
addLoadEvent(doTest);
</script>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=766282">Mozilla Bug 766282</a> - implement allow-popups directive for iframe sandbox
<p id="display"></p>
<div id="content">
<iframe sandbox="allow-scripts allow-popups allow-modals allow-same-origin allow-forms allow-top-navigation" id="if_1" src="file_iframe_sandbox_j_if1.html" height="10" width="10"></iframe>
<iframe sandbox="allow-scripts allow-popups allow-modals allow-same-origin" id="if_2" src="file_iframe_sandbox_j_if2.html" height="10" width="10"></iframe>
<iframe sandbox="allow-popups allow-modals allow-same-origin allow-scripts" id="if_3" src="file_iframe_sandbox_j_if3.html" height="10" width="10"></iframe>
</div>

@ -174,8 +174,6 @@ UseOfCaptureEventsWarning=Use of captureEvents() is deprecated. To upgrade your
UseOfReleaseEventsWarning=Use of releaseEvents() is deprecated. To upgrade your code, use the DOM 2 removeEventListener() method. For more help http://developer.mozilla.org/en/docs/DOM:element.removeEventListener
# LOCALIZATION NOTE: Do not translate "document.load()" or "XMLHttpRequest"
UseOfDOM3LoadMethodWarning=Use of document.load() is deprecated. To upgrade your code, use the DOM XMLHttpRequest object. For more help https://developer.mozilla.org/en/XMLHttpRequest
# LOCALIZATION NOTE: Do not translate "window.showModalDialog()" or "window.open()"
ShowModalDialogWarning=Use of window.showModalDialog() is deprecated. Use window.open() instead. For more help https://developer.mozilla.org/en-US/docs/Web/API/Window.open
# LOCALIZATION NOTE: Do not translate "window._content" or "window.content"
Window_ContentWarning=window._content is deprecated. Please use window.content instead.
# LOCALIZATION NOTE: Do not translate "XMLHttpRequest"

@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
SimpleTest.waitForExplicitFinish();
/*
* window.showModalDialog() can be used to spin the event loop, causing
* SpecialPowers.spinEventLoop can be used to spin the event loop, causing
* queued SpeechEvents (such as those created by calls to start(), stop()
* or abort()) to be processed immediately.
* When this is done from inside DOM event handlers, it is possible to
@ -33,7 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
}
function doneFunc() {
// Trigger gc now and wait some time to make sure this test gets the blame
// for any assertions caused by showModalDialog
// for any assertions caused by spinning the event loop.
//
// NB - The assertions should be gone, but this looks too scary to touch
// during batch cleanup.

@ -1,28 +0,0 @@
<html>
<head>
<script>
<!--
function listener1() {
window.showModalDialog("data:text/html,<script>var maintest = opener.opener; opener.location = 'data:text/html,test'; maintest.end(); window.close();</script>");
}
function listener2() {
opener.secondListenerDidRun = true;
}
window.addEventListener("foo", listener1);
window.addEventListener("foo", listener2);
function fireFoo() {
var e = document.createEvent("Events");
e.initEvent("foo", true, true);
window.dispatchEvent(e);
}
//-->
</script>
</head>
<body onload="setTimeout(fireFoo, 0)">
Test for bug 291653
</body>
</html>

@ -1,22 +0,0 @@
<html>
<body>
<script>
window.returnValue = 3;
if (location.toString().match(/^http:\/\/mochi.test:8888/)) {
// Test that we got the right arguments.
opener.is(window.dialogArguments, "my args",
"dialog did not get the right arguments.");
// Load a different url, and test that it sees the arguments (since it's same origin).
window.location="data:text/html,<html><body onload=\"opener.is(window.dialogArguments, 'my args', 'subsequent dialog document did not get the right arguments.'); close();\">';";
} else {
// Post a message containing our arguments to the opener to test
// that this cross origing dialog does *not* see the passed in
// arguments.
opener.postMessage("args: " + window.dialogArguments,
"http://mochi.test:8888");
close();
}
</script>

@ -10,9 +10,6 @@ support-files =
child_bug260264.html
devicemotion_inner.html
devicemotion_outer.html
file_bug291653.html
file_bug406375.html
file_bug504862.html
file_bug593174_1.html
file_bug593174_2.html
file_bug809290_b1.html
@ -45,7 +42,6 @@ skip-if = toolkit == 'android'
[test_bug260264_nested.html]
[test_bug265203.html]
[test_bug291377.html]
[test_bug291653.html]
skip-if = toolkit == 'android' #TIMED_OUT
[test_bug304459.html]
[test_bug308856.html]
@ -67,28 +63,21 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug396843.html]
[test_bug400204.html]
[test_bug404748.html]
[test_bug406375.html]
skip-if = toolkit == 'android'
[test_bug414291.html]
tags = openwindow
[test_bug427744.html]
skip-if = toolkit == 'android'
[test_bug42976.html]
[test_bug430276.html]
[test_bug437361.html]
skip-if = toolkit == 'android'
[test_bug440572.html]
[test_bug456151.html]
[test_bug458091.html]
[test_bug459848.html]
[test_bug465263.html]
[test_bug479143.html]
skip-if = toolkit == 'android'
[test_bug484775.html]
[test_bug492925.html]
[test_bug49312.html]
[test_bug495219.html]
[test_bug504862.html]
skip-if = toolkit == 'android' #RANDOM
[test_bug529328.html]
[test_bug531176.html]
@ -126,7 +115,6 @@ skip-if = toolkit == 'android'
[test_bug698061.html]
[test_bug698551.html]
[test_bug707749.html]
[test_bug735237.html]
[test_bug739038.html]
[test_bug740811.html]
[test_bug743615.html]

@ -1,56 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=291653
-->
<head>
<title>Test for Bug 291653</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=291653">Mozilla Bug 291653</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 291653 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
var secondListenerDidRun = false;
var w;
function start() {
if ("showModalDialog" in window) {
w = window.open("file_bug291653.html", "foo", "width=300,height=300");
} else {
// window.showModalDialog doesn't exist in e10s mode, nothing to do in this test.
ok(true, "nothing to do in e10s mode");
SimpleTest.finish();
}
}
function closeTest() {
w.setTimeout("close()", 0);
setTimeout("finish()", 500);
}
function finish() {
ok(!secondListenerDidRun, "Shouldn't have run second listener!");
SimpleTest.finish();
}
function end() {
setTimeout("closeTest()", 500);
}
start();
</script>
</pre>
</body>
</html>

@ -1,37 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=406375
-->
<head>
<title>Test for Bug 406375</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="runTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=406375">Mozilla Bug 406375</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 406375 **/
SimpleTest.waitForExplicitFinish();
function runTest() {
if ("showModalDialog" in window) {
window.showModalDialog("file_bug406375.html");
}
ok(true, "This test should not hang");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

@ -16,7 +16,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=414291
var result1 = 0;
var result2 = 0;
var result3 = 0;
window.open("data:text/html,<html><body onload='close(); opener.result1 = 1;'>", "w1");
is(result1, 0, "window should not be opened either as modal or loaded synchronously.");
@ -24,11 +23,6 @@ is(result1, 0, "window should not be opened either as modal or loaded synchronou
window.open("data:text/html,<html><body onload='close(); opener.result2 = 2;'>", "w2", "modal=yes");
is(result2, 0, "window should not be opened either as modal or data loaded synchronously.");
if (window.showModalDialog) {
result3 = window.showModalDialog("data:text/html,<html><body onload='close(); returnValue = 3;'>");
is(result3, 3, "window should be opened as modal.");