From 760b4604b12dfd12dc8a0eee72a19ea320e2e6a4 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Sat, 24 Jan 2015 14:52:07 -0800 Subject: [PATCH] Back out 2 changesets (bug 1125351, bug 1069719) for m-oth bustage CLOSED TREE Backed out changeset fb315ec11af4 (bug 1125351) Backed out changeset 0ab33c2362cf (bug 1069719) --- docshell/base/nsDocShell.cpp | 6 +- docshell/base/nsIDocShell.idl | 2 +- dom/bindings/BindingUtils.cpp | 44 +------ dom/bindings/BindingUtils.h | 15 +-- dom/bindings/Codegen.py | 6 +- dom/bindings/test/chrome.ini | 5 - dom/bindings/test/file_focuser.html | 24 ---- .../test/file_fullScreenPropertyAccessor.html | 24 ---- ...test_blacklisted_prerendering_function.xul | 124 ------------------ 9 files changed, 14 insertions(+), 236 deletions(-) delete mode 100644 dom/bindings/test/file_focuser.html delete mode 100644 dom/bindings/test/file_fullScreenPropertyAccessor.html delete mode 100644 dom/bindings/test/test_blacklisted_prerendering_function.xul diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index a4ddd62686be..f576d2fb2e4d 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3383,7 +3383,11 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent) { SetIsActive(value); } - SetIsPrerendered(parentAsDocShell->GetIsPrerendered()); + if (NS_SUCCEEDED(parentAsDocShell->GetIsPrerendered(&value))) { + if (value) { + SetIsPrerendered(true); + } + } if (NS_FAILED(parentAsDocShell->GetAllowDNSPrefetch(&value))) { value = false; } diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 9cd80000f8f6..acc4dbded56f 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -624,7 +624,7 @@ interface nsIDocShell : nsIDocShellTreeItem * native code to be able to put a docshell in prerendering. */ [noscript] void SetIsPrerendered(in boolean prerendered); - [infallible] readonly attribute boolean isPrerendered; + readonly attribute boolean isPrerendered; /** * The ID of the docshell in the session history. diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 39fe8fd08445..e477e08a9b0d 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -20,7 +20,6 @@ #include "jsfriendapi.h" #include "nsContentUtils.h" #include "nsGlobalWindow.h" -#include "nsIDocShell.h" #include "nsIDOMGlobalPropertyInitializer.h" #include "nsIPermissionManager.h" #include "nsIPrincipal.h" @@ -2382,47 +2381,12 @@ CheckPermissions(JSContext* aCx, JSObject* aObj, const char* const aPermissions[ return false; } -void -HandlePrerenderingViolation(nsPIDOMWindow* aWindow) -{ - // Suspend the window and its workers, and its children too. - aWindow->SuspendTimeouts(); - - // Suspend event handling on the document - nsCOMPtr doc = aWindow->GetExtantDoc(); - if (doc) { - doc->SuppressEventHandling(nsIDocument::eEvents); - } -} - bool -EnforceNotInPrerendering(JSContext* aCx, JSObject* aObj) +CheckSafetyInPrerendering(JSContext* aCx, JSObject* aObj) { - JS::Rooted thisObj(aCx, js::CheckedUnwrap(aObj)); - if (!thisObj) { - // Without a this object, we cannot check the safety. - return true; - } - nsGlobalWindow* window = xpc::WindowGlobalOrNull(thisObj); - if (!window) { - // Without a window, we cannot check the safety. - return true; - } - - nsIDocShell* docShell = window->GetDocShell(); - if (!docShell) { - // Without a docshell, we cannot check the safety. - return true; - } - - if (docShell->GetIsPrerendered()) { - HandlePrerenderingViolation(window); - // When the bindings layer sees a false return value, it returns false form - // the JSNative in order to trigger an uncatchable exception. - return false; - } - - return true; + //TODO: Check if page is being prerendered. + //Returning false for now. + return false; } bool diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index 53846fa2a5fd..6e7c874108fb 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -3142,20 +3142,9 @@ AssertReturnTypeMatchesJitinfo(const JSJitInfo* aJitinfo, bool CheckPermissions(JSContext* aCx, JSObject* aObj, const char* const aPermissions[]); -// This function is called by the bindings layer for methods/getters/setters -// that are not safe to be called in prerendering mode. It checks to make sure -// that the |this| object is not running in a global that is in prerendering -// mode. Otherwise, it aborts execution of timers and event handlers, and -// returns false which gets converted to an uncatchable exception by the -// bindings layer. +//Returns true if page is being prerendered. bool -EnforceNotInPrerendering(JSContext* aCx, JSObject* aObj); - -// Handles the violation of a blacklisted action in prerendering mode by -// aborting the scripts, and preventing timers and event handlers from running -// in the window in the future. -void -HandlePrerenderingViolation(nsPIDOMWindow* aWindow); +CheckSafetyInPrerendering(JSContext* aCx, JSObject* aObj); bool CallerSubsumes(JSObject* aObject); diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 674d6d6bc71d..2bc28151c63c 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -6503,10 +6503,8 @@ class CGPerSignatureCall(CGThing): for i in descriptor.interface.getInheritedInterfaces())): cgThings.append(CGGeneric(dedent( """ - if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) { - // Return false from the JSNative in order to trigger - // an uncatchable exception. - MOZ_ASSERT(!JS_IsExceptionPending(cx)); + if (mozilla::dom::CheckSafetyInPrerendering(cx, obj)) { + //TODO: Handle call into unsafe API during Prerendering (Bug 730101) return false; } """))) diff --git a/dom/bindings/test/chrome.ini b/dom/bindings/test/chrome.ini index 173fd79102a4..689bb0415faa 100644 --- a/dom/bindings/test/chrome.ini +++ b/dom/bindings/test/chrome.ini @@ -6,8 +6,3 @@ [test_dom_xrays.html] [test_proxies_via_xray.html] [test_document_location_via_xray_cached.html] -[test_blacklisted_prerendering_function.xul] -support-files = - file_focuser.html - file_fullScreenPropertyAccessor.html -skip-if = e10s # prerendering doesn't work in e10s yet diff --git a/dom/bindings/test/file_focuser.html b/dom/bindings/test/file_focuser.html deleted file mode 100644 index 0d5240f95b1a..000000000000 --- a/dom/bindings/test/file_focuser.html +++ /dev/null @@ -1,24 +0,0 @@ - -
- diff --git a/dom/bindings/test/file_fullScreenPropertyAccessor.html b/dom/bindings/test/file_fullScreenPropertyAccessor.html deleted file mode 100644 index 92a37e0bac62..000000000000 --- a/dom/bindings/test/file_fullScreenPropertyAccessor.html +++ /dev/null @@ -1,24 +0,0 @@ - -
- diff --git a/dom/bindings/test/test_blacklisted_prerendering_function.xul b/dom/bindings/test/test_blacklisted_prerendering_function.xul deleted file mode 100644 index f542458b1dec..000000000000 --- a/dom/bindings/test/test_blacklisted_prerendering_function.xul +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - -Mozilla Bug 1069719 -

- -
-
- - - -