|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 'use strict' |
|
5 |
|
6 const { Cu, Cc, Ci } = require('chrome'); |
|
7 const Request = require('sdk/request').Request; |
|
8 const { WindowTracker } = require('sdk/deprecated/window-utils'); |
|
9 const { close, open } = require('sdk/window/helpers'); |
|
10 |
|
11 const XUL_URL = 'chrome://test/content/new-window.xul' |
|
12 |
|
13 const { Services } = Cu.import('resource://gre/modules/Services.jsm', {}); |
|
14 const { NetUtil } = Cu.import('resource://gre/modules/NetUtil.jsm', {}); |
|
15 |
|
16 exports.testChromeSkin = function(assert, done) { |
|
17 let skinURL = 'chrome://test/skin/style.css'; |
|
18 |
|
19 Request({ |
|
20 url: skinURL, |
|
21 overrideMimeType: 'text/plain', |
|
22 onComplete: function (response) { |
|
23 assert.equal(response.text.trim(), 'test{}', 'chrome.manifest skin folder was registered!'); |
|
24 done(); |
|
25 } |
|
26 }).get(); |
|
27 |
|
28 assert.pass('requesting ' + skinURL); |
|
29 } |
|
30 |
|
31 exports.testChromeContent = function(assert, done) { |
|
32 let wt = WindowTracker({ |
|
33 onTrack: function(window) { |
|
34 if (window.document.documentElement.getAttribute('windowtype') === 'test:window') { |
|
35 assert.pass('test xul window was opened'); |
|
36 wt.unload(); |
|
37 |
|
38 close(window).then(done, assert.fail); |
|
39 } |
|
40 } |
|
41 }); |
|
42 |
|
43 open(XUL_URL).then( |
|
44 assert.pass.bind(assert, 'opened ' + XUL_URL), |
|
45 assert.fail); |
|
46 |
|
47 assert.pass('opening ' + XUL_URL); |
|
48 } |
|
49 |
|
50 exports.testChromeLocale = function(assert) { |
|
51 let jpLocalePath = Cc['@mozilla.org/chrome/chrome-registry;1']. |
|
52 getService(Ci.nsIChromeRegistry). |
|
53 convertChromeURL(NetUtil.newURI('chrome://test/locale/description.properties')). |
|
54 spec.replace(/(en\-US|ja\-JP)/, 'ja-JP'); |
|
55 let enLocalePath = jpLocalePath.replace(/ja\-JP/, 'en-US'); |
|
56 |
|
57 let jpStringBundle = Services.strings.createBundle(jpLocalePath); |
|
58 assert.equal(jpStringBundle.GetStringFromName('test'), |
|
59 'ใในใ', |
|
60 'locales ja-JP folder was copied correctly'); |
|
61 |
|
62 let enStringBundle = Services.strings.createBundle(enLocalePath); |
|
63 assert.equal(enStringBundle.GetStringFromName('test'), |
|
64 'Test', |
|
65 'locales en-US folder was copied correctly'); |
|
66 } |
|
67 |
|
68 require('sdk/test/runner').runTestsFromModule(module); |