Bug 503226, r=sicking, sr=jst
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 17 Aug 2009 13:48:01 +0300
changeset 31446 015c3c8cf0779c62c8f267de8dd608ac4daaba11
parent 31445 1bf16951d1bed2a934aa67a29f3b39fe50920c04
child 31447 9c6103ea22f47cc7c91f65351acd1ee581ab8eda
push id11
push useropettay@mozilla.com
push dateMon, 17 Aug 2009 12:56:36 +0000
reviewerssicking, jst
bugs503226
milestone1.9.2a2pre
Bug 503226, r=sicking, sr=jst
content/html/document/src/nsHTMLDocument.cpp
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2570,18 +2570,23 @@ nsHTMLDocument::GetSelection(nsAString& 
 
   nsCOMPtr<nsIConsoleService> consoleService
     (do_GetService("@mozilla.org/consoleservice;1"));
 
   if (consoleService) {
     consoleService->LogStringMessage(NS_LITERAL_STRING("Deprecated method document.getSelection() called.  Please use window.getSelection() instead.").get());
   }
 
-  nsIDOMWindow *window = GetWindow();
-  NS_ENSURE_TRUE(window, NS_OK);
+  nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(GetScopeObject());
+  nsCOMPtr<nsPIDOMWindow> pwin = do_QueryInterface(window);
+  NS_ENSURE_TRUE(pwin, NS_OK);
+  NS_ASSERTION(pwin->IsInnerWindow(), "Should have inner window here!");
+  NS_ENSURE_TRUE(pwin->GetOuterWindow() &&
+                 pwin->GetOuterWindow()->GetCurrentInnerWindow() == pwin,
+                 NS_OK);
 
   nsCOMPtr<nsISelection> selection;
   nsresult rv = window->GetSelection(getter_AddRefs(selection));
   NS_ENSURE_TRUE(selection && NS_SUCCEEDED(rv), rv);
 
   nsXPIDLString str;
 
   rv = selection->ToString(getter_Copies(str));