summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/news/test/unit/test_nntpUrl.js
blob: 93c51334bd1c92b40f3b5a14738fe414afe412f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 *
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 *
 * ***** END LICENSE BLOCK ***** */

var { MailServices } = ChromeUtils.import(
  "resource:///modules/MailServices.jsm"
);

function getMessageHeaderFromUrl(aUrl) {
  let msgUrl = Services.io.newURI(aUrl).QueryInterface(Ci.nsIMsgMessageUrl);
  return msgUrl.messageHeader;
}

function run_test() {
  // This is crash test for Bug 392729
  try {
    // msgkey is invalid for news:// protocol
    getMessageHeaderFromUrl(
      "news://localhost:119" +
        "/123@example.invalid?group=test.subscribe.simple&key=abcdefghijk"
    );
    Assert.ok(false);
  } catch (e) {
    Assert.equal(e.result, Cr.NS_ERROR_MALFORMED_URI);
  }
}