~ubuntu-branches/ubuntu/trusty/enigmail/trusty-updates

« back to all changes in this revision

Viewing changes to extensions/enigmail/ipc/tests/buftest.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2011-06-07 14:35:53 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: package-import@ubuntu.com-20110607143553-fbgqhhvh8g8h6j1y
Tags: 2:1.2~a2~cvs20110606t2200-0ubuntu1
* Update to latest trunk snapshot for Thunderbird beta compat

* Remove build/pgo/profileserver.py from debian/clean. The new build
  system has a target depending on this
  - update debian/clean
* Drop debian/patches/autoconf.diff, just generate this at build time
* Refresh debian/patches/build_system_dont_link_libxul.diff
* libipc seems to be renamed to libipc-pipe. Fix genxpi and chrome.manifest
  to fix this 
  - add debian/patches/ipc-pipe_rename.diff
  - update debian/patches/series
* The makefiles in extensions/enigmail/ipc have an incorrect DEPTH
  attribute. Fix this so that they can find the rest of the build system
  - add debian/patches/makefile_depth.diff
  - update debian/patches/series
* Drop debian/patches/makefile-in-empty-xpcom-fix.diff - fixed in the
  current version
* Don't register a class ID multiple times, as this breaks enigmail entirely
  - add debian/patches/dont_register_cids_multiple_times.diff
  - update debian/patches/series
* Look for the Thunderbird 5 SDK
  - update debian/rules
  - update debian/control
* Run autoconf2.13 at build time
  - update debian/rules
  - update debian/control
* Add useless mesa-common-dev build-dep, just to satisfy the build system.
  We should just patch this out entirely really, but that's for another upload
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * buftest.js
3
 
 * Test and demo application for:
4
 
 * nsIPipeConsole, nsIIPCBuffer, nsIPipeFilterListener
5
 
 *
6
 
 * The contents of this file are subject to the Mozilla Public
7
 
 * License Version 1.1 (the "MPL"); you may not use this file
8
 
 * except in compliance with the MPL. You may obtain a copy of
9
 
 * the MPL at http://www.mozilla.org/MPL/
10
 
 *
11
 
 * Software distributed under the MPL is distributed on an "AS
12
 
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13
 
 * implied. See the MPL for the specific language governing
14
 
 * rights and limitations under the MPL.
15
 
 *
16
 
 * The Original Code is protoZilla.
17
 
 *
18
 
 * The Initial Developer of the Original Code is Ramalingam Saravanan.
19
 
 * Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
20
 
 * Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 * Patrick Brunschwig <patrick@mozilla-enigmail.org>
24
 
 *
25
 
 * Alternatively, the contents of this file may be used under the
26
 
 * terms of the GNU General Public License (the "GPL"), in which case
27
 
 * the provisions of the GPL are applicable instead of
28
 
 * those above. If you wish to allow use of your version of this
29
 
 * file only under the terms of the GPL and not to allow
30
 
 * others to use your version of this file under the MPL, indicate
31
 
 * your decision by deleting the provisions above and replace them
32
 
 * with the notice and other provisions required by the GPL.
33
 
 * If you do not delete the provisions above, a recipient
34
 
 * may use your version of this file under either the MPL or the
35
 
 * GPL.
36
 
*/
37
 
 
38
 
load("ipc.js");
39
 
 
40
 
const NS_PIPECONSOLE_CONTRACTID = "@mozilla.org/process/pipe-console;1";
41
 
const NS_IPCBUFFER_CONTRACTID   = "@mozilla.org/process/ipc-buffer;1";
42
 
const NS_PIPEFILTERLISTENER_CONTRACTID = "@mozilla.org/process/pipe-filter-listener;1";
43
 
 
44
 
function escape_cr(str) {
45
 
   return str.replace(/\r/g, "\\r");
46
 
}
47
 
 
48
 
const InputStream = new Components.Constructor( "@mozilla.org/scriptableinputstream;1", "nsIScriptableInputStream" );
49
 
 
50
 
dump("Testing IPC service etc.\n");
51
 
 
52
 
// Test getEnv
53
 
dump("\nTesting getEnv('PATH')\n");
54
 
dump("  PATH="+getEnv('PATH')+"\n");
55
 
 
56
 
// Test pipeConsole
57
 
dump("\nTesting PipeConsole\n");
58
 
 
59
 
var pipeConsole = Components.classes[NS_PIPECONSOLE_CONTRACTID].createInstance(Components.interfaces.nsIPipeConsole);
60
 
pipeConsole.open(24, 80, false);
61
 
pipeConsole.write("PipeConsole initialized\n");
62
 
 
63
 
if (pipeConsole.hasNewData) {
64
 
   dump("data='"+pipeConsole.getData()+"'\n");
65
 
} else {
66
 
   dump("  Error in pipeConsole\n");
67
 
}
68
 
pipeConsole.shutdown();
69
 
 
70
 
// Test IPC buffer
71
 
dump("\nTesting IPCBuffer\n");
72
 
 
73
 
var ipcBuffer = Components.classes[NS_IPCBUFFER_CONTRACTID].createInstance(Components.interfaces.nsIIPCBuffer);
74
 
 
75
 
ipcBuffer.open(10, true);
76
 
ipcBuffer.write("IPCBuffer initialized\n");
77
 
ipcBuffer.onStopRequest(null, null, 0);
78
 
 
79
 
var totalBytes = ipcBuffer.totalBytes;
80
 
dump("totalBytes="+totalBytes+"\n");
81
 
 
82
 
dump("data='"+ipcBuffer.getData()+"'\n");
83
 
 
84
 
var rawInStream = ipcBuffer.openInputStream();
85
 
var scriptableInStream = new InputStream();
86
 
scriptableInStream.init(rawInStream);
87
 
 
88
 
var available = scriptableInStream.available();
89
 
dump("available="+available+"\n");
90
 
 
91
 
var bufData = scriptableInStream.read(available-3);
92
 
rawInStream.close();
93
 
 
94
 
dump("bufData='"+bufData+"'\n");
95
 
 
96
 
ipcBuffer.shutdown();
97
 
 
98
 
// Test PipeFilterListener
99
 
dump("\nTesting PipeFilterListener\n");
100
 
 
101
 
var listener = Components.classes[NS_IPCBUFFER_CONTRACTID].createInstance(Components.interfaces.nsIIPCBuffer);
102
 
 
103
 
listener.open(2000, false);
104
 
 
105
 
var listener2 = Components.classes[NS_IPCBUFFER_CONTRACTID].createInstance(Components.interfaces.nsIIPCBuffer);
106
 
 
107
 
listener2.open(2000, false);
108
 
 
109
 
var pipeFilter = Components.classes[NS_PIPEFILTERLISTENER_CONTRACTID].createInstance(Components.interfaces.nsIPipeFilterListener);
110
 
 
111
 
pipeFilter.init(listener, null, "", "", 0, true, true, listener2);
112
 
 
113
 
var lines = ["--Boundary",
114
 
             "\r\nPart 1\r\n",
115
 
             " --Boundary\r\n\r\n",
116
 
             "--Boundary\r",
117
 
             "\nPart 2\r\nPL2\r\nx\r\n--Boundary--\r\n"];
118
 
 
119
 
for (var j=0; j<lines.length; j++) {
120
 
  pipeFilter.write(lines[j], lines[j].length, null, null);
121
 
}
122
 
pipeFilter.onStopRequest(null, null, 0);
123
 
 
124
 
dump("listener.getData()='"+escape_cr(listener.getData())+"'\n");
125
 
dump("listener2.getData()='"+escape_cr(listener2.getData())+"'\n");
126
 
 
127
 
var linebreak = ["CRLF", "LF", "CR"];
128
 
 
129
 
for (var j=0; j<linebreak.length; j++) {
130
 
  listener = Components.classes[NS_IPCBUFFER_CONTRACTID].createInstance(Components.interfaces.nsIIPCBuffer);
131
 
 
132
 
  listener.open(2000, false);
133
 
 
134
 
  pipeFilter = Components.classes[NS_PIPEFILTERLISTENER_CONTRACTID].createInstance(Components.interfaces.nsIPipeFilterListener);
135
 
 
136
 
  pipeFilter.init(listener, null, "", "", 1, (j != 0), true, null);
137
 
 
138
 
  for (var k=0; k<lines.length; k++) {
139
 
    var line = lines[k];
140
 
    if (j == 1) line = line.replace(/\r/g, "");
141
 
    if (j == 2) line = line.replace(/\n/g, "");
142
 
    pipeFilter.write(line, line.length, null, null);
143
 
  }
144
 
 
145
 
  pipeFilter.onStopRequest(null, null, 0);
146
 
 
147
 
  dump(linebreak[j]+" listener.getData()='"+escape_cr(listener.getData())+"'\n");
148
 
}