You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



Test Plan for nsIWebNavigation interface


The nsIWebNavigation interface has methods to navigate across urls. In order to test the nsIWebNavigation interface, you should have at least one url loaded in your session history. See nsIWebNavigation.idl for more information.

To access the nsIWebnavigation object, use a Query Interface on a web browser object. See nsIWebNavigation.idl for more info:

   nsCOMPtr theWebBrowser;
   nsCOMPtr theWebNav; // nsIWebNavigation object

   theWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
   theWebNav = do_QueryInterface(theWebBrowser, &rv);

Now you can call the attributes & methods using the web navigation object.

To see the test cases click on the desired attributes & methods below.

    methods:
   
canGoBack attribute
    canGoForward attribute
    goBack()
    goForward()
    gotoIndex()
    loadURI()
    reload()
    stop()
    document attribute
    currentURI attribute
    sessionHistory attribute
 

canGoBack attribute:

Introduction:
This attribute is used to determine if we can navigate back to a previous url (i.e. use an enabled back button). It is a readonly attribute. The GetCanGoBack() method accepts the boolean canGoBack parameter:

How to use:

   // use web navigation object from above (theWebNav)
   PRBool canGoBack = PR_FALSE;
   rv = theWebNav->GetCanGoBack(&canGoBack);

   // check rv and canGoBack values using local methods

Note: canGoBack will return true if back navigation is enabled, false if it's not.

Case Steps Expected Results Pass/Fail Comments
1 Enter at least two urls in your browser. Call GetCanGoBack(). canGoBack should return true. pass Testing default impl of GetCanGoBack()
2 Relaunch browser, don't load any urls. Call GetCanGoBack(). canGoBack should return false. pass Testing default impl of GetCanGoBack()

Back To Top

canGoForward attribute:

Introduction:
This attribute is used to determine if we can navigate forward to another url (i.e. use an enabled forward button). It is a readonly attribute. The GetCanGoForward() method accepts the boolean canGoForward parameter:

How to use:

   // use web navigation object from above (theWebNav)
   PRBool canGoForward = PR_FALSE;
   rv = theWebNav->GetCanGoForward(&canGoForward);

   // check rv and canGoForward values using local methods

Note: canGoForward will return true if back navigation is enabled, false if it's not.

Case Steps Expected Results Pass/Fail Comments
1 Enter at least two urls in your browser, then navigate back to the first one. Call GetCanGoForward(). canGoForward should return true. pass Testing default impl of GetCanGoForward()
2 Relaunch browser, don't load any urls. Call GetCanGoForward(). canGoForward should return false. pass Testing default impl of GetCanGoForward()

Back To Top

goBack():

Introduction:
This method navigates back to a previous url in the session history. It doesn't accept any parameters:

How to use:

   // use web navigation object from above (theWebNav)
   rv = theWebNav->GoBack();

   // check rv using local methods

Case Steps Expected Results Pass/Fail Comments
1 Enter at least two urls in your browser. Call goBack(). Should navigate back to the previous url. pass Testing default impl of goBack()
2 Relaunch browser, don't load any urls. Call goBack(). Should not navigate back to any url. pass Testing default impl of goBack()

Back To Top

goForward():

Introduction:
This method navigates forward to the next url in the session history. It doesn't accept any parameters:

How to use:

   // use web navigation object from above (theWebNav)
   rv = theWebNav->GoForward();

   // check rv using local methods

Case Steps Expected Results Pass/Fail Comments
1 Enter at least two urls in your browser. Call goBack() then goForward(). Should navigate forward to the next url. pass Testing default impl of goForward()
2 Relaunch browser, don't load any urls. Call goForward(). Should not navigate forward to another url. pass Testing default impl of goForward()

Back To Top

gotoIndex():

Introduction:
This method navigates to a given index in the session history. It accepts an integer parameter indicating the index entry in the session history:

How to use:

   // use web navigation object from above (theWebNav)
   PRInt32 theIndex = 0;

   rv = theWebNav->GotoIndex(theIndex);

   // check rv and theIndex using local methods

Case Steps Expected Results Pass/Fail Comments
1 Enter at least three urls in your browser. Call gotoIndex() with index=0. Should navigate to the first url in session history. pass Testing default impl of gotoIndex()
2 Enter three urls in your browser. Call gotoIndex() with index=2. Should navigate to the last url in session history. pass Testing default impl of gotoIndex()

Back To Top

loadURI():

Introduction:
This method navigates to a given uri. It accepts two parameters: a uri string and a load flag. Legal flags for loadURI will be tested for basic functionality. It would be a good idea to create a url table with several url & flag entries.

How to use:

   // use web navigation object from above (theWebNav)

   rv = theWebNav->LoadURI(NS_ConvertASCIItoUCS2("http://www.netscape.com/").get(), 
						LOAD_FLAGS_NONE);
   // check rv and theIndex using local methods

Case Steps Expected Results Pass/Fail Comments
1 Call loadURI() with flag = LOAD_FLAGS_NONE. Should navigate to the url. Using the index, verify that the url is entered into the session history. pass Testing default impl of loadURI()
2 Call loadURI() with flag = LOAD_FLAGS_REFRESH. Should navigate to the url without any problems. Using the index, verify that the url is entered into the session history. pass Testing default impl of loadURI()
3 Call loadURI() with flag = LOAD_FLAGS_IS_LINK. Should navigate to the url without any problems. Using the index, verify that the url is entered into the session history. pass Testing default impl of loadURI()
4 Call loadURI() with flag = LOAD_FLAGS_REPLACE_HISTORY. Make sure to use a url that's different from the last test. Should navigate to the new url without any problems. Also verify that this url replaces the last url in the session history (use the index to obtain this url entry). pass Testing default impl of loadURI()

Back To Top

reload():

Introduction:
This method reloads the current uri. It accepts one parameter: a load flag. Legal flags for reload() will be tested for basic functionality.

How to use:

   // use web navigation object from above (theWebNav)

   rv = theWebNav->Reload(LOAD_FLAGS_NONE);

   // check rv and theIndex using local methods

Case Steps Expected Results Pass/Fail Comments
1 Call reload() with flag = LOAD_FLAGS_NONE. Should reload the url. pass Testing default impl of reload()
2 Call reload() with flag = LOAD_FLAGS_BYPASS_CACHE. Should reload the url. pass Testing default impl of reload()
3 Call reload() with flag = LOAD_FLAGS_BYPASS_PROXY. Should reload the url. pass Testing default impl of reload()
4 Call reload() with flag = LOAD_FLAGS_CHARSET_CHANGE. Should reload the url. pass Testing default impl of reload()

Back To Top

stop():

Introduction:
This method prevents a url from loading. It doesn't accept any parameters:

How to use:

   // use web navigation object from above (theWebNav)
   theWebNav->LoadURI(NS_ConvertASCIItoUCS2(theUrl).get(), 
						nsIWebNavigation::LOAD_FLAGS_NONE);
   rv = theWebNav->Stop();
   // check rv using local methods

Case Steps Expected Results Pass/Fail Comments
1 Try loading a url at the API level. Call stop(). Verify that the url does not load. Also verify that the url is not entered in the session history. pass Testing default impl of stop()

Back To Top

document attribute:

Introduction:
This readonly attributes accesses an object of type nsIDOMDocument. You should then be able to use methods of this interface:

How to use:

   // use web navigation object from above (theWebNav)
   nsCOMPtr theDocument;
   nsCOMPtr theDocType;
   
   rv = theWebNav->GetDocument(getter_AddRefs(theDocument));
   // check rv using local methods

   // now, access a method of nsIDOMDocument (to obtain the document type):
   rv = theDocument->GetDoctype(getter_AddRefs(theDocType));

Case Steps Expected Results Pass/Fail Comments
1 Access the nsIDOMDocument object using a getter on theDocument. Use GetDoctype() Verify that the object is obtained as is not null. pass Testing default impl of GetDoctype()
2 Use the newly created document object to access a method of nsIDOMDocument. Verify that method is called correctly (the doc type). pass Testing default impl of GetDoctype()

Back To Top

currentURI attribute:

Introduction:
This readonly attributes accesses an object of type nsIURI. You should then be able to use methods of this interface:

How to use:

   // use web navigation object from above (theWebNav)
   nsCOMPtr theUri;

   rv = theWebNav->GetCurrentURI(getter_AddRefs(theUri));
   // check rv using local methods

   // now, access a method of nsIURI (to obtain the uri):
   char *uriSpec;
   rv = theUri->GetSpec(&uriSpec);

Case Steps Expected Results Pass/Fail Comments
1 Access the nsIURI object using a getter on theURI. Use GetCurrentURI() Verify that the object is obtained as is not null. pass Testing default impl of GetCurrentURI()
2 Use the newly created uri object to access a method of nsIURI. Verify that method is called correctly (the uri). pass Testing default impl of GetCurrentURI()

Back To Top

sessionHistory attribute:

Introduction:
This readonly attributes accesses an object of type nsISHistory. You should then be able to use methods of this interface:

How to use:

   // use web navigation object from above (theWebNav)
   PRInt32 numOfElements;

   nsCOMPtr theSessionHistory;
   rv = theWebNav->GetSessionHistory(getter_AddRefs(theSessionHistory));
   // check rv using local methods

   // now, access a method of nsIURI (to obtain the uri count in session history):
   rv = theSessionHistory->GetCount(&numOfElements);

Case Steps Expected Results Pass/Fail Comments
1 Access the nsISHistory object using a getter on theSessionHistory. Use GetSessionHistory() Verify that the object is obtained as is not null. pass Testing default impl of GetSessionHistory()
2 Use the newly created session history object to access a method of nsISHistory. Verify that method is called correctly (session history count). pass Testing default impl of GetSessionHistory()

Back To Top

Revision History:

Date                        Changed By              Comments

07/17/01                                                   Test Plan written by David Epstein.