Source code

Revision control

Copy as Markdown

Other Tools

/* Any copyright is dedicated to the Public Domain.
*/
#include "gtest/gtest.h"
#include "mozilla/ChromeScriptPath.h"
using mozilla::GetReportableChromeScriptPath;
TEST(ChromeScriptPath, Schemes)
{
EXPECT_STREQ(GetReportableChromeScriptPath(
"resource://gre/modules/AppConstants.sys.mjs"),
"gre/modules/AppConstants.sys.mjs");
EXPECT_STREQ(
GetReportableChromeScriptPath("chrome://browser/content/browser.js"),
"browser/content/browser.js");
EXPECT_STREQ(GetReportableChromeScriptPath(
"moz-src:///browser/components/Foo.sys.mjs"),
"browser/components/Foo.sys.mjs");
}
TEST(ChromeScriptPath, Redirects)
{
EXPECT_STREQ(GetReportableChromeScriptPath(
"gre/b.js");
EXPECT_STREQ(GetReportableChromeScriptPath(
"b.js");
}
TEST(ChromeScriptPath, Extensions)
{
EXPECT_STREQ(GetReportableChromeScriptPath(
"x@y.xpi!/a.js");
}
TEST(ChromeScriptPath, LeafName)
{
EXPECT_STREQ(GetReportableChromeScriptPath(
"boot.sys.mjs");
EXPECT_STREQ(GetReportableChromeScriptPath(
"C:\\Program Files\\Mozilla Firefox\\defaults\\pref\\x.js"),
"x.js");
EXPECT_STREQ(GetReportableChromeScriptPath("C:\\Users/Name\\mixed.js"),
"mixed.js");
EXPECT_STREQ(GetReportableChromeScriptPath("plain.js"), "plain.js");
EXPECT_STREQ(GetReportableChromeScriptPath(""), "");
}