Back to index

lightning-sunbird  0.9+nobinonly
Selection.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Ashish Bhatt <ashishbhatt@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 // File Overview....
00040 //
00041 // Test cases for the nsISelection Interface
00042 
00043 #include "stdafx.h"
00044 #include "QaUtils.h"
00045 #include <stdio.h>
00046 #include "Selection.h"
00047 
00048 CSelection::CSelection(nsIWebBrowser* mWebBrowser)
00049 {
00050        qaWebBrowser = mWebBrowser;
00051 }
00052 
00053 
00054 CSelection::~CSelection()
00055 {
00056 }
00057 
00058 
00059 void CSelection::OnStartTests(UINT nMenuID)
00060 {
00061        // Calls  all or indivdual test cases on the basis of the 
00062        // option selected from menu.
00063 
00064        switch(nMenuID)
00065        {
00066               case ID_INTERFACES_NSISELECTION_RUNALLTESTS      :
00067                      RunAllTests();
00068                      break ;
00069               case ID_INTERFACES_NSISELECTION_GETANCHORNODE :
00070                      GetAnchorNode();
00071                      break ;
00072               case ID_INTERFACES_NSISELECTION_GETANCHOROFFSET :
00073                      GetAnchorOffset();
00074                      break ;
00075               case ID_INTERFACES_NSISELECTION_GETFOCUSNODE :
00076                       GetFocusNode() ;
00077                      break ;
00078               case ID_INTERFACES_NSISELECTION_GETFOCUSOFFSET :
00079                      GetFocusOffset() ;
00080                      break ;
00081               case ID_INTERFACES_NSISELECTION_GETISCOLLAPSED :
00082                      GetIsCollapsed() ;
00083                      break ;
00084               case ID_INTERFACES_NSISELECTION_GETRANGECOUNT :
00085                      GetRangecount() ;
00086                      break ;
00087               case ID_INTERFACES_NSISELECTION_GETRANGEAT :
00088                      GetRangeAt() ;
00089                      break ;
00090               case ID_INTERFACES_NSISELECTION_COLLAPSE :
00091                      Collapse() ;
00092                      break ;
00093               case ID_INTERFACES_NSISELECTION_EXTEND :
00094                      Extend() ;
00095                      break ;
00096               case ID_INTERFACES_NSISELECTION_COLLAPSETOSTART :
00097                      CollapseToStart() ;
00098                      break ;
00099               case ID_INTERFACES_NSISELECTION_COLLAPSETOEND :
00100                      CollapseToEnd() ;
00101                      break ;
00102               case ID_INTERFACES_NSISELECTION_CONTAINSNODE :
00103                      ContainsNode() ;
00104                      break ;
00105               case ID_INTERFACES_NSISELECTION_SELECTALLCHILDREN :
00106                      SelectAllChildren();
00107                      break ;
00108               case ID_INTERFACES_NSISELECTION_ADDRANGE :
00109                      Addrange();
00110                      break ;
00111               case ID_INTERFACES_NSISELECTION_REMOVERANGE :
00112                      RemoveRange();
00113                      break ;
00114               case ID_INTERFACES_NSISELECTION_REMOVEALLRANGES :
00115                      RemoveAllRanges();
00116                      break ;
00117               case ID_INTERFACES_NSISELECTION_DELETEFROMDOCUMENT :
00118                      DeleteFromDocument();
00119                      break ;
00120               case ID_INTERFACES_NSISELECTION_SELECTIONLANGUAGECHANGE :
00121                      SelectionLanguageChange();
00122                      break ;
00123               case ID_INTERFACES_NSISELECTION_TOSTRING :
00124                      ToString();
00125                      break ;
00126        }
00127 
00128 }
00129 
00130 void CSelection::RunAllTests()
00131 {
00132 
00133        PRInt32 ancoroffset = 0;
00134        PRInt32 focusoffset = 0;
00135        PRInt32 rangecount = 0;
00136        PRInt32 index = 0;
00137        PRBool  bisCollapsed = false;
00138        PRBool  bContains = false;
00139        nsXPIDLString szText;
00140        
00141        nsCOMPtr<nsISelection> oNsSelection ;
00142        nsCOMPtr<nsIDOMNode> oNsDOMAnchorNode ;
00143        nsCOMPtr<nsIDOMNode> oNsDOMFocusNode ;
00144        nsCOMPtr<nsIDOMRange> oNsDOMRange ;
00145 
00146        oNsSelection = GetSelectionObject(true);
00147        if (!oNsSelection)
00148               return ;
00149 
00150 //---------------- Test case for AnchorNode Attribute
00151 
00152        rv = oNsSelection->GetAnchorNode(getter_AddRefs(oNsDOMAnchorNode));
00153     RvTestResultDlg(rv, "nsISelection::GetAnchorNode() ");
00154        if (!oNsDOMAnchorNode)
00155               RvTestResultDlg(rv, "------>No Selection made to get the AnchorNode object");
00156 
00157 //---------------- Test case for AnchorOffset Attribute
00158 
00159        rv = oNsSelection->GetAnchorOffset(&ancoroffset);
00160        RvTestResultDlg(rv, "nsISelection::GetAnchorOffset()");
00161 
00162 
00163 //---------------- Test case for FocusNode Attribute
00164 
00165        rv = oNsSelection->GetFocusNode(getter_AddRefs(oNsDOMFocusNode));
00166     RvTestResultDlg(rv, "nsISelection::GetFocusNode() ");
00167        if (!oNsDOMFocusNode)
00168               RvTestResultDlg(rv, "------>No Selection made to get the FocusNode object");
00169 
00170 //---------------- Test case for FocusOffset Attribute
00171 
00172        rv = oNsSelection->GetFocusOffset(&focusoffset);
00173        RvTestResultDlg(rv, "nsISelection::GetFocusOffset()");  
00174 
00175 //---------------- Test case for isCollapsed Attribute
00176 
00177        rv = oNsSelection->GetIsCollapsed(&bisCollapsed);
00178        RvTestResultDlg(rv, "nsISelection::GetIsCollapsed()");  
00179        if(bisCollapsed)
00180               RvTestResultDlg(rv, "------> Returned value for IsCollapsed is true");       
00181        else
00182               RvTestResultDlg(rv, "------> Returned value for IsCollapsed is false");      
00183 
00184        
00185 //---------------- Test case for isCollapsed Attribute
00186 
00187        rv = oNsSelection->GetRangeCount(&rangecount);
00188        RvTestResultDlg(rv, "nsISelection::GetRangeCount()");   
00189 
00190 
00191 //---------------- Test case for GetRangeAt function
00192 
00193               rv = oNsSelection->GetRangeAt(index,getter_AddRefs(oNsDOMRange));
00194               RvTestResultDlg(rv, "nsISelection::GetRangeAt() ");
00195               if (!oNsDOMRange)
00196                      RvTestResultDlg(rv, "------>Not able to get nsIDOMRange object");
00197 
00198 
00199 //---------------- Test case for Collapse function
00200 
00201        rv = oNsSelection->Collapse(oNsDOMFocusNode,1) ;
00202            RvTestResultDlg(rv, "nsISelection::Collapse() ");
00203 
00204 //---------------- Test case for Extend function
00205 
00206        rv = oNsSelection->Extend(oNsDOMFocusNode,10) ;
00207            RvTestResultDlg(rv, "nsISelection::Extend() ");
00208        
00209 //---------------- Test case for CollapseToStart function
00210 
00211        rv = oNsSelection->CollapseToStart();
00212            RvTestResultDlg(rv, "nsISelection::CollapseToStart() ");
00213 
00214 //---------------- Test case for CollapseToEnd function
00215 
00216        rv = oNsSelection->CollapseToEnd();
00217            RvTestResultDlg(rv, "nsISelection::CollapseToEnd() ");
00218 
00219 //---------------- Test case for ContainsNode function
00220 
00221        rv = oNsSelection->ContainsNode(oNsDOMFocusNode,PR_TRUE, &bContains);
00222            RvTestResultDlg(rv, "nsISelection::ContainsNode() ");
00223        if(bContains)
00224               RvTestResultDlg(rv, "------> Returned value for ContainsNode is true");      
00225        else
00226               RvTestResultDlg(rv, "------> Returned value for ContainsNode is false");
00227 
00228 
00229 //---------------- Test case for SelectAllChildren function
00230 
00231        rv = oNsSelection->SelectAllChildren(oNsDOMFocusNode);
00232            RvTestResultDlg(rv, "nsISelection::SelectAllChildren() ");
00233 
00234 //---------------- Test case for Addrange function
00235 
00236        rv = oNsSelection->AddRange(oNsDOMRange);
00237            RvTestResultDlg(rv, "nsISelection::Addrange() ");
00238 
00239 //---------------- Test case for RemoveRange function
00240 
00241        rv = oNsSelection->RemoveRange(oNsDOMRange);
00242            RvTestResultDlg(rv, "nsISelection::RemoveRange() ");
00243 
00244 //---------------- Test case for RemoveAllRanges function
00245 
00246        rv = oNsSelection->RemoveAllRanges();
00247            RvTestResultDlg(rv, "nsISelection::RemoveAllRanges() ");
00248 
00249 //---------------- Test case for DeleteFromDocument function
00250 
00251        rv = oNsSelection->DeleteFromDocument();
00252            RvTestResultDlg(rv, "nsISelection::DeleteFromDocument() ");
00253 
00254 //---------------- Test case for SelectionLanguageChange function
00255 
00256        rv = oNsSelection->SelectionLanguageChange(PR_FALSE);
00257            RvTestResultDlg(rv, "nsISelection::SelectionLanguageChange() ");
00258 
00259 //---------------- Test case for ToString function
00260 
00261        rv = oNsSelection->ToString(getter_Copies(szText));
00262            RvTestResultDlg(rv, "nsISelection::ToString() ");
00263 }
00264 
00265 
00266 void CSelection::GetAnchorNode() 
00267 {
00268 
00269        nsCOMPtr<nsIDOMNode> oNsDOMAnchorNode ;
00270        nsCOMPtr<nsISelection> oSelection ;
00271 
00272        oSelection = GetSelectionObject();
00273        if (!oSelection)
00274               return ;
00275 
00276        rv = oSelection->GetAnchorNode(getter_AddRefs(oNsDOMAnchorNode));
00277     RvTestResult(rv, "nsISelection::GetAnchorNode() ",0);
00278        if (!oNsDOMAnchorNode)
00279               RvTestResult(rv, "------>No Selection made to get the AnchorNode object",0);
00280 }
00281 
00282 
00283 void CSelection::GetAnchorOffset()
00284 {
00285 
00286        PRInt32 ancoroffset = 0;
00287        //char szstr[10] ;
00288 
00289        nsCOMPtr<nsISelection> oSelection ;
00290 
00291        oSelection = GetSelectionObject();
00292        if (!oSelection)
00293               return ;
00294 
00295        rv = oSelection->GetAnchorOffset(&ancoroffset);
00296        RvTestResult(rv, "nsISelection::GetAnchorOffset()",0);
00297        //ltoa(ancoroffset,  szstr,10);
00298        //AfxMessageBox(szstr);
00299 }
00300 
00301 void CSelection::GetFocusNode() 
00302 {
00303        nsCOMPtr<nsIDOMNode> oNsDOMFocusNode ;
00304        nsCOMPtr<nsISelection> oSelection ;
00305 
00306        oSelection = GetSelectionObject();
00307        if (!oSelection)
00308               return ;
00309 
00310        rv = oSelection->GetFocusNode(getter_AddRefs(oNsDOMFocusNode));
00311     RvTestResult(rv, "nsISelection::GetFocusNode() ",0);
00312        if (!oNsDOMFocusNode)
00313               RvTestResult(rv, "------>No Selection made to get the FocusNode object",0);
00314 }
00315 
00316 void CSelection::GetFocusOffset() 
00317 {
00318        PRInt32 focusoffset = 0;
00319        nsCOMPtr<nsISelection> oSelection ;
00320 
00321        oSelection = GetSelectionObject();
00322        if (!oSelection)
00323               return ;
00324 
00325        rv = oSelection->GetFocusOffset(&focusoffset);
00326        RvTestResult(rv, "nsISelection::GetFocusOffset()",0);   
00327 
00328 }
00329 
00330 void CSelection::GetIsCollapsed() 
00331 {
00332        PRBool  bisCollapsed = false;
00333 
00334        nsCOMPtr<nsISelection> oSelection ;
00335        oSelection = GetSelectionObject();
00336        if (!oSelection)
00337               return ;
00338 
00339        rv = oSelection->GetIsCollapsed(&bisCollapsed);
00340        RvTestResult(rv, "nsISelection::GetIsCollapsed()",0);   
00341        if(bisCollapsed)
00342               RvTestResult(rv, "------> Returned value for IsCollapsed is true",0); 
00343        else
00344               RvTestResult(rv, "------> Returned value for IsCollapsed is false",0);       
00345 }
00346 
00347 void CSelection::GetRangecount() 
00348 {
00349        PRInt32 rangecount = 0;
00350        nsCOMPtr<nsISelection> oSelection ;
00351 
00352        oSelection = GetSelectionObject();
00353        if (!oSelection)
00354               return ;
00355        rv = oSelection->GetRangeCount(&rangecount);
00356        RvTestResult(rv, "nsISelection::GetRangeCount()",0);    
00357        char szstr[10] ;
00358        ltoa(rangecount,     szstr,10);
00359        AfxMessageBox(szstr);
00360 }
00361 
00362 
00363 void CSelection::GetRangeAt() 
00364 {
00365        PRInt32 index = 0;
00366        nsCOMPtr<nsIDOMRange> oNsDOMRange ;
00367 
00368        nsCOMPtr<nsISelection> oSelection ;
00369        oSelection = GetSelectionObject();
00370        if (!oSelection)
00371               return ;
00372        rv = oSelection->GetRangeAt(index,getter_AddRefs(oNsDOMRange));
00373        RvTestResult(rv, "nsISelection::GetRangeAt() ",0);
00374        if (!oNsDOMRange)
00375               RvTestResult(rv, "------>Not able to get nsIDOMRange object",0);
00376 
00377 
00378 }
00379 
00380 void CSelection::Collapse() 
00381 {
00382 
00383        nsCOMPtr<nsIDOMNode> oNsDOMFocusNode ;
00384        nsCOMPtr<nsISelection> oSelection ;
00385 
00386        oSelection = GetSelectionObject();
00387        if (!oSelection)
00388               return ;
00389 
00390        rv = oSelection->GetFocusNode(getter_AddRefs(oNsDOMFocusNode));
00391     RvTestResult(rv, "nsISelection::GetFocusNode() ",0);
00392        if (!oNsDOMFocusNode)
00393               RvTestResult(rv, "------>No Selection made to get the FocusNode object",0);
00394 
00395        rv = oSelection->Collapse(oNsDOMFocusNode,1) ;
00396     RvTestResult(rv, "nsISelection::Collapse() ",0);
00397 
00398 }
00399 
00400 void CSelection::Extend() 
00401 {
00402        nsCOMPtr<nsIDOMNode> oNsDOMFocusNode ;
00403        nsCOMPtr<nsISelection> oSelection ;
00404 
00405        oSelection = GetSelectionObject();
00406        if (!oSelection)
00407               return ;
00408 
00409        rv = oSelection->GetFocusNode(getter_AddRefs(oNsDOMFocusNode));
00410     RvTestResult(rv, "nsISelection::GetFocusNode() ",0);
00411        if (!oNsDOMFocusNode)
00412               RvTestResult(rv, "------>No Selection made to get the FocusNode object",0);
00413 
00414 
00415        rv = oSelection->Extend(oNsDOMFocusNode,10) ;
00416     RvTestResult(rv, "nsISelection::Extend() ",0);
00417 
00418 
00419 }
00420 
00421 void CSelection::CollapseToStart()
00422 {
00423        nsCOMPtr<nsISelection> oSelection ;
00424        oSelection = GetSelectionObject();
00425        if (!oSelection)
00426               return ;
00427        rv = oSelection->CollapseToStart();
00428            RvTestResult(rv, "nsISelection::CollapseToStart() ",0);
00429 
00430 }
00431 
00432 void CSelection::CollapseToEnd()
00433 {
00434        nsCOMPtr<nsISelection> oSelection ;
00435        oSelection = GetSelectionObject();
00436        rv = oSelection->CollapseToEnd();
00437            RvTestResult(rv, "nsISelection::CollapseToEnd() ",0);
00438 }
00439 
00440 void CSelection::ContainsNode()
00441 {
00442        PRBool  bContains = false;
00443 
00444        nsCOMPtr<nsIDOMNode> oNsDOMFocusNode ;
00445        nsCOMPtr<nsISelection> oSelection ;
00446 
00447        oSelection = GetSelectionObject();
00448        if (!oSelection)
00449               return ;
00450 
00451        rv = oSelection->GetFocusNode(getter_AddRefs(oNsDOMFocusNode));
00452     RvTestResult(rv, "nsISelection::GetFocusNode() ",0);
00453        if (!oNsDOMFocusNode)
00454               RvTestResult(rv, "------>No Selection made to get the FocusNode object",0);
00455 
00456 
00457        rv = oSelection->ContainsNode(oNsDOMFocusNode,PR_TRUE, &bContains);
00458            RvTestResult(rv, "nsISelection::ContainsNode() ",0);
00459        if(bContains)
00460               RvTestResult(rv, "------> Returned value for ContainsNode is true",0);       
00461        else
00462               RvTestResult(rv, "------> Returned value for ContainsNode is false",0);
00463 }
00464 
00465 void CSelection::SelectAllChildren()
00466 {
00467        nsCOMPtr<nsIDOMNode> oNsDOMFocusNode ;
00468        nsCOMPtr<nsISelection> oSelection ;
00469 
00470        oSelection = GetSelectionObject();
00471        if (!oSelection)
00472               return ;
00473 
00474        rv = oSelection->GetFocusNode(getter_AddRefs(oNsDOMFocusNode));
00475     RvTestResult(rv, "nsISelection::GetFocusNode() ",0);
00476        if (!oNsDOMFocusNode)
00477               RvTestResult(rv, "------>No Selection made to get the FocusNode object",0);
00478 
00479 
00480        rv = oSelection->SelectAllChildren(oNsDOMFocusNode);
00481            RvTestResult(rv, "nsISelection::SelectAllChildren() ",0);
00482 
00483 }
00484 
00485 void CSelection::Addrange()
00486 {      
00487        PRInt32 index= 0;
00488        
00489        nsCOMPtr<nsIDOMRange> oNsDOMRange ;
00490        nsCOMPtr<nsISelection> oSelection ;
00491 
00492        oSelection = GetSelectionObject();
00493        if (!oSelection)
00494               return ;
00495 
00496        rv = oSelection->GetRangeAt(index,getter_AddRefs(oNsDOMRange));
00497        RvTestResult(rv, "nsISelection::GetRangeAt() ",0);
00498        if (!oNsDOMRange)
00499               RvTestResult(rv, "------>Not able to get nsIDOMRange object",0);
00500 
00501        rv = oSelection->AddRange(oNsDOMRange);
00502            RvTestResult(rv, "nsISelection::Addrange() ",0);
00503 
00504 }
00505 
00506 void CSelection::RemoveRange()
00507 { 
00508        PRInt32 index= 0;
00509 
00510        nsCOMPtr<nsIDOMRange> oNsDOMRange ;
00511        nsCOMPtr<nsISelection> oSelection ;
00512 
00513        oSelection = GetSelectionObject();
00514        if (!oSelection)
00515               return ;
00516 
00517        rv = oSelection->GetRangeAt(index,getter_AddRefs(oNsDOMRange));
00518        RvTestResult(rv, "nsISelection::GetRangeAt() ",0);
00519        if (!oNsDOMRange)
00520               RvTestResult(rv, "------>Not able to get nsIDOMRange object",0);
00521 
00522        rv = oSelection->RemoveRange(oNsDOMRange);
00523            RvTestResult(rv, "nsISelection::RemoveRange() ",0);
00524 }
00525 
00526 void CSelection::RemoveAllRanges()
00527 { 
00528        nsCOMPtr<nsISelection> oSelection ;
00529        oSelection = GetSelectionObject();
00530        if (!oSelection)
00531               return ;
00532        rv = oSelection->RemoveAllRanges();
00533            RvTestResult(rv, "nsISelection::RemoveAllRanges() ",0);
00534 
00535 }
00536 
00537 void CSelection::DeleteFromDocument()
00538 { 
00539        nsCOMPtr<nsISelection> oSelection ;
00540        oSelection = GetSelectionObject();
00541        if (!oSelection)
00542               return ;
00543        rv = oSelection->DeleteFromDocument();
00544            RvTestResult(rv, "nsISelection::DeleteFromDocument() ",0);
00545 
00546 }
00547 
00548 void CSelection::SelectionLanguageChange()
00549 { 
00550        nsCOMPtr<nsISelection> oSelection ;
00551        oSelection = GetSelectionObject();
00552        if (!oSelection)
00553               return ;
00554 
00555        rv = oSelection->SelectionLanguageChange(PR_TRUE);
00556            RvTestResult(rv, "nsISelection::SelectionLanguageChange() ",0);
00557 
00558 }
00559 
00560 void CSelection::ToString()
00561 { 
00562        nsXPIDLString szText;
00563        nsCOMPtr<nsISelection> oSelection ;
00564 
00565        oSelection = GetSelectionObject();
00566        if (!oSelection)
00567               return ;
00568        rv = oSelection->ToString(getter_Copies(szText));
00569     RvTestResult(rv, "nsISelection::ToString() ",0);
00570 }
00571 
00572 
00573 nsISelection * CSelection::GetSelectionObject(BOOL bShowDialog)
00574 {
00575        nsCOMPtr<nsISelection> oNsSelection ;
00576 
00577        nsCOMPtr<nsIDOMWindow> oDomWindow;
00578 
00579        // Get the nsIDOMWindow interface in order to get nsISelection 
00580        rv = qaWebBrowser->GetContentDOMWindow(getter_AddRefs(oDomWindow));
00581 
00582        if(bShowDialog)
00583           RvTestResultDlg(rv, "nsIWebBrowser::GetContentDOMWindow()' rv test",true);
00584        else
00585        RvTestResult(rv, "nsIWebBrowser::GetContentDOMWindow()' rv test", 0);
00586        if (!oDomWindow)
00587        {
00588               if(bShowDialog)
00589                   RvTestResultDlg(rv, "------>Cannot get the  nsIDOMNode Object");
00590               else
00591               RvTestResult(rv, "------>Cannot get the  nsIDOMNode Object", 0);
00592               return NULL ;
00593        }
00594 
00595        if(bShowDialog)
00596               RvTestResultDlg(rv, "------>nsIDOMWindow is required in order to get the nsISelection interface");
00597        else
00598        RvTestResult(rv, "nsIDOMWindow is required in order to get the nsISelection interface", 0);
00599        
00600        // Now get the nsISelection interface
00601        rv = oDomWindow->GetSelection(getter_AddRefs(oNsSelection));
00602 
00603        if(bShowDialog)
00604            RvTestResultDlg(rv, "nsIDOMWindow::GetSelection()");
00605        else
00606        RvTestResult(rv, "nsIDOMWindow::GetSelection()", 0);
00607 
00608        if (!oNsSelection)
00609        {
00610               if(bShowDialog)
00611                   RvTestResultDlg(rv, "------>Cannot get the  Selection Object");
00612               else
00613               RvTestResult(rv, "Cannot get the  Selection Object", 0);
00614 
00615               return NULL ;
00616        }
00617        
00618        return oNsSelection ;
00619 }