Commit fc0780ef authored by Cristian Tuns's avatar Cristian Tuns
Browse files

Backed out 10 changesets (bug 1793834, bug 1801724) for causing mochitest...

Backed out 10 changesets (bug 1793834, bug 1801724) for causing mochitest failures in browser_preferences_usage.js CLOSED TREE

Backed out changeset 89c9e4e1c3ad (bug 1801724)
Backed out changeset 9130ed00888e (bug 1793834)
Backed out changeset 34f582bdc341 (bug 1793834)
Backed out changeset c34df1dc8ff8 (bug 1793834)
Backed out changeset 2ae1429c886a (bug 1793834)
Backed out changeset a49eff0693ce (bug 1793834)
Backed out changeset 034466342a3b (bug 1793834)
Backed out changeset 2d19fa85af4e (bug 1793834)
Backed out changeset d16ff7dbd155 (bug 1793834)
Backed out changeset a39300a8ddff (bug 1793834)
parent 9999145b
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -279,12 +279,6 @@ var whitelist = [
    file: "resource://gre/localization/en-US/toolkit/about/aboutThirdParty.ftl",
    platforms: ["linux", "macosx"],
  },
  // Bug 1973834 - referenced by aboutWindowsMessages.html which is only for Windows
  {
    file:
      "resource://gre/localization/en-US/toolkit/about/aboutWindowsMessages.ftl",
    platforms: ["linux", "macosx"],
  },
  // Bug 1721741:
  // (The references to these files are dynamically generated, so the test can't
  // find the references)
+0 −2
Original line number Diff line number Diff line
@@ -157,8 +157,6 @@ static const RedirEntry kRedirMap[] = {
#ifdef XP_WIN
    {"third-party", "chrome://global/content/aboutThirdParty.html",
     nsIAboutModule::ALLOW_SCRIPT},
    {"windows-messages", "chrome://global/content/aboutWindowsMessages.html",
     nsIAboutModule::ALLOW_SCRIPT},
#endif
#ifndef MOZ_GLEAN_ANDROID
    {"glean", "chrome://global/content/aboutGlean.html",
+0 −1
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] != 'android':
    about_pages.append('profiles')
if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'windows':
    about_pages.append('third-party')
    about_pages.append('windows-messages')
if not defined('MOZ_GLEAN_ANDROID'):
    about_pages.append('glean')

+0 −7
Original line number Diff line number Diff line
@@ -14671,13 +14671,6 @@
  type: RelaxedAtomicInt32
  value: 0
  mirror: always

# The number of messages of each type to keep for display in
# about:windows-messages
- name: widget.windows.messages_to_log
  type: RelaxedAtomicUint32
  value: 6
  mirror: always
#endif

# Whether to flush the Ole clipboard synchronously.
+0 −93
Original line number Diff line number Diff line
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

#include "AboutWindowsMessages.h"

#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/StaticPtr.h"
#include "nsThreadUtils.h"
#include "nsPIDOMWindow.h"
#include "nsGlobalWindowOuter.h"
#include "nsServiceManagerUtils.h"
#include "nsIWindowMediator.h"
#include "nsIAppWindow.h"
#include "nsIBaseWindow.h"
#include "nsDocShellTreeOwner.h"
#include "mozilla/WidgetUtils.h"
#include "mozilla/widget/nsWindowLoggedMessages.h"

namespace mozilla {

static StaticRefPtr<AboutWindowsMessages> sSingleton;

NS_IMPL_ISUPPORTS(AboutWindowsMessages, nsIAboutWindowsMessages);

/*static*/
already_AddRefed<AboutWindowsMessages> AboutWindowsMessages::GetSingleton() {
  if (!sSingleton) {
    sSingleton = new AboutWindowsMessages;
    ClearOnShutdown(&sSingleton);
  }

  return do_AddRef(sSingleton);
}

static bool GetWindowTitleFromWindow(const nsCOMPtr<nsPIDOMWindowOuter>& window,
                                     nsAutoString& title) {
  nsIDocShell* docShell = window->GetDocShell();
  if (docShell) {
    nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
    docShell->GetTreeOwner(getter_AddRefs(parentTreeOwner));
    nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(parentTreeOwner));
    baseWindow->GetTitle(title);
    return true;
  }
  return false;
}

NS_IMETHODIMP
AboutWindowsMessages::GetMessages(mozIDOMWindowProxy* currentWindow,
                                  nsTArray<nsTArray<nsCString>>& messages,
                                  nsTArray<nsString>& windowTitles) {
  messages.Clear();
  // Display the current window's messages first
  auto currentWindowOuter = nsPIDOMWindowOuter::From(currentWindow);
  RefPtr<nsIWidget> currentWidget =
      widget::WidgetUtils::DOMWindowToWidget(currentWindowOuter);
  nsAutoString currentWindowTitle;
  if (GetWindowTitleFromWindow(currentWindowOuter, currentWindowTitle)) {
    nsTArray<nsCString> windowMessages;
    widget::GetLatestWindowMessages(currentWidget, windowMessages);
    windowTitles.AppendElement(currentWindowTitle);
    messages.EmplaceBack(std::move(windowMessages));
  }
  nsCOMPtr<nsIWindowMediator> mediator(
      do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
  nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
  mediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
  if (!windowEnumerator) return NS_ERROR_FAILURE;
  bool more;
  while (NS_SUCCEEDED(windowEnumerator->HasMoreElements(&more)) && more) {
    nsCOMPtr<nsISupports> isupports;
    if (NS_FAILED(windowEnumerator->GetNext(getter_AddRefs(isupports)))) break;
    nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryInterface(isupports);
    NS_ASSERTION(window, "not an nsPIDOMWindowOuter");
    RefPtr<nsIWidget> windowWidget =
        widget::WidgetUtils::DOMWindowToWidget(window);
    if (&*windowWidget != &*currentWidget) {
      nsAutoString title;
      if (GetWindowTitleFromWindow(window, title)) {
        nsTArray<nsCString> windowMessages;
        widget::GetLatestWindowMessages(windowWidget, windowMessages);
        windowTitles.AppendElement(title);
        messages.EmplaceBack(std::move(windowMessages));
      }
    }
  }
  return NS_OK;
}
}  // namespace mozilla
Loading