diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 974140f3a3b5..7ea3816dd17f 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1382,3 +1382,27 @@ nsDOMWindowUtils::GetCurrentInnerWindowID(PRUint64 *aWindowID) *aWindowID = inner->mWindowID; return NS_OK; } + +NS_IMETHODIMP +nsDOMWindowUtils::SuspendTimeouts() +{ + if (!IsUniversalXPConnectCapable()) { + return NS_ERROR_DOM_SECURITY_ERR; + } + + mWindow->SuspendTimeouts(); + + return NS_OK; +} + +NS_IMETHODIMP +nsDOMWindowUtils::ResumeTimeouts() +{ + if (!IsUniversalXPConnectCapable()) { + return NS_ERROR_DOM_SECURITY_ERR; + } + + mWindow->ResumeTimeouts(); + + return NS_OK; +} diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 39f5d613710f..302dc0e43c00 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -9138,7 +9138,7 @@ nsGlobalWindow::SuspendTimeouts(PRUint32 aIncrease, for (nsTimeout *t = FirstTimeout(); IsTimeout(t); t = t->Next()) { // Set mTimeRemaining to be the time remaining for this timer. if (t->mWhen > now) - t->mTimeRemaining = now - t->mWhen; + t->mTimeRemaining = t->mWhen - now; else t->mTimeRemaining = TimeDuration(0); diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 678a60c197fd..360f7c5ce9b4 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -53,7 +53,7 @@ interface nsIDOMEvent; interface nsITransferable; interface nsIQueryContentEventResult; -[scriptable, uuid(a6dbdbc9-5564-4e52-820a-4056c698f699)] +[scriptable, uuid(1e042706-0343-4cba-a549-6a83eefb1835)] interface nsIDOMWindowUtils : nsISupports { /** @@ -691,4 +691,10 @@ interface nsIDOMWindowUtils : nsISupports { * Is the window is in a modal state? [See enterModalState()] */ boolean isInModalState(); + + /** + * Suspend/resume timeouts on this window and its descendant windows. + */ + void suspendTimeouts(); + void resumeTimeouts(); }; diff --git a/dom/tests/mochitest/bugs/Makefile.in b/dom/tests/mochitest/bugs/Makefile.in index 5e5de84a30f7..291f78f19a2e 100644 --- a/dom/tests/mochitest/bugs/Makefile.in +++ b/dom/tests/mochitest/bugs/Makefile.in @@ -117,6 +117,7 @@ _TEST_FILES = \ test_bug545314.html \ test_bug548828.html \ test_DOMWindowCreated_chromeonly.html \ + test_bug581072.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/dom/tests/mochitest/bugs/test_bug581072.html b/dom/tests/mochitest/bugs/test_bug581072.html new file mode 100644 index 000000000000..2ae8a1f1df42 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug581072.html @@ -0,0 +1,49 @@ + + + + + Test for Bug 581072 + + + + + +Mozilla Bug 581072 +

+ +
+
+
+ +