Bug 903311. Remove all ChromeOnly methods on window.history. r=bzbarsky
authorJohnny Stenback <jst@mozilla.com>
Tue, 13 Aug 2013 21:02:01 -0700
changeset 150561 8fbc8f21565354e0d15477bd1e5b7ca353dca5f3
parent 150560 950b1a7567b8d33f0372686f9dae6129a8df5e29
child 150562 d0c7789c7ff0a3c3e058495f05e82241a014a279
push id4254
push userakeybl@mozilla.com
push dateTue, 17 Sep 2013 14:18:33 +0000
treeherdermozilla-aurora@9edd56e694b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs903311
milestone26.0a1
Bug 903311. Remove all ChromeOnly methods on window.history. r=bzbarsky
dom/base/nsHistory.cpp
dom/base/nsHistory.h
dom/webidl/History.webidl
--- a/dom/base/nsHistory.cpp
+++ b/dom/base/nsHistory.cpp
@@ -250,218 +250,16 @@ void
 nsHistory::ReplaceState(JSContext* aCx, JS::Handle<JS::Value> aData,
                         const nsAString& aTitle, const nsAString& aUrl,
                         ErrorResult& aRv)
 {
   PushOrReplaceState(aCx, aData, aTitle, aUrl, aRv, true);
 }
 
 void
-nsHistory::GetCurrent(nsString& aRetval, ErrorResult& aRv) const
-{
-  MOZ_ASSERT(nsContentUtils::IsCallerChrome());
-
-  aRetval.Truncate();
-
-  int32_t curIndex = 0;
-  nsAutoCString curURL;
-  nsCOMPtr<nsISHistory> sHistory = GetSessionHistory();
-  if (!sHistory) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  // Get the current index at session History
-  sHistory->GetIndex(&curIndex);
-  nsCOMPtr<nsIHistoryEntry> curEntry;
-  nsCOMPtr<nsIURI> uri;
-
-  // Get the SH entry for the current index
-  sHistory->GetEntryAtIndex(curIndex, false, getter_AddRefs(curEntry));
-  if (!curEntry) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  // Get the URI for the current entry
-  curEntry->GetURI(getter_AddRefs(uri));
-  if (!uri) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  uri->GetSpec(curURL);
-  CopyUTF8toUTF16(curURL, aRetval);
-}
-
-void
-nsHistory::GetPrevious(nsString& aRetval, ErrorResult& aRv) const
-{
-  MOZ_ASSERT(nsContentUtils::IsCallerChrome());
-
-  aRetval.Truncate();
-
-  int32_t curIndex;
-  nsAutoCString prevURL;
-  nsCOMPtr<nsISHistory> sHistory = GetSessionHistory();
-  if (!sHistory) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  // Get the current index at session History
-  sHistory->GetIndex(&curIndex);
-  nsCOMPtr<nsIHistoryEntry> prevEntry;
-  nsCOMPtr<nsIURI> uri;
-
-  // Get the previous SH entry
-  sHistory->GetEntryAtIndex((curIndex - 1), false, getter_AddRefs(prevEntry));
-  if (!prevEntry) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  // Get the URI for the previous entry
-  prevEntry->GetURI(getter_AddRefs(uri));
-  if (!uri) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  uri->GetSpec(prevURL);
-  CopyUTF8toUTF16(prevURL, aRetval);
-}
-
-void
-nsHistory::GetNext(nsString& aRetval, ErrorResult& aRv) const
-{
-  MOZ_ASSERT(nsContentUtils::IsCallerChrome());
-
-  aRetval.Truncate();
-
-  int32_t curIndex;
-  nsAutoCString nextURL;
-  nsCOMPtr<nsISHistory> sHistory = GetSessionHistory();
-  if (!sHistory) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  // Get the current index at session History
-  sHistory->GetIndex(&curIndex);
-  nsCOMPtr<nsIHistoryEntry> nextEntry;
-  nsCOMPtr<nsIURI> uri;
-
-  // Get the next SH entry
-  sHistory->GetEntryAtIndex((curIndex+1), false, getter_AddRefs(nextEntry));
-  if (!nextEntry) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  // Get the URI for the next entry
-  nextEntry->GetURI(getter_AddRefs(uri));
-
-  if (!uri) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  uri->GetSpec(nextURL);
-  CopyUTF8toUTF16(nextURL, aRetval);
-}
-
-void
-nsHistory::Item(uint32_t aIndex, nsString& aRetval, ErrorResult& aRv)
-{
-  bool unused;
-  IndexedGetter(aIndex, unused, aRetval, aRv);
-}
-
-void
-nsHistory::IndexedGetter(uint32_t aIndex, bool &aFound, nsString& aRetval,
-                         ErrorResult& aRv)
-{
-  aRetval.Truncate();
-  aFound = false;
-
-  if (!nsContentUtils::IsCallerChrome()) {
-    aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
-
-    return;
-  }
-
-  nsCOMPtr<nsISHistory> session_history = GetSessionHistory();
-  if (!session_history) {
-    aRv.Throw(NS_ERROR_FAILURE);
-
-    return;
-  }
-
-  nsCOMPtr<nsIHistoryEntry> sh_entry;
-  nsCOMPtr<nsIURI> uri;
-
-  aRv = session_history->GetEntryAtIndex(aIndex, false,
-                                         getter_AddRefs(sh_entry));
-
-  if (aRv.Failed()) {
-    return;
-  }
-
-  if (sh_entry) {
-    aRv = sh_entry->GetURI(getter_AddRefs(uri));
-  }
-
-  if (uri) {
-    nsAutoCString urlCString;
-    aRv = uri->GetSpec(urlCString);
-
-    if (aRv.Failed()) {
-      return;
-    }
-
-    CopyUTF8toUTF16(urlCString, aRetval);
-
-    aFound = true;
-  }
-}
-
-uint32_t
-nsHistory::Length()
-{
-  if (!nsContentUtils::IsCallerChrome()) {
-    return 0;
-  }
-
-  // Get session History from docshell
-  nsCOMPtr<nsISHistory> sHistory = GetSessionHistory();
-  if (!sHistory) {
-    return 0;
-  }
-
-  int32_t len;
-  nsresult rv = sHistory->GetCount(&len);
-
-  if (NS_FAILED(rv) || len < 0) {
-    return 0;
-  }
-
-  return len;
-}
-
-void
 nsHistory::PushOrReplaceState(JSContext* aCx, JS::Value aData,
                               const nsAString& aTitle, const nsAString& aUrl,
                               ErrorResult& aRv, bool aReplace)
 {
   nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mInnerWindow));
   if (!win) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
 
--- a/dom/base/nsHistory.h
+++ b/dom/base/nsHistory.h
@@ -42,23 +42,16 @@ public:
   void Back(mozilla::ErrorResult& aRv);
   void Forward(mozilla::ErrorResult& aRv);
   void PushState(JSContext* aCx, JS::Handle<JS::Value> aData,
                  const nsAString& aTitle, const nsAString& aUrl,
                  mozilla::ErrorResult& aRv);
   void ReplaceState(JSContext* aCx, JS::Handle<JS::Value> aData,
                     const nsAString& aTitle, const nsAString& aUrl,
                     mozilla::ErrorResult& aRv);
-  void GetCurrent(nsString& aRetval, mozilla::ErrorResult& aRv) const;
-  void GetPrevious(nsString& aRetval, mozilla::ErrorResult& aRv) const;
-  void GetNext(nsString& aRetval, mozilla::ErrorResult& aRv) const;
-  void Item(uint32_t aIndex, nsString& aRetval, mozilla::ErrorResult& aRv);
-  void IndexedGetter(uint32_t aIndex, bool &aFound, nsString& aRetval,
-                     mozilla::ErrorResult& aRv);
-  uint32_t Length();
 
 protected:
   nsIDocShell *GetDocShell() const {
     nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mInnerWindow));
     if (!win)
       return nullptr;
     return win->GetDocShell();
   }
--- a/dom/webidl/History.webidl
+++ b/dom/webidl/History.webidl
@@ -21,19 +21,9 @@ interface History {
   [Throws]
   void back();
   [Throws]
   void forward();
   [Throws]
   void pushState(any data, DOMString title, optional DOMString? url = null);
   [Throws]
   void replaceState(any data, DOMString title, optional DOMString? url = null);
-
-  // Chrome only methods.
-  [Throws, ChromeOnly]
-  readonly attribute DOMString current;
-  [Throws, ChromeOnly]
-  readonly attribute DOMString previous;
-  [Throws, ChromeOnly]
-  readonly attribute DOMString next;
-  [Throws, ChromeOnly]
-  getter DOMString? item(unsigned long index);
 };