Restore browser.history.allow... and more.
parent
2ee57d93d2
commit
a371672f3d
|
@ -470,6 +470,8 @@ static uint32_t gThrottledIdlePeriodLength;
|
|||
// CIDs
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
|
||||
static const char sPopStatePrefStr[] = "browser.history.allowPopState";
|
||||
|
||||
#define NETWORK_UPLOAD_EVENT_NAME NS_LITERAL_STRING("moznetworkupload")
|
||||
#define NETWORK_DOWNLOAD_EVENT_NAME NS_LITERAL_STRING("moznetworkdownload")
|
||||
|
||||
|
@ -10637,9 +10639,14 @@ nsGlobalWindow::DispatchSyncPopState()
|
|||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Check that PopState hasn't been pref'ed off.
|
||||
if (!Preferences::GetBool(sPopStatePrefStr, false)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Bail if the window is frozen.
|
||||
if (IsFrozen()) {
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Get the document's pending state object -- it contains the data we're
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
static const char* sAllowPushStatePrefStr =
|
||||
"browser.history.allowPushState";
|
||||
static const char* sAllowReplaceStatePrefStr =
|
||||
"browser.history.allowReplaceState";
|
||||
static const char* sAllowOtherStuffPrefStr =
|
||||
"browser.history.allowOtherStuff";
|
||||
//
|
||||
// History class implementation
|
||||
//
|
||||
|
@ -62,6 +68,11 @@ nsHistory::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
uint32_t
|
||||
nsHistory::GetLength(ErrorResult& aRv) const
|
||||
{
|
||||
|
||||
if (!Preferences::GetBool(sAllowOtherStuffPrefStr, false)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
|
||||
if (!win || !win->HasActiveDocument()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
@ -92,6 +103,10 @@ nsHistory::GetLength(ErrorResult& aRv) const
|
|||
ScrollRestoration
|
||||
nsHistory::GetScrollRestoration(mozilla::ErrorResult& aRv)
|
||||
{
|
||||
if (!Preferences::GetBool(sAllowOtherStuffPrefStr, false)) {
|
||||
return mozilla::dom::ScrollRestoration::Auto;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
|
||||
if (!win || !win->HasActiveDocument() || !win->GetDocShell()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
@ -110,6 +125,11 @@ void
|
|||
nsHistory::SetScrollRestoration(mozilla::dom::ScrollRestoration aMode,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
|
||||
if (!Preferences::GetBool(sAllowOtherStuffPrefStr, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
|
||||
if (!win || !win->HasActiveDocument() || !win->GetDocShell()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
@ -125,6 +145,12 @@ void
|
|||
nsHistory::GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
|
||||
ErrorResult& aRv) const
|
||||
{
|
||||
|
||||
if (!Preferences::GetBool(sAllowOtherStuffPrefStr, false)) {
|
||||
aResult.setNull();
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
|
||||
if (!win) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
|
@ -166,6 +192,11 @@ nsHistory::GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
|
|||
void
|
||||
nsHistory::Go(int32_t aDelta, ErrorResult& aRv)
|
||||
{
|
||||
|
||||
if (!Preferences::GetBool(sAllowOtherStuffPrefStr, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
|
||||
if (!win || !win->HasActiveDocument()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
@ -225,6 +256,11 @@ nsHistory::Go(int32_t aDelta, ErrorResult& aRv)
|
|||
void
|
||||
nsHistory::Back(ErrorResult& aRv)
|
||||
{
|
||||
|
||||
if (!Preferences::GetBool(sAllowOtherStuffPrefStr, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
|
||||
if (!win || !win->HasActiveDocument()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
@ -246,6 +282,11 @@ nsHistory::Back(ErrorResult& aRv)
|
|||
void
|
||||
nsHistory::Forward(ErrorResult& aRv)
|
||||
{
|
||||
|
||||
if (!Preferences::GetBool(sAllowOtherStuffPrefStr, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
|
||||
if (!win || !win->HasActiveDocument()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
@ -298,6 +339,13 @@ nsHistory::PushOrReplaceState(JSContext* aCx, JS::Handle<JS::Value> aData,
|
|||
return;
|
||||
}
|
||||
|
||||
// Check that PushState hasn't been pref'ed off.
|
||||
if (!Preferences::GetBool(aReplace ? sAllowReplaceStatePrefStr :
|
||||
sAllowPushStatePrefStr, false)) {
|
||||
aRv = NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// AddState might run scripts, so we need to hold a strong reference to the
|
||||
// docShell here to keep it from going away.
|
||||
nsCOMPtr<nsIDocShell> docShell = win->GetDocShell();
|
||||
|
|
|
@ -4680,6 +4680,10 @@ pref("html5.flushtimer.initialdelay", 120);
|
|||
pref("html5.flushtimer.subsequentdelay", 120);
|
||||
|
||||
// Push/Pop/Replace State prefs
|
||||
pref("browser.history.allowPushState", true);
|
||||
pref("browser.history.allowReplaceState", true);
|
||||
pref("browser.history.allowPopState", true);
|
||||
pref("browser.history.allowOtherStuff", true);
|
||||
pref("browser.history.maxStateObjectSize", 655360);
|
||||
|
||||
pref("browser.meta_refresh_when_inactive.disabled", false);
|
||||
|
|
Loading…
Reference in New Issue