From b9f243f10ca5cdcfcfcecbecf3395300381ab0db Mon Sep 17 00:00:00 2001 From: "shaver%mozilla.org" Date: Wed, 13 Oct 2004 21:30:21 +0000 Subject: [PATCH] WebDAV, NPOTB. Don't propagatge NS_BINDING_ABORTED to put() callers. PUT() test wrapper and findErr helper. --- .../webdav/src/nsOperationStreamListeners.cpp | 2 +- extensions/webdav/tests/davshell.js | 33 +++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/extensions/webdav/src/nsOperationStreamListeners.cpp b/extensions/webdav/src/nsOperationStreamListeners.cpp index 8cebb65e8bab..f0bf6f8a27fc 100644 --- a/extensions/webdav/src/nsOperationStreamListeners.cpp +++ b/extensions/webdav/src/nsOperationStreamListeners.cpp @@ -110,7 +110,7 @@ OperationStreamListener::OnDataAvailable(nsIRequest *aRequest, PRUint32 offset, PRUint32 count) { aRequest->Cancel(NS_BINDING_ABORTED); - return NS_BINDING_ABORTED; + return NS_OK; } nsresult diff --git a/extensions/webdav/tests/davshell.js b/extensions/webdav/tests/davshell.js index 5f579f5eb6da..f01149bf387b 100644 --- a/extensions/webdav/tests/davshell.js +++ b/extensions/webdav/tests/davshell.js @@ -1,6 +1,18 @@ const C = Components; const CI = C.interfaces; +// I wonder how many copies of this are floating around +function findErr(result) +{ + for (var i in C.results) { + if (C.results[i] == result) { + dump(i + "\n"); + return; + } + } + dump("No result code found for " + result + "\n"); +} + function getService(contract, iface) { return C.classes[contract].getService(CI[iface]); @@ -32,8 +44,16 @@ Resource.prototype = { function ResourceWithFileData(url, filename) { - this.urlSpec = url; - this.mFilename = filename; + this.urlSpec = url; + var file = makeFile(filename); + var instream = createInstance("@mozilla.org/network/file-input-stream;1", + "nsIFileInputStream"); + instream.init(file, 0x01, 0, 0); + + var buffered = createInstance("@mozilla.org/network/buffered-input-stream;1", + "nsIBufferedInputStream"); + buffered.init(instream, 64 * 1024); + this.data = buffered; } ResourceWithFileData.prototype = { @@ -44,7 +64,7 @@ ResourceWithFileData.prototype = { return Resource.prototype.QueryInterface.call(this, outer, iid); }, - __proto__: Resource.prototype + __proto__: Resource.prototype, }; function propertiesToKeyArray(props) @@ -185,3 +205,10 @@ function GET(url, filename) new OperationListener()); runEventPump(); } + +function PUT(filename, url, contentType) +{ + var resource = new ResourceWithFileData(url, filename); + davSvc.put(resource, contentType, new OperationListener()); + runEventPump(); +}