Bug 715700 - Test to check that localStorage across multiple windows remains in sync while in private browsing mode. r=mayhemer

This commit is contained in:
Josh Matthews 2012-01-20 04:04:25 -05:00
parent 53ae1d66e1
commit 4c5d85b248
4 changed files with 82 additions and 0 deletions

View File

@ -56,6 +56,9 @@ _BROWSER_TEST_FILES = \
browser_privatebrowsing_geoprompt.js \
browser_privatebrowsing_geoprompt_page.html \
browser_privatebrowsing_import.js \
browser_privatebrowsing_localStorage.js \
browser_privatebrowsing_localStorage_page1.html \
browser_privatebrowsing_localStorage_page2.html \
browser_privatebrowsing_newwindow_stopcmd.js \
browser_privatebrowsing_opendir.js \
browser_privatebrowsing_openlocation.js \

View File

@ -0,0 +1,59 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Private Browsing Tests.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Josh Matthews <josh@joshmatthews.net> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function test() {
let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
waitForExplicitFinish();
pb.privateBrowsingEnabled = true;
let tab = gBrowser.selectedTab = gBrowser.addTab();
let browser = gBrowser.selectedBrowser;
browser.addEventListener('load', function() {
browser.removeEventListener('load', arguments.callee, true);
let tab2 = gBrowser.selectedTab = gBrowser.addTab();
browser.contentWindow.location = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
'browser_privatebrowsing_localStorage_page2.html';
browser.addEventListener('load', function() {
browser.removeEventListener('load', arguments.callee, true);
is(browser.contentWindow.document.title, '2', "localStorage should contain 2 items");
pb.privateBrowsingEnabled = false;
finish();
}, true);
}, true);
browser.loadURI('http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
'browser_privatebrowsing_localStorage_page1.html');
}

View File

@ -0,0 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
localStorage.clear();
localStorage.setItem('test1', 'value1');
</script>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
localStorage.setItem('test2', 'value2');
document.title = localStorage.length;
</script>
</head>
<body>
</body>
</html>