├── mutt
├── mutt
│ ├── tests
│ │ ├── python
│ │ │ ├── js-modules
│ │ │ │ ├── manifest-empty.ini
│ │ │ │ ├── test_shutdownAfterRestart
│ │ │ │ │ ├── manifest.ini
│ │ │ │ │ ├── test2.js
│ │ │ │ │ └── test1.js
│ │ │ │ ├── testThrowGlobalException.js
│ │ │ │ ├── newEmptyFunction.js
│ │ │ │ ├── testAddons.js
│ │ │ │ ├── testPersisted.js
│ │ │ │ ├── testShutdown_sleep.js
│ │ │ │ ├── testScreenshotPath.js
│ │ │ │ ├── testPersistedShutdown.js
│ │ │ │ ├── useMozmill
│ │ │ │ │ ├── testTeardownModuleFails.js
│ │ │ │ │ ├── testSetupModuleFails.js
│ │ │ │ │ ├── testTeardownTestFails.js
│ │ │ │ │ ├── testSetupTestFails.js
│ │ │ │ │ ├── testTeardownModuleAndTeardownTestFails.js
│ │ │ │ │ ├── testSetupModuleAndSetupTestFails.js
│ │ │ │ │ ├── testTestFails.js
│ │ │ │ │ └── testTestPass.js
│ │ │ │ ├── testShutdown_waitFor.js
│ │ │ │ ├── testMessageFlooding.js
│ │ │ │ ├── testPageLoadOnStartup.js
│ │ │ │ ├── testPageLoad.js
│ │ │ │ ├── testExpectStack.js
│ │ │ │ ├── testWaitForPassFrame.js
│ │ │ │ ├── testFailureBackgroundThread.js
│ │ │ │ ├── restartTests
│ │ │ │ │ ├── testStateMachine.js
│ │ │ │ │ ├── testCountTestSkipped.js
│ │ │ │ │ ├── testCountTestPasses.js
│ │ │ │ │ └── testCountTestFailures.js
│ │ │ │ └── testUTF-8.js
│ │ │ ├── cli
│ │ │ │ ├── manifest.ini
│ │ │ │ ├── test_manifest_and_tests_exclusive.py
│ │ │ │ └── test_profile_relative_path.py
│ │ │ ├── manifest.ini
│ │ │ ├── test_multiple_run.py
│ │ │ ├── test_framework_sanity.py
│ │ │ ├── test_slow_pageload_on_startup.py
│ │ │ ├── test_waitfor_pass_frame.py
│ │ │ ├── test_console_messages.py
│ │ │ ├── test_api.py
│ │ │ ├── test_persisted_object.py
│ │ │ ├── test_references.py
│ │ │ ├── test_throw_global_exception.py
│ │ │ ├── test_page_load.py
│ │ │ ├── test_logger_listener.py
│ │ │ ├── test_addons.py
│ │ │ ├── test_shutdown.py
│ │ │ ├── test_expect_stack.py
│ │ │ ├── test_use_mozmill.py
│ │ │ ├── test_screenshot_path.py
│ │ │ └── test_restart.py
│ │ ├── manifest.ini
│ │ ├── data
│ │ │ ├── favicon.ico
│ │ │ ├── singlediv.html
│ │ │ ├── link.html
│ │ │ ├── radio_button.html
│ │ │ ├── no_bfcache.html
│ │ │ ├── iframe.html
│ │ │ ├── complex.html
│ │ │ └── form.html
│ │ └── js
│ │ │ ├── testDriver
│ │ │ ├── manifest.ini
│ │ │ └── testOpenBrowserWindow.js
│ │ │ ├── testLiveWeb
│ │ │ ├── manifest.ini
│ │ │ └── testFlashProtectedMode.js
│ │ │ ├── testL10n
│ │ │ ├── manifest.ini
│ │ │ ├── testGetEntity.js
│ │ │ └── testGetProperty.js
│ │ │ ├── testAssertions
│ │ │ ├── manifest.ini
│ │ │ └── testWaitFor.js
│ │ │ ├── testFrame
│ │ │ ├── testSandbox
│ │ │ │ ├── manifest.ini
│ │ │ │ ├── testSandboxA.js
│ │ │ │ └── testSandboxB.js
│ │ │ ├── testHttpd
│ │ │ │ ├── manifest.ini
│ │ │ │ └── testRestartAvailability.js
│ │ │ ├── testRequire
│ │ │ │ ├── manifest.ini
│ │ │ │ ├── moduleC.js
│ │ │ │ ├── moduleB.js
│ │ │ │ ├── moduleD.js
│ │ │ │ ├── testRequireDefaultModules.js
│ │ │ │ ├── sub
│ │ │ │ │ └── moduleA.js
│ │ │ │ └── testRequire.js
│ │ │ ├── testRestart
│ │ │ │ ├── testApplicationDisconnect
│ │ │ │ │ ├── manifest.ini
│ │ │ │ │ ├── test2.js
│ │ │ │ │ └── test1.js
│ │ │ │ ├── testStates
│ │ │ │ │ ├── manifest.ini
│ │ │ │ │ ├── testSetupTestSkip.js
│ │ │ │ │ └── testSetupTestPass.js
│ │ │ │ ├── manifest.ini
│ │ │ │ └── testRestartFlags.js
│ │ │ ├── testGlobalTimeout
│ │ │ │ ├── manifest.ini
│ │ │ │ ├── testTimeoutAfter.js
│ │ │ │ └── testTimeout.js
│ │ │ ├── testUserShutdown
│ │ │ │ ├── testTimeoutRestartApplication
│ │ │ │ │ ├── manifest.ini
│ │ │ │ │ ├── test2.js
│ │ │ │ │ └── test1.js
│ │ │ │ ├── manifest.ini
│ │ │ │ └── testMultiple
│ │ │ │ │ ├── manifest.ini
│ │ │ │ │ ├── test5.js
│ │ │ │ │ ├── test1.js
│ │ │ │ │ ├── test2.js
│ │ │ │ │ ├── test3.js
│ │ │ │ │ ├── test7.js
│ │ │ │ │ ├── test4.js
│ │ │ │ │ └── test6.js
│ │ │ ├── python_callback.py
│ │ │ ├── testStopRunner.js
│ │ │ ├── manifest.ini
│ │ │ ├── testSyntaxError.js
│ │ │ ├── testPythonCallback.js
│ │ │ ├── testPersistedData.js
│ │ │ └── testInvalidInterface.js
│ │ │ ├── testMetro
│ │ │ ├── manifest.ini
│ │ │ └── testTabs.js
│ │ │ ├── metro
│ │ │ └── testTouchEvents
│ │ │ │ ├── manifest.ini
│ │ │ │ ├── testTap.js
│ │ │ │ ├── testWaitThenTap.js
│ │ │ │ └── testDoubleTap.js
│ │ │ ├── testUtils
│ │ │ ├── manifest.ini
│ │ │ ├── testPageLoadBfCache.js
│ │ │ ├── testReloadPage.js
│ │ │ └── testSaveScreenshot.js
│ │ │ ├── testElementsLib
│ │ │ ├── manifest.ini
│ │ │ ├── testSelector.js
│ │ │ ├── testStaleElement.js
│ │ │ ├── testRadioButtons.js
│ │ │ ├── testMozElementWindow.js
│ │ │ ├── testLookup.js
│ │ │ └── testMenuList.js
│ │ │ ├── manifest.ini
│ │ │ └── testController
│ │ │ ├── manifest.ini
│ │ │ ├── testDndChrome.js
│ │ │ ├── testDndContent.js
│ │ │ ├── testNativeEvents.js
│ │ │ ├── testDndContentChrome.js
│ │ │ ├── testDynamicMenuEntries.js
│ │ │ ├── testContextMenu.js
│ │ │ ├── testSynthesizeEvents.js
│ │ │ ├── testScreenshot.js
│ │ │ ├── testExpectedEvents.js
│ │ │ └── testWindowFocus.js
│ └── __init__.py
├── setup.py
└── README.md
├── mozmill
├── MANIFEST.in
├── mozmill
│ ├── extension
│ │ ├── content
│ │ │ └── test
│ │ │ │ ├── test.css
│ │ │ │ ├── test.html
│ │ │ │ ├── test.js
│ │ │ │ ├── test.xul
│ │ │ │ ├── radio_buttons.xul
│ │ │ │ └── chrome_elements.xul
│ │ ├── chrome.manifest
│ │ ├── resource
│ │ │ ├── stdlib
│ │ │ │ ├── dom.js
│ │ │ │ ├── strings.js
│ │ │ │ ├── objects.js
│ │ │ │ ├── os.js
│ │ │ │ └── arrays.js
│ │ │ ├── modules
│ │ │ │ ├── stack.js
│ │ │ │ ├── l10n.js
│ │ │ │ └── errors.js
│ │ │ └── driver
│ │ │ │ └── msgbroker.js
│ │ ├── build.xml
│ │ ├── install.rdf
│ │ └── components
│ │ │ └── handlers.js
│ ├── python_callbacks.py
│ └── handlers.py
├── scripts
│ └── sync_dependencies.py
├── docs
│ ├── api_example.py
│ └── architecture.txt
├── setup.py
└── patches
│ └── eventUtils.patch
├── jsbridge
├── MANIFEST.in
├── jsbridge
│ ├── extension
│ │ ├── chrome.manifest
│ │ ├── install.rdf
│ │ ├── resource
│ │ │ └── modules
│ │ │ │ ├── Events.jsm
│ │ │ │ ├── Log.jsm
│ │ │ │ └── Server.jsm
│ │ └── components
│ │ │ └── jsbridge.js
│ └── __init__.py
├── History.md
├── README.md
└── setup.py
├── .gitignore
├── docs.manifest
├── carton-mozmill.py
└── README.md
/mutt/mutt/tests/python/js-modules/manifest-empty.ini:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/mozmill/MANIFEST.in:
--------------------------------------------------------------------------------
1 | recursive-include docs *
2 | recursive-include mozmill/extension *
3 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/manifest.ini:
--------------------------------------------------------------------------------
1 | [include:python/manifest.ini]
2 | [include:js/manifest.ini]
3 |
--------------------------------------------------------------------------------
/jsbridge/MANIFEST.in:
--------------------------------------------------------------------------------
1 | recursive-include jsbridge/extension *
2 | recursive-include jsbridge/xpi *
3 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/js-modules/test_shutdownAfterRestart/manifest.ini:
--------------------------------------------------------------------------------
1 | [test1.js]
2 | [test2.js]
3 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/data/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apm/mozmill/master/mutt/mutt/tests/data/favicon.ico
--------------------------------------------------------------------------------
/mutt/mutt/tests/js/testDriver/manifest.ini:
--------------------------------------------------------------------------------
1 | [DEFAULT]
2 | type = javascript
3 |
4 | [testOpenBrowserWindow.js]
5 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/js/testLiveWeb/manifest.ini:
--------------------------------------------------------------------------------
1 | [DEFAULT]
2 | type = javascript
3 |
4 | [testFlashProtectedMode.js]
5 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/js/testL10n/manifest.ini:
--------------------------------------------------------------------------------
1 | [DEFAULT]
2 | type = javascript
3 |
4 | [testGetEntity.js]
5 | [testGetProperty.js]
6 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/data/singlediv.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 | We believe that the internet should be public,
15 | open and accessible.
16 |
17 |
18 |
19 |
24 |
25 |
26 |
27 | We're an open source project whose code is used for some of the
28 | Internet's most innovative applications.
29 | More
30 |
31 |
32 |
33 |
34 | We're a public benefit organization dedicated to making the
35 | Internet better for everyone.
36 | More
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/test_waitfor_pass_frame.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, you can obtain one at http://mozilla.org/MPL/2.0/.
6 |
7 | import os
8 | import unittest
9 |
10 | import mozmill
11 |
12 |
13 | class TestBug795579(unittest.TestCase):
14 | """Bug 795579: waitFor method doesn't send a pass frame
15 | which can cause an application disconnect when handled in a loop
16 | """
17 |
18 | jsbridge_timeout = 5.
19 |
20 | def test_waitfor_send_pass_frame(self):
21 | testpath = os.path.join("js-modules", "testWaitForPassFrame.js")
22 | self.do_test(testpath, passes=2, fails=0, skips=0)
23 |
24 | def do_test(self, relative_test_path, passes=0, fails=0, skips=0):
25 | testpath = os.path.join(os.path.dirname(os.path.abspath(__file__)),
26 | relative_test_path)
27 | tests = [{'path': testpath}]
28 |
29 | m = mozmill.MozMill.create(jsbridge_timeout=self.jsbridge_timeout)
30 | m.run(tests)
31 | results = m.finish()
32 |
33 | self.assertEqual(len(results.passes), passes)
34 | self.assertEqual(len(results.fails), fails)
35 | self.assertEqual(len(results.skipped), skips)
36 |
37 | if __name__ == '__main__':
38 | unittest.main()
39 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/js/testController/testContextMenu.js:
--------------------------------------------------------------------------------
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 |
5 | const BASE_URL = collector.addHttpResource("../../data/");
6 | const TEST_DATA = BASE_URL + "form.html";
7 |
8 | function setupModule(aModule) {
9 | aModule.controller = mozmill.getBrowserController();
10 |
11 | // Create a new menu instance for the context menu
12 | aModule.contextMenu = aModule.controller.getMenu("#contentAreaContextMenu");
13 | }
14 |
15 | function testMenu() {
16 | controller.open(TEST_DATA);
17 | controller.waitForPageLoad();
18 |
19 | // Enter text in a text field and select all via the context menu
20 | var field = new elementslib.ID(controller.tabs.activeTab, "fname");
21 | field.sendKeys("mozmill");
22 | contextMenu.select("#context-selectall", field);
23 |
24 | // Reopen the context menu and check the 'Paste' menu item
25 | contextMenu.open(field);
26 | expect.ok(contextMenu.getItem("#context-viewimage").getNode().hidden,
27 | "Context menu entry 'View Image' is not visible");
28 |
29 | // Remove the text by selecting 'Undo'
30 | contextMenu.keypress("VK_DOWN", {});
31 | contextMenu.keypress("VK_RETURN", {});
32 | contextMenu.close();
33 |
34 | expect.equal(field.getNode().value, "", "Text field has been emptied.");
35 | }
36 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/js/testElementsLib/testRadioButtons.js:
--------------------------------------------------------------------------------
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 |
5 | const BASE_URL = collector.addHttpResource("../../data/");
6 | const TEST_DATA = BASE_URL + "radio_button.html";
7 |
8 | function setupModule(aModule) {
9 | aModule.controller = mozmill.getBrowserController();
10 | }
11 |
12 | function test() {
13 | // Test content
14 | controller.open(TEST_DATA);
15 | controller.waitForPageLoad();
16 |
17 | let radio1 = findElement.ID(controller.tabs.activeTab, "radio1");
18 | radio1.select();
19 | expect.ok(radio1.getNode().checked, "First radio button has been selected.");
20 |
21 | let radio2 = findElement.ID(controller.tabs.activeTab, "radio2");
22 | radio2.select();
23 | expect.ok(radio2.getNode().checked, "Second radio button has been selected.");
24 |
25 | // Test chrome (XUL)
26 | controller.open("chrome://mozmill/content/test/radio_buttons.xul");
27 | controller.waitForPageLoad();
28 |
29 | var radiogroup = findElement.ID(controller.tabs.activeTab, "saveWhere");
30 | radiogroup.select(0);
31 | expect.equal(radiogroup.getNode().selectedIndex, 0, "First radio button has been selected.");
32 |
33 | radiogroup.select(1);
34 | expect.equal(radiogroup.getNode().selectedIndex, 1, "Second radio button has been selected.");
35 | }
36 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/test_console_messages.py:
--------------------------------------------------------------------------------
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 |
5 | import os
6 | import unittest
7 |
8 | import mozmill
9 |
10 |
11 | class TestFrameworkFailure(unittest.TestCase):
12 |
13 | def do_test(self, relative_test_path, passes=0, fails=0, skips=0):
14 | testpath = os.path.join(os.path.dirname(os.path.abspath(__file__)),
15 | relative_test_path)
16 | tests = [{'path': testpath}]
17 |
18 | m = mozmill.MozMill.create()
19 | m.run(tests)
20 | results = m.finish(())
21 |
22 | # From the first test, there is one passing test
23 | self.assertEqual(len(results.passes), passes, "Passes should match")
24 | self.assertEqual(len(results.fails), fails, "Fails should match")
25 | self.assertEqual(len(results.skipped), skips, "Skips should match")
26 |
27 | def test_no_abort_via_client_tests(self):
28 | testpath = os.path.join("js-modules", "testFailureBackgroundThread.js")
29 | self.do_test(testpath, passes=1, fails=0, skips=0)
30 |
31 | def test_message_flooding(self):
32 | testpath = os.path.join("js-modules", "testMessageFlooding.js")
33 | self.do_test(testpath, passes=2, fails=0, skips=0)
34 |
35 | if __name__ == '__main__':
36 | unittest.main()
37 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/js/testFrame/testRestart/testStates/testSetupTestPass.js:
--------------------------------------------------------------------------------
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 |
5 | var state = 0;
6 |
7 | // initialisation code that will only run once
8 | // for example: setting the addons discovery pane URL to a local resource
9 | function setupModule() {
10 | state = 2;
11 | }
12 |
13 | // initialisation code that will run for every test
14 | // for example: initialising the controller or closing all tabs
15 | function setupTest(aModule) {
16 | aModule.controller = mozmill.getBrowserController();
17 | state++;
18 | }
19 |
20 | function testOne() {
21 | assert.equal(state, 3, 'Ensure setupModule and setupTest ran before testOne');
22 |
23 | controller.restartApplication('testTwo');
24 | }
25 |
26 | function testTwo() {
27 | // this time setupModule is not run but setupTest is, so state is 1.
28 | assert.equal(state, 1, 'Ensure only setupTest ran before testTwo');
29 | }
30 |
31 | // teardown code that will run for every test
32 | function teardownTest() {
33 | state--;
34 | }
35 |
36 | // teardown code that will only run once, at the very end
37 | // for example: clearing user defined preferences
38 | // Because it is only run after testTwo and teardowntest, state is 0
39 | function teardownModule() {
40 | assert.equal(state, 0, 'Ensure that testTwo and teardownTest ran before teardownModule');
41 | }
42 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/test_api.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, you can obtain one at http://mozilla.org/MPL/2.0/.
6 |
7 | import mozmill
8 | import os
9 | import unittest
10 |
11 |
12 | class TestMozmillAPI(unittest.TestCase):
13 | """Several tests for Mozmill API"""
14 |
15 | def do_test(self, relative_test_path, profile_args=None, runner_args=None):
16 | abspath = os.path.dirname(os.path.abspath(__file__))
17 | testpath = os.path.join(abspath, relative_test_path)
18 | tests = [{'path': testpath}]
19 |
20 | m = mozmill.MozMill.create(profile_args=profile_args,
21 | runner_args=runner_args)
22 | m.run(tests)
23 | m.finish()
24 |
25 | return m.results
26 |
27 | def test_basic(self):
28 | testpath = os.path.join("js-modules", "newEmptyFunction.js")
29 | results = self.do_test(testpath)
30 |
31 | self.assertEqual(len(results.passes), 1)
32 |
33 | def test_create_args_by_reference(self):
34 | testpath = os.path.join("js-modules", "newEmptyFunction.js")
35 | profile_args = dict(addons=[])
36 | runner_args = dict(cmdargs=[])
37 |
38 | self.do_test(testpath, profile_args, runner_args)
39 |
40 | self.assertEqual(profile_args, dict(addons=[]))
41 | self.assertEqual(runner_args, dict(cmdargs=[]))
42 |
43 | if __name__ == '__main__':
44 | unittest.main()
45 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/test_persisted_object.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, you can obtain one at http://mozilla.org/MPL/2.0/.
6 |
7 | import mozmill
8 | import os
9 | import unittest
10 |
11 |
12 | class TestMozmillPersisted(unittest.TestCase):
13 | """test persisted object"""
14 |
15 | def do_test(self, relative_test_path):
16 | abspath = os.path.dirname(os.path.abspath(__file__))
17 | testpath = os.path.join(abspath, relative_test_path)
18 | tests = [{'path': testpath}]
19 |
20 | m = mozmill.MozMill.create()
21 |
22 | m.persisted['bar'] = 'foo'
23 | m.persisted['foo'] = 'bar'
24 | m.persisted['number'] = 1
25 |
26 | m.run(tests)
27 | results = m.finish()
28 |
29 | self.assertEqual(len(results.passes), 1)
30 |
31 | # inspect the persisted data following the test
32 | self.assertEqual(m.persisted['fleem'], 2)
33 | self.assertEqual(m.persisted['bar'], 'bar')
34 | self.assertEqual(m.persisted['number'], 2)
35 | self.assertFalse('foo' in m.persisted)
36 |
37 | def test_persisted(self):
38 | testpath = os.path.join("js-modules", "testPersisted.js")
39 | self.do_test(testpath)
40 |
41 | def test_persisted_shutdown(self):
42 | testpath = os.path.join("js-modules", "testPersistedShutdown.js")
43 | self.do_test(testpath)
44 |
45 |
46 | if __name__ == '__main__':
47 | unittest.main()
48 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/cli/test_manifest_and_tests_exclusive.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, you can obtain one at http://mozilla.org/MPL/2.0/.
6 |
7 | import subprocess
8 | import os
9 | import unittest
10 |
11 | from mozprocess import ProcessHandler
12 |
13 | class TestManifestTestsOptions(unittest.TestCase):
14 | """Ensure that tests and manifests cannot be specified at the same time."""
15 |
16 | def test_options(self):
17 | absdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18 | testdir = os.path.join(absdir, 'js-modules')
19 |
20 | process = ProcessHandler(['mozmill',
21 | '-b', os.environ['BROWSER_PATH'],
22 | '-t', os.path.join(testdir,
23 | 'useMozmill',
24 | 'testTestPass.js'),
25 | '-m', os.path.join(testdir, 'manifest-empty.ini')
26 | ],
27 | # stop mozmill from printing output to console
28 | processOutputLine=[lambda line: None])
29 | process.run()
30 | process.wait()
31 |
32 | self.assertNotEqual(process.proc.poll(), 0,
33 | 'Parser error due to -t and -m are mutually exclusive')
34 |
35 | if __name__ == '__main__':
36 | unittest.main()
37 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/test_references.py:
--------------------------------------------------------------------------------
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 |
5 | from cStringIO import StringIO
6 | import os
7 | import sys
8 | import unittest
9 |
10 | import mozmill
11 | from mozmill.logger import LoggerListener
12 |
13 |
14 | class ModuleTest(unittest.TestCase):
15 |
16 | def do_test(self, relative_test_path):
17 | abspath = os.path.dirname(os.path.abspath(__file__))
18 | testpath = os.path.join(abspath, relative_test_path)
19 | tests = [{'path': testpath}]
20 |
21 | info_data = StringIO()
22 | logger = LoggerListener(console_level="DEBUG",
23 | console_stream=info_data)
24 |
25 | m = mozmill.MozMill.create(handlers=[logger])
26 | m.run(tests)
27 | results = m.finish()
28 |
29 | self.assertEqual(sys.getrefcount(logger), 2,
30 | "Only a single reference to the logger exists")
31 | self.assertEqual(sys.getrefcount(m), 2,
32 | "Only a single reference to mozmill exists")
33 |
34 | return results
35 |
36 | def test_modules(self):
37 | testpath = os.path.join("js-modules", "newEmptyFunction.js")
38 | results = self.do_test(testpath)
39 |
40 | self.assertEqual(sys.getrefcount(results), 2,
41 | "Only a single reference to results exists")
42 |
43 | if __name__ == '__main__':
44 | unittest.main()
45 |
--------------------------------------------------------------------------------
/mozmill/mozmill/extension/resource/stdlib/objects.js:
--------------------------------------------------------------------------------
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 |
5 | var EXPORTED_SYMBOLS = ['getLength', ];//'compare'];
6 |
7 | function getLength(obj) {
8 | var len = 0;
9 | for (i in obj) {
10 | len++;
11 | }
12 |
13 | return len;
14 | }
15 |
16 | // var logging = {}; Components.utils.import('resource://mozmill/stdlib/logging.js', logging);
17 |
18 | // var objectsLogger = logging.getLogger('objectsLogger');
19 |
20 | // var compare = function (obj1, obj2, depth, recursion) {
21 | // if (depth == undefined) {
22 | // var depth = 4;
23 | // }
24 | // if (recursion == undefined) {
25 | // var recursion = 0;
26 | // }
27 | //
28 | // if (recursion > depth) {
29 | // return true;
30 | // }
31 | //
32 | // if (typeof(obj1) != typeof(obj2)) {
33 | // return false;
34 | // }
35 | //
36 | // if (typeof(obj1) == "object" && typeof(obj2) == "object") {
37 | // if ([x for (x in obj1)].length != [x for (x in obj2)].length) {
38 | // return false;
39 | // }
40 | // for (i in obj1) {
41 | // recursion++;
42 | // var result = compare(obj1[i], obj2[i], depth, recursion);
43 | // objectsLogger.info(i+' in recursion '+result);
44 | // if (result == false) {
45 | // return false;
46 | // }
47 | // }
48 | // } else {
49 | // if (obj1 != obj2) {
50 | // return false;
51 | // }
52 | // }
53 | // return true;
54 | // }
55 |
--------------------------------------------------------------------------------
/mozmill/mozmill/extension/resource/stdlib/os.js:
--------------------------------------------------------------------------------
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 |
5 | var EXPORTED_SYMBOLS = ['listDirectory', 'getFileForPath', 'abspath', 'getPlatform'];
6 |
7 | const Cc = Components.classes;
8 | const Ci = Components.interfaces;
9 | const Cu = Components.utils;
10 |
11 | Cu.import("resource://gre/modules/Services.jsm");
12 |
13 | function listDirectory(file) {
14 | // file is the given directory (nsIFile)
15 | var entries = file.directoryEntries;
16 | var array = [];
17 |
18 | while (entries.hasMoreElements()) {
19 | var entry = entries.getNext();
20 | entry.QueryInterface(Ci.nsIFile);
21 | array.push(entry);
22 | }
23 |
24 | return array;
25 | }
26 |
27 | function getFileForPath(path) {
28 | var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
29 | file.initWithPath(path);
30 | return file;
31 | }
32 |
33 | function abspath(rel, file) {
34 | var relSplit = rel.split('/');
35 |
36 | if (relSplit[0] == '..' && !file.isDirectory()) {
37 | file = file.parent;
38 | }
39 |
40 | for each(var p in relSplit) {
41 | if (p == '..') {
42 | file = file.parent;
43 | } else if (p == '.') {
44 | if (!file.isDirectory()) {
45 | file = file.parent;
46 | }
47 | } else {
48 | file.append(p);
49 | }
50 | }
51 |
52 | return file.path;
53 | }
54 |
55 | function getPlatform() {
56 | return Services.appinfo.OS.toLowerCase();
57 | }
58 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/js-modules/restartTests/testStateMachine.js:
--------------------------------------------------------------------------------
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 |
5 | Cu.import("resource://gre/modules/Services.jsm");
6 |
7 | const STATES = [
8 | "testFirst",
9 | "testSecond",
10 | "testThird"
11 | ];
12 |
13 |
14 | function setupModule(aModule) {
15 | persisted.seen_states = ['setupModule'];
16 |
17 | persisted.state = {
18 | index: 0,
19 | finished: false
20 | };
21 | }
22 |
23 | function setupTest(aModule) {
24 | persisted.seen_states.push('setupTest');
25 |
26 | aModule.controller = mozmill.getBrowserController();
27 | }
28 |
29 | function teardownTest(aModule) {
30 | persisted.seen_states.push('teardownTest');
31 |
32 | if (!persisted.state.finished) {
33 | aModule.controller.restartApplication(STATES[persisted.state.index]);
34 | } else {
35 | aModule.controller.stopApplication();
36 | }
37 | }
38 |
39 | function teardownModule(aModule) {
40 | persisted.seen_states.push('teardownModule');
41 | }
42 |
43 | function testFirst() {
44 | persisted.seen_states.push('testFirst');
45 | persisted.state.index = 2;
46 | }
47 |
48 | function testSecond() {
49 | persisted.seen_states.push('testSecond');
50 | persisted.state.finished = true;
51 | }
52 |
53 | function testThird() {
54 | persisted.seen_states.push('testThird');
55 | persisted.state.index = 1
56 | }
57 |
58 | function testForth() {
59 | assert.fail("This test should not be executed");
60 | }
61 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/js/testController/testSynthesizeEvents.js:
--------------------------------------------------------------------------------
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 |
5 | const BASE_URL = collector.addHttpResource("../../data/");
6 | const TEST_DATA = BASE_URL + "form.html";
7 |
8 | function setupModule(aModule) {
9 | aModule.controller = mozmill.getBrowserController();
10 | }
11 |
12 | function test() {
13 | controller.open(TEST_DATA);
14 | controller.waitForPageLoad();
15 |
16 | var fname = new elementslib.ID(controller.tabs.activeTab, "fname");
17 | var lname = new elementslib.ID(controller.tabs.activeTab, "lname");
18 |
19 | // Clicking the search field should raise a focus event
20 | fname.click(2, 2);
21 | expect.equal(fname.getNode(), controller.tabs.activeTab.activeElement,
22 | "click() put the focus to the element.");
23 |
24 | // Synthesize keypress event
25 | fname.keypress("F", {shiftKey: true});
26 | expect.equal(fname.getNode().value, "F",
27 | "keypress() with pressed shift key succeeded.");
28 | fname.getNode().value = "";
29 |
30 | // Synthesize type event
31 | fname.sendKeys("Fire");
32 | expect.equal(fname.getNode().value, "Fire",
33 | "type() without expected event succeeded.");
34 |
35 | // A focus event for the next element in the tab order should be fired
36 | fname.keypress("VK_TAB", {});
37 | expect.equal(lname.getNode(), controller.tabs.activeTab.activeElement,
38 | "Tab key put the focus to the next element.");
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/js/testElementsLib/testMozElementWindow.js:
--------------------------------------------------------------------------------
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 |
5 | const BASE_URL = collector.addHttpResource("../../data/");
6 | const TEST_DATA = BASE_URL + "form.html";
7 |
8 | // Bug 677364:
9 | // Fix controller keyboard methods to allow a null parameter for the target element
10 |
11 | function setupModule(aModule) {
12 | aModule.controller = mozmill.getBrowserController();
13 |
14 | aModule.win = new findElement.Elem(aModule.controller.window);
15 | }
16 |
17 | function testContent() {
18 | controller.open(TEST_DATA);
19 | controller.waitForPageLoad();
20 |
21 | let textbox = new findElement.ID(controller.tabs.activeTab, "fname");
22 |
23 | // Focus the textbox
24 | textbox.click();
25 |
26 | // A key event sent to the window will be propagated to the
27 | // currently active element.
28 | win.keypress("t");
29 | expect.equal(textbox.getNode().value, "t",
30 | "keypress added letter to textbox.");
31 | }
32 |
33 | function testChrome() {
34 | controller.open('about:blank');
35 | controller.waitForPageLoad();
36 |
37 | let urlbar = new findElement.ID(controller.window.document, "urlbar");
38 |
39 | // Focus the location bar
40 | urlbar.click();
41 |
42 | // A key event sent to the window will be propagated to the
43 | // currently active element.
44 | win.keypress("t", { });
45 | expect.equal(urlbar.getNode().value, "t",
46 | "keypress added letter to location bar.");
47 | }
48 |
--------------------------------------------------------------------------------
/mozmill/mozmill/extension/resource/modules/stack.js:
--------------------------------------------------------------------------------
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 |
5 | var EXPORTED_SYMBOLS = ['findCallerFrame'];
6 |
7 |
8 | /**
9 | * @namespace Defines utility methods for handling stack frames
10 | */
11 |
12 | /**
13 | * Find the frame to use for logging the test result. If a start frame has
14 | * been specified, we walk down the stack until a frame with the same filename
15 | * as the start frame has been found. The next file in the stack will be the
16 | * frame to use for logging the result.
17 | *
18 | * @memberOf stack
19 | * @param {Object} [aStartFrame=Components.stack] Frame to start from walking up the stack.
20 | * @returns {Object} Frame of the stack to use for logging the result.
21 | */
22 | function findCallerFrame(aStartFrame) {
23 | let frame = Components.stack;
24 | let filename = frame.filename.replace(/(.*)-> /, "");
25 |
26 | // If a start frame has been specified, walk up the stack until we have
27 | // found the corresponding file
28 | if (aStartFrame) {
29 | filename = aStartFrame.filename.replace(/(.*)-> /, "");
30 |
31 | while (frame.caller &&
32 | frame.filename && (frame.filename.indexOf(filename) == -1)) {
33 | frame = frame.caller;
34 | }
35 | }
36 |
37 | // Walk even up more until the next file has been found
38 | while (frame.caller &&
39 | (!frame.filename || (frame.filename.indexOf(filename) != -1)))
40 | frame = frame.caller;
41 |
42 | return frame;
43 | }
44 |
--------------------------------------------------------------------------------
/mutt/mutt/tests/python/test_throw_global_exception.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, you can obtain one at http://mozilla.org/MPL/2.0/.
6 |
7 | import mozmill
8 | import os
9 | import unittest
10 |
11 |
12 | class TestBug690154(unittest.TestCase):
13 | """
14 | JSON structure when test throws a global exception:
15 | https://bugzilla.mozilla.org/show_bug.cgi?id=690154
16 | """
17 |
18 | def do_test(self, relative_test_path, passes=0):
19 | abspath = os.path.dirname(os.path.abspath(__file__))
20 | testpath = os.path.join(abspath, relative_test_path)
21 | tests = [{'path': testpath}]
22 |
23 | m = mozmill.MozMill.create()
24 | m.run(tests)
25 | results = m.finish(())
26 |
27 | # no modules pass
28 | self.assertFalse(results.passes)
29 | # one module fails
30 | self.assertTrue(len(results.fails) == 1)
31 |
32 | fails = results.fails[0]
33 | # no functions pass
34 | self.assertFalse(fails['passes'])
35 | # a single failure at the module level
36 | self.assertTrue(len(fails['fails']) == 1)
37 |
38 | failure = fails['fails'][0]
39 | self.assertTrue('exception' in failure)
40 | self.assertTrue(fails['name'] == '