author | Monica Chew <mmc@mozilla.com> |
Thu, 07 Mar 2013 08:35:38 -0500 | |
changeset 124107 | 99ef1303095d41f4bb647fcb0e318cef22d42d3b |
parent 124106 | fc9cdf372502878c8da412c6d50c2a0f0f80c13b |
child 124108 | 814a0c94b2157293a978dd976273c28e9fb304b6 |
push id | 24406 |
push user | ryanvm@gmail.com |
push date | Thu, 07 Mar 2013 17:19:02 +0000 |
treeherder | mozilla-central@71395a927025 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | paolo |
bugs | 844392 |
milestone | 22.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/netwerk/test/unit/test_backgroundfilesaver.js +++ b/netwerk/test/unit/test_backgroundfilesaver.js @@ -466,32 +466,39 @@ add_task(function test_finish_only() let completionPromise = promiseSaverComplete(saver, onTargetChange); saver.finish(Cr.NS_OK); yield completionPromise; }); add_task(function test_invalid_hash() { let saver = new BackgroundFileSaverStreamListener(); + let completionPromise = promiseSaverComplete(saver); // We shouldn't be able to get the hash if hashing hasn't been enabled try { let hash = saver.sha256Hash; - throw "Shouldn't be able to get hash if hashing not enabled"; + do_throw("Shouldn't be able to get hash if hashing not enabled"); } catch (ex if ex.result == Cr.NS_ERROR_NOT_AVAILABLE) { } // Enable hashing, but don't feed any data to saver saver.enableSha256(); let destFile = getTempFile(TEST_FILE_NAME_1); saver.setTarget(destFile, false); // We don't wait on promiseSaverComplete, so the hash getter can run before // or after onSaveComplete is called. However, the expected behavior is the // same in both cases since the hash is only valid when the save completes // successfully. saver.finish(Cr.NS_ERROR_FAILURE); try { let hash = saver.sha256Hash; - throw "Shouldn't be able to get hash if save did not succeed"; + do_throw("Shouldn't be able to get hash if save did not succeed"); } catch (ex if ex.result == Cr.NS_ERROR_NOT_AVAILABLE) { } + // Wait for completion so that the worker thread finishes dealing with the + // target file. We expect it to fail. + try { + yield completionPromise; + do_throw("completionPromise should throw"); + } catch (ex if ex.result == Cr.NS_ERROR_FAILURE) { } }); add_task(function test_teardown() { gStillRunning = false; });