Commit 5c65681c authored by Nika Layzell's avatar Nika Layzell
Browse files

Bug 1415645 - Part 5: Fix some more consumers of nsGlobalWindow which I missed, r=smaug

MozReview-Commit-ID: DvMH4cVw5NK
parent 53984f31
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@
#include "gtest/gtest.h"
#include "nsGlobalWindow.h"

// XXX(nika): I can't find any non-test callers of this code, can we remove it?

struct dialog_test {
  const char* input;
  const char* output;
@@ -25,7 +27,7 @@ void runTokenizeTest(dialog_test& test)
  nsAutoString result;
  nsAutoString token;

  while (nsGlobalWindow::TokenizeDialogOptions(token, iter, end)) {
  while (nsGlobalWindowInner::TokenizeDialogOptions(token, iter, end)) {
    if (!result.IsEmpty()) {
      result.Append(',');
    }
@@ -41,7 +43,7 @@ void runTest(dialog_test& test)
  NS_ConvertUTF8toUTF16 input(test.input);

  nsAutoString result;
  nsGlobalWindow::ConvertDialogOptions(input, result);
  nsGlobalWindowInner::ConvertDialogOptions(input, result);

  ASSERT_STREQ(test.output, NS_ConvertUTF16toUTF8(result).get()) << "Testing " << test.input;
}
+19 −19
Original line number Diff line number Diff line
@@ -377,19 +377,19 @@ partial interface Window {
// Mozilla extensions for Chrome windows.
partial interface Window {
  // The STATE_* constants need to match the corresponding enum in nsGlobalWindow.cpp.
  [Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  const unsigned short STATE_MAXIMIZED = 1;
  [Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  const unsigned short STATE_MINIMIZED = 2;
  [Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  const unsigned short STATE_NORMAL = 3;
  [Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  const unsigned short STATE_FULLSCREEN = 4;

  [Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  readonly attribute unsigned short windowState;

  [Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  readonly attribute boolean isFullyOccluded;

  /**
@@ -397,40 +397,40 @@ partial interface Window {
   * utility functions implemented by chrome script. It will be null
   * for DOMWindows not corresponding to browsers.
   */
  [Throws, Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
           attribute nsIBrowserDOMWindow? browserDOMWindow;

  [Throws, Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  void                      getAttention();

  [Throws, Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  void                      getAttentionWithCycleCount(long aCycleCount);

  [Throws, Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  void                      setCursor(DOMString cursor);

  [Func="nsGlobalWindow::IsPrivilegedChromeWindow", UnsafeInPrerendering]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow", UnsafeInPrerendering]
  void                      maximize();
  [Func="nsGlobalWindow::IsPrivilegedChromeWindow", UnsafeInPrerendering]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow", UnsafeInPrerendering]
  void                      minimize();
  [Func="nsGlobalWindow::IsPrivilegedChromeWindow", UnsafeInPrerendering]
  [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow", UnsafeInPrerendering]
  void                      restore();

  /**
   * Notify a default button is loaded on a dialog or a wizard.
   * defaultButton is the default button.
   */
  [Throws, Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  void notifyDefaultButtonLoaded(Element defaultButton);

  [Throws, Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  readonly attribute nsIMessageBroadcaster messageManager;

  /**
   * Returns the message manager identified by the given group name that
   * manages all frame loaders belonging to that group.
   */
  [Throws, Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  nsIMessageBroadcaster getGroupMessageManager(DOMString aGroup);

  /**
@@ -443,7 +443,7 @@ partial interface Window {
   *
   * Throws NS_ERROR_NOT_IMPLEMENTED if the OS doesn't support this.
   */
  [Throws, Func="nsGlobalWindow::IsPrivilegedChromeWindow"]
  [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
  void beginWindowMove(Event mouseDownEvent, optional Element? panel = null);

  [Func="IsChromeOrXBL"]
@@ -478,10 +478,10 @@ partial interface Window {
Window implements WindowOrWorkerGlobalScope;

partial interface Window {
  [Throws, Func="nsGlobalWindow::IsRequestIdleCallbackEnabled"]
  [Throws, Func="nsGlobalWindowInner::IsRequestIdleCallbackEnabled"]
  unsigned long requestIdleCallback(IdleRequestCallback callback,
                                    optional IdleRequestOptions options);
  [Func="nsGlobalWindow::IsRequestIdleCallbackEnabled"]
  [Func="nsGlobalWindowInner::IsRequestIdleCallbackEnabled"]
  void          cancelIdleCallback(unsigned long handle);
};

+5 −5
Original line number Diff line number Diff line
@@ -711,13 +711,13 @@ XPCJSContext::InterruptCallback(JSContext* cx)
    }

    // Show the prompt to the user, and kill if requested.
    nsGlobalWindow::SlowScriptResponse response = win->ShowSlowScriptDialog(addonId);
    if (response == nsGlobalWindow::KillSlowScript) {
    nsGlobalWindowInner::SlowScriptResponse response = win->ShowSlowScriptDialog(addonId);
    if (response == nsGlobalWindowInner::KillSlowScript) {
        if (Preferences::GetBool("dom.global_stop_script", true))
            xpc::Scriptability::Get(global).Block();
        return false;
    }
    if (response == nsGlobalWindow::KillScriptGlobal) {
    if (response == nsGlobalWindowInner::KillScriptGlobal) {
        nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();

        if (!IsSandbox(global) || !obs)
@@ -742,10 +742,10 @@ XPCJSContext::InterruptCallback(JSContext* cx)

    // The user chose to continue the script. Reset the timer, and disable this
    // machinery with a pref of the user opted out of future slow-script dialogs.
    if (response != nsGlobalWindow::ContinueSlowScriptAndKeepNotifying)
    if (response != nsGlobalWindowInner::ContinueSlowScriptAndKeepNotifying)
        self->mSlowScriptCheckpoint = TimeStamp::NowLoRes();

    if (response == nsGlobalWindow::AlwaysContinueSlowScript)
    if (response == nsGlobalWindowInner::AlwaysContinueSlowScript)
        Preferences::SetInt(prefName, 0);

    return true;
+1 −1
Original line number Diff line number Diff line
@@ -1224,7 +1224,7 @@ nsDocumentViewer::PermitUnloadInternal(bool *aShouldPrompt,
    // Never permit dialogs from the beforeunload handler
    nsGlobalWindowOuter* globalWindow = nsGlobalWindowOuter::Cast(window);
    dialogsAreEnabled = globalWindow->AreDialogsEnabled();
    nsGlobalWindow::TemporarilyDisableDialogs disableDialogs(globalWindow);
    nsGlobalWindowOuter::TemporarilyDisableDialogs disableDialogs(globalWindow);

    nsIDocument::PageUnloadingEventTimeStamp timestamp(mDocument);

+4 −2
Original line number Diff line number Diff line
@@ -166,7 +166,8 @@ nsLayoutStatics::Initialize()
    return rv;
  }

  nsGlobalWindow::Init();
  // XXX: Arbitrarially choose inner window?
  nsGlobalWindowInner::Init();
  Navigator::Init();
  nsXBLService::Init();

@@ -380,7 +381,8 @@ nsLayoutStatics::Shutdown()
  RuleProcessorCache::Shutdown();

  ShutdownJSEnvironment();
  nsGlobalWindow::ShutDown();
  // XXX: Arbitrarially choose inner window?
  nsGlobalWindowInner::ShutDown();
  nsDOMClassInfo::ShutDown();
  WebIDLGlobalNameHash::Shutdown();
  nsListControlFrame::Shutdown();