do_test_privatebrowsing_commandline.js
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is Private Browsing Tests.
15  *
16  * The Initial Developer of the Original Code is
17  * William Jon McCann
18  * Portions created by the Initial Developer are Copyright (C) 2009
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * William Jon McCann <william.jon.mccann@gmail.com> (Original Author)
23  * Ehsan Akhgari <ehsan.akhgari@gmail.com>
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either of the GNU General Public License Version 2 or later (the "GPL"),
27  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38 
39 // This test checks the browser -private command line option.
40 
41 function testprivatecl() {
42 }
43 
44 testprivatecl.prototype = {
45  _arguments: ["private", "silent"],
46  get length getLength() {
47  return this._arguments.length;
48  },
49  getArgument: function getArgument(aIndex) {
50  return this._arguments[aIndex];
51  },
52  findFlag: function findFlag(aFlag, aCaseSensitive) {
53  for (let i = 0; i < this._arguments.length; ++i)
54  if (aCaseSensitive ?
55  (this._arguments[i] == aFlag) :
56  (this._arguments[i].toLowerCase() == aFlag.toLowerCase()))
57  return i;
58  return -1;
59  },
60  removeArguments: function removeArguments(aStart, aEnd) {
61  this._arguments.splice(aStart, aEnd - aStart + 1);
62  },
63  handleFlag: function handleFlag (aFlag, aCaseSensitive) {
64  let res = this.findFlag(aFlag, aCaseSensitive);
65  if (res > -1) {
66  this.removeArguments(res, res);
67  return true;
68  }
69  return false;
70  },
71  handleFlagWithParam: function handleFlagWithParam(aFlag, aCaseSensitive) {
72  return null;
73  },
74  STATE_INITIAL_LAUNCH: 0,
75  STATE_REMOTE_AUTO: 1,
76  STATE_REMOTE_EXPLICIT: 2,
77  get state getState() {
78  return this.STATE_INITIAL_LAUNCH;
79  },
80  preventDefault: false,
81  workingDirectory: null,
82  windowContext: null,
83  resolveFile: function resolveFile (aArgument) {
84  return null;
85  },
86  resolveURI: function resolveURI (aArgument) {
87  return null;
88  },
89  QueryInterface: function(aIID) {
90  if (!aIID.equals(Ci.nsICommandLine)
91  && !aIID.equals(Ci.nsISupports))
92  throw Cr.NS_ERROR_NO_INTERFACE;
93  return this;
94  }
95 }
96 
97 function do_test() {
98  // initialization
100  getService(Ci.nsIPrivateBrowsingService);
101 
102  let testcl = new testprivatecl();
103 
104  let catMan = Cc["@mozilla.org/categorymanager;1"].
105  getService(Ci.nsICategoryManager);
106  let categories = catMan.enumerateCategory("command-line-handler");
107  while (categories.hasMoreElements()) {
108  let category = categories.getNext().QueryInterface(Ci.nsISupportsCString).data;
109  let contractID = catMan.getCategoryEntry("command-line-handler", category);
110  let handler = Cc[contractID].getService(Ci.nsICommandLineHandler);
111  handler.handle(testcl);
112  }
113 
114  // the private mode should be entered automatically
115  do_check_true(pb.privateBrowsingEnabled);
116  // and should appear as auto-started!
117  do_check_true(pb.autoStarted);
118 }
const Cc
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
getService(Ci.sbIFaceplateManager)
function do_test()
return null
Definition: FeedWriter.js:1143
const Cr
const Ci
var PRIVATEBROWSING_CONTRACT_ID
_getSelectedPageStyle s i
GstMessage gpointer data sbGStreamerMessageHandler * handler
function testprivatecl()