summaryrefslogtreecommitdiffstats
path: root/toolkit
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-10 02:51:36 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-10 02:51:36 -0500
commit37d5300335d81cecbecc99812747a657588c63eb (patch)
tree765efa3b6a56bb715d9813a8697473e120436278 /toolkit
parentb2bdac20c02b12f2057b9ef70b0a946113a00e00 (diff)
parent4fb11cd5966461bccc3ed1599b808237be6b0de9 (diff)
downloadUXP-37d5300335d81cecbecc99812747a657588c63eb.tar
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.gz
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.lz
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.xz
UXP-37d5300335d81cecbecc99812747a657588c63eb.zip
Merge branch 'ext-work'
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/components/moz.build4
-rw-r--r--toolkit/components/telemetry/tests/unit/xpcshell.ini2
-rw-r--r--toolkit/components/webextensions/.eslintrc.js (renamed from toolkit/components/extensions/.eslintrc.js)0
-rw-r--r--toolkit/components/webextensions/Extension.jsm (renamed from toolkit/components/extensions/Extension.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionAPI.jsm (renamed from toolkit/components/extensions/ExtensionAPI.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionChild.jsm (renamed from toolkit/components/extensions/ExtensionChild.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionCommon.jsm (renamed from toolkit/components/extensions/ExtensionCommon.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionContent.jsm (renamed from toolkit/components/extensions/ExtensionContent.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionManagement.jsm (renamed from toolkit/components/extensions/ExtensionManagement.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionParent.jsm (renamed from toolkit/components/extensions/ExtensionParent.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionStorage.jsm (renamed from toolkit/components/extensions/ExtensionStorage.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionTestCommon.jsm (renamed from toolkit/components/extensions/ExtensionTestCommon.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionUtils.jsm (renamed from toolkit/components/extensions/ExtensionUtils.jsm)0
-rw-r--r--toolkit/components/webextensions/ExtensionXPCShellUtils.jsm (renamed from toolkit/components/extensions/ExtensionXPCShellUtils.jsm)0
-rw-r--r--toolkit/components/webextensions/LegacyExtensionsUtils.jsm (renamed from toolkit/components/extensions/LegacyExtensionsUtils.jsm)0
-rw-r--r--toolkit/components/webextensions/MessageChannel.jsm (renamed from toolkit/components/extensions/MessageChannel.jsm)0
-rw-r--r--toolkit/components/webextensions/NativeMessaging.jsm (renamed from toolkit/components/extensions/NativeMessaging.jsm)0
-rw-r--r--toolkit/components/webextensions/Schemas.jsm (renamed from toolkit/components/extensions/Schemas.jsm)0
-rw-r--r--toolkit/components/webextensions/ext-alarms.js (renamed from toolkit/components/extensions/ext-alarms.js)0
-rw-r--r--toolkit/components/webextensions/ext-backgroundPage.js (renamed from toolkit/components/extensions/ext-backgroundPage.js)0
-rw-r--r--toolkit/components/webextensions/ext-browser-content.js (renamed from toolkit/components/extensions/ext-browser-content.js)0
-rw-r--r--toolkit/components/webextensions/ext-c-backgroundPage.js (renamed from toolkit/components/extensions/ext-c-backgroundPage.js)0
-rw-r--r--toolkit/components/webextensions/ext-c-extension.js (renamed from toolkit/components/extensions/ext-c-extension.js)0
-rw-r--r--toolkit/components/webextensions/ext-c-runtime.js (renamed from toolkit/components/extensions/ext-c-runtime.js)0
-rw-r--r--toolkit/components/webextensions/ext-c-storage.js (renamed from toolkit/components/extensions/ext-c-storage.js)0
-rw-r--r--toolkit/components/webextensions/ext-c-test.js (renamed from toolkit/components/extensions/ext-c-test.js)0
-rw-r--r--toolkit/components/webextensions/ext-cookies.js (renamed from toolkit/components/extensions/ext-cookies.js)0
-rw-r--r--toolkit/components/webextensions/ext-downloads.js (renamed from toolkit/components/extensions/ext-downloads.js)0
-rw-r--r--toolkit/components/webextensions/ext-extension.js (renamed from toolkit/components/extensions/ext-extension.js)0
-rw-r--r--toolkit/components/webextensions/ext-i18n.js (renamed from toolkit/components/extensions/ext-i18n.js)0
-rw-r--r--toolkit/components/webextensions/ext-idle.js (renamed from toolkit/components/extensions/ext-idle.js)0
-rw-r--r--toolkit/components/webextensions/ext-management.js (renamed from toolkit/components/extensions/ext-management.js)0
-rw-r--r--toolkit/components/webextensions/ext-notifications.js (renamed from toolkit/components/extensions/ext-notifications.js)0
-rw-r--r--toolkit/components/webextensions/ext-runtime.js (renamed from toolkit/components/extensions/ext-runtime.js)0
-rw-r--r--toolkit/components/webextensions/ext-storage.js (renamed from toolkit/components/extensions/ext-storage.js)0
-rw-r--r--toolkit/components/webextensions/ext-topSites.js (renamed from toolkit/components/extensions/ext-topSites.js)0
-rw-r--r--toolkit/components/webextensions/ext-webNavigation.js (renamed from toolkit/components/extensions/ext-webNavigation.js)0
-rw-r--r--toolkit/components/webextensions/ext-webRequest.js (renamed from toolkit/components/extensions/ext-webRequest.js)0
-rw-r--r--toolkit/components/webextensions/extensions-toolkit.manifest (renamed from toolkit/components/extensions/extensions-toolkit.manifest)0
-rw-r--r--toolkit/components/webextensions/jar.mn (renamed from toolkit/components/extensions/jar.mn)0
-rw-r--r--toolkit/components/webextensions/moz.build (renamed from toolkit/components/extensions/moz.build)0
-rw-r--r--toolkit/components/webextensions/schemas/LICENSE (renamed from toolkit/components/extensions/schemas/LICENSE)0
-rw-r--r--toolkit/components/webextensions/schemas/alarms.json (renamed from toolkit/components/extensions/schemas/alarms.json)0
-rw-r--r--toolkit/components/webextensions/schemas/cookies.json (renamed from toolkit/components/extensions/schemas/cookies.json)0
-rw-r--r--toolkit/components/webextensions/schemas/downloads.json (renamed from toolkit/components/extensions/schemas/downloads.json)0
-rw-r--r--toolkit/components/webextensions/schemas/events.json (renamed from toolkit/components/extensions/schemas/events.json)0
-rw-r--r--toolkit/components/webextensions/schemas/experiments.json (renamed from toolkit/components/extensions/schemas/experiments.json)0
-rw-r--r--toolkit/components/webextensions/schemas/extension.json (renamed from toolkit/components/extensions/schemas/extension.json)0
-rw-r--r--toolkit/components/webextensions/schemas/extension_types.json (renamed from toolkit/components/extensions/schemas/extension_types.json)0
-rw-r--r--toolkit/components/webextensions/schemas/i18n.json (renamed from toolkit/components/extensions/schemas/i18n.json)0
-rw-r--r--toolkit/components/webextensions/schemas/idle.json (renamed from toolkit/components/extensions/schemas/idle.json)0
-rw-r--r--toolkit/components/webextensions/schemas/jar.mn (renamed from toolkit/components/extensions/schemas/jar.mn)0
-rw-r--r--toolkit/components/webextensions/schemas/management.json (renamed from toolkit/components/extensions/schemas/management.json)0
-rw-r--r--toolkit/components/webextensions/schemas/manifest.json (renamed from toolkit/components/extensions/schemas/manifest.json)0
-rw-r--r--toolkit/components/webextensions/schemas/moz.build (renamed from toolkit/components/extensions/schemas/moz.build)0
-rw-r--r--toolkit/components/webextensions/schemas/native_host_manifest.json (renamed from toolkit/components/extensions/schemas/native_host_manifest.json)0
-rw-r--r--toolkit/components/webextensions/schemas/notifications.json (renamed from toolkit/components/extensions/schemas/notifications.json)0
-rw-r--r--toolkit/components/webextensions/schemas/runtime.json (renamed from toolkit/components/extensions/schemas/runtime.json)0
-rw-r--r--toolkit/components/webextensions/schemas/storage.json (renamed from toolkit/components/extensions/schemas/storage.json)0
-rw-r--r--toolkit/components/webextensions/schemas/test.json (renamed from toolkit/components/extensions/schemas/test.json)0
-rw-r--r--toolkit/components/webextensions/schemas/top_sites.json (renamed from toolkit/components/extensions/schemas/top_sites.json)0
-rw-r--r--toolkit/components/webextensions/schemas/web_navigation.json (renamed from toolkit/components/extensions/schemas/web_navigation.json)0
-rw-r--r--toolkit/components/webextensions/schemas/web_request.json (renamed from toolkit/components/extensions/schemas/web_request.json)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/.eslintrc.js (renamed from toolkit/components/extensions/test/mochitest/.eslintrc.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/chrome.ini (renamed from toolkit/components/extensions/test/mochitest/chrome.ini)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/chrome_head.js (renamed from toolkit/components/extensions/test/mochitest/chrome_head.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_WebNavigation_page1.html (renamed from toolkit/components/extensions/test/mochitest/file_WebNavigation_page1.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_WebNavigation_page2.html (renamed from toolkit/components/extensions/test/mochitest/file_WebNavigation_page2.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_WebNavigation_page3.html (renamed from toolkit/components/extensions/test/mochitest/file_WebNavigation_page3.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_WebRequest_page3.html (renamed from toolkit/components/extensions/test/mochitest/file_WebRequest_page3.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_csp.html (renamed from toolkit/components/extensions/test/mochitest/file_csp.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_csp.html^headers^ (renamed from toolkit/components/extensions/test/mochitest/file_csp.html^headers^)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_ext_test_api_injection.js (renamed from toolkit/components/extensions/test/mochitest/file_ext_test_api_injection.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_image_bad.png (renamed from toolkit/components/extensions/test/mochitest/file_image_bad.png)bin5401 -> 5401 bytes
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_image_good.png (renamed from toolkit/components/extensions/test/mochitest/file_image_good.png)bin580 -> 580 bytes
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_image_redirect.png (renamed from toolkit/components/extensions/test/mochitest/file_image_redirect.png)bin5401 -> 5401 bytes
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_mixed.html (renamed from toolkit/components/extensions/test/mochitest/file_mixed.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_permission_xhr.html (renamed from toolkit/components/extensions/test/mochitest/file_permission_xhr.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_privilege_escalation.html (renamed from toolkit/components/extensions/test/mochitest/file_privilege_escalation.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_sample.html (renamed from toolkit/components/extensions/test/mochitest/file_sample.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_script_bad.js (renamed from toolkit/components/extensions/test/mochitest/file_script_bad.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_script_good.js (renamed from toolkit/components/extensions/test/mochitest/file_script_good.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_script_redirect.js (renamed from toolkit/components/extensions/test/mochitest/file_script_redirect.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_script_xhr.js (renamed from toolkit/components/extensions/test/mochitest/file_script_xhr.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_style_bad.css (renamed from toolkit/components/extensions/test/mochitest/file_style_bad.css)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_style_good.css (renamed from toolkit/components/extensions/test/mochitest/file_style_good.css)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_style_redirect.css (renamed from toolkit/components/extensions/test/mochitest/file_style_redirect.css)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_teardown_test.js (renamed from toolkit/components/extensions/test/mochitest/file_teardown_test.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect.html (renamed from toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html (renamed from toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html^headers^ (renamed from toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html^headers^)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_webNavigation_frameClientRedirect.html (renamed from toolkit/components/extensions/test/mochitest/file_webNavigation_frameClientRedirect.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_webNavigation_frameRedirect.html (renamed from toolkit/components/extensions/test/mochitest/file_webNavigation_frameRedirect.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe.html (renamed from toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe_page1.html (renamed from toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe_page1.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe_page2.html (renamed from toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe_page2.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/file_with_about_blank.html (renamed from toolkit/components/extensions/test/mochitest/file_with_about_blank.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/head.js (renamed from toolkit/components/extensions/test/mochitest/head.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/head_cookies.js (renamed from toolkit/components/extensions/test/mochitest/head_cookies.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/head_webrequest.js (renamed from toolkit/components/extensions/test/mochitest/head_webrequest.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/mochitest.ini (renamed from toolkit/components/extensions/test/mochitest/mochitest.ini)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/redirection.sjs (renamed from toolkit/components/extensions/test/mochitest/redirection.sjs)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/return_headers.sjs (renamed from toolkit/components/extensions/test/mochitest/return_headers.sjs)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_debug_global.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_background_debug_global.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_background_page.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_downloads_saveAs.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_eventpage_warning.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_hybrid_addons.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_hybrid_addons.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_idle.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_shutdown_cleanup.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_shutdown_cleanup.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_storage_cleanup.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_storage_cleanup.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_trustworthy_origin.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_trustworthy_origin.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_webrequest_background_events.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_background_events.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_native_messaging_paths.html (renamed from toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_clipboard.html (renamed from toolkit/components/extensions/test/mochitest/test_clipboard.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_all_apis.js (renamed from toolkit/components/extensions/test/mochitest/test_ext_all_apis.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_background_api_injection.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_background_api_injection.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_background_canvas.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_background_generated_url.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_background_generated_url.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_background_teardown.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_background_teardown.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_content_security_policy.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_content_security_policy.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_about_blank.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_api_injection.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_api_injection.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_async_loading.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_async_loading.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_context.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_context.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_create_iframe.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_create_iframe.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_css.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_css.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_devtools_metadata.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_exporthelpers.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_incognito.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_incognito.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_permission.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript_teardown.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_contentscript_teardown.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_cookies.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_cookies.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_cookies_containers.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_cookies_expiry.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_cookies_permissions_bad.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_cookies_permissions_good.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_exclude_include_globs.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_generate.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_generate.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_geturl.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_geturl.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_i18n.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_i18n.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_i18n_css.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_inIncognitoContext_window.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_jsversion.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_jsversion.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_listener_proxies.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_notifications.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_notifications.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_permission_xhr.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect2.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect_twoway.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_runtime_disconnect.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_runtime_id.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_runtime_id.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_sandbox_var.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_schema.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_schema.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_doublereply.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_no_receiver.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply2.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_storage_content.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_storage_content.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_storage_tab.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_storage_tab.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_subframes_privileges.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_tab_teardown.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_tab_teardown.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_test.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_test.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_unload_frame.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_unload_frame.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_web_accessible_resources.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_webnavigation.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_webnavigation_filters.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_webrequest_background_events.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_webrequest_basic.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_webrequest_suspend.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_webrequest_suspend.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_webrequest_upload.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_window_postMessage.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_window_postMessage.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_xhr_capabilities.html (renamed from toolkit/components/extensions/test/mochitest/test_ext_xhr_capabilities.html)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/webrequest_chromeworker.js (renamed from toolkit/components/extensions/test/mochitest/webrequest_chromeworker.js)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/webrequest_test.jsm (renamed from toolkit/components/extensions/test/mochitest/webrequest_test.jsm)0
-rw-r--r--toolkit/components/webextensions/test/mochitest/webrequest_worker.js (renamed from toolkit/components/extensions/test/mochitest/webrequest_worker.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/.eslintrc.js (renamed from toolkit/components/extensions/test/xpcshell/.eslintrc.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/data/file_download.html (renamed from toolkit/components/extensions/test/xpcshell/data/file_download.html)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/data/file_download.txt (renamed from toolkit/components/extensions/test/xpcshell/data/file_download.txt)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/head.js (renamed from toolkit/components/extensions/test/xpcshell/head.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/head_native_messaging.js (renamed from toolkit/components/extensions/test/xpcshell/head_native_messaging.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/head_sync.js (renamed from toolkit/components/extensions/test/xpcshell/head_sync.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/native_messaging.ini (renamed from toolkit/components/extensions/test/xpcshell/native_messaging.ini)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_csp_custom_policies.js (renamed from toolkit/components/extensions/test/xpcshell/test_csp_custom_policies.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_csp_validator.js (renamed from toolkit/components/extensions/test/xpcshell/test_csp_validator.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_alarms.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_alarms.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_alarms_does_not_fire.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_alarms_does_not_fire.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_alarms_periodic.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_alarms_periodic.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_alarms_replaces.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_alarms_replaces.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_api_permissions.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_api_permissions.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_apimanager.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_apimanager.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_background_generated_load_events.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_background_generated_load_events.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_background_generated_reload.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_background_generated_reload.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_background_global_history.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_background_global_history.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_background_private_browsing.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_background_private_browsing.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_background_runtime_connect_params.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_background_runtime_connect_params.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_background_sub_windows.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_background_sub_windows.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_background_window_properties.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_background_window_properties.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_contexts.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_contexts.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_downloads.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_downloads_download.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_downloads_download.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_downloads_misc.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_downloads_misc.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_downloads_search.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_experiments.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_experiments.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_extension.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_extension.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_idle.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_idle.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_json_parser.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_json_parser.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_context.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_embedding.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_embedding.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_localStorage.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_localStorage.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_management.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_management.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_management_uninstall_self.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_management_uninstall_self.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_manifest_content_security_policy.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_manifest_content_security_policy.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_manifest_incognito.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_manifest_incognito.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_manifest_minimum_chrome_version.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_manifest_minimum_chrome_version.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging_perf.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_native_messaging_perf.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging_unresponsive.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_native_messaging_unresponsive.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_onmessage_removelistener.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_onmessage_removelistener.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_runtime_connect_no_receiver.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_runtime_connect_no_receiver.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_runtime_getPlatformInfo.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_runtime_getPlatformInfo.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_no_receiver.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_no_receiver.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_self.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_self.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_schemas.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_schemas.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_schemas_allowed_contexts.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_schemas_allowed_contexts.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_schemas_api_injection.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_schemas_async.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_simple.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_simple.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_storage.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_storage.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_topSites.js (renamed from toolkit/components/extensions/test/xpcshell/test_ext_topSites.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_getAPILevelForWindow.js (renamed from toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_locale_converter.js (renamed from toolkit/components/extensions/test/xpcshell/test_locale_converter.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_locale_data.js (renamed from toolkit/components/extensions/test/xpcshell/test_locale_data.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_native_messaging.js (renamed from toolkit/components/extensions/test/xpcshell/test_native_messaging.js)0
-rw-r--r--toolkit/components/webextensions/test/xpcshell/xpcshell.ini (renamed from toolkit/components/extensions/test/xpcshell/xpcshell.ini)0
-rw-r--r--toolkit/jetpack/app-extension/application.ini11
-rw-r--r--toolkit/jetpack/app-extension/bootstrap.js362
-rw-r--r--toolkit/jetpack/app-extension/install.rdf33
-rw-r--r--toolkit/jetpack/dev/debuggee.js95
-rw-r--r--toolkit/jetpack/dev/frame-script.js120
-rw-r--r--toolkit/jetpack/dev/panel.js259
-rw-r--r--toolkit/jetpack/dev/panel/view.js14
-rw-r--r--toolkit/jetpack/dev/ports.js64
-rw-r--r--toolkit/jetpack/dev/theme.js135
-rw-r--r--toolkit/jetpack/dev/theme/hooks.js17
-rw-r--r--toolkit/jetpack/dev/toolbox.js107
-rw-r--r--toolkit/jetpack/dev/utils.js40
-rw-r--r--toolkit/jetpack/dev/volcan.js3848
-rw-r--r--toolkit/jetpack/diffpatcher/.travis.yml5
-rw-r--r--toolkit/jetpack/diffpatcher/History.md14
-rw-r--r--toolkit/jetpack/diffpatcher/License.md18
-rw-r--r--toolkit/jetpack/diffpatcher/Readme.md70
-rw-r--r--toolkit/jetpack/diffpatcher/diff.js45
-rw-r--r--toolkit/jetpack/diffpatcher/index.js5
-rw-r--r--toolkit/jetpack/diffpatcher/package.json54
-rw-r--r--toolkit/jetpack/diffpatcher/patch.js21
-rw-r--r--toolkit/jetpack/diffpatcher/rebase.js36
-rw-r--r--toolkit/jetpack/diffpatcher/test/common.js3
-rw-r--r--toolkit/jetpack/diffpatcher/test/diff.js59
-rw-r--r--toolkit/jetpack/diffpatcher/test/index.js14
-rw-r--r--toolkit/jetpack/diffpatcher/test/patch.js83
-rw-r--r--toolkit/jetpack/diffpatcher/test/tap.js3
-rw-r--r--toolkit/jetpack/framescript/FrameScriptManager.jsm27
-rw-r--r--toolkit/jetpack/framescript/content.jsm94
-rw-r--r--toolkit/jetpack/framescript/context-menu.js215
-rw-r--r--toolkit/jetpack/framescript/manager.js26
-rw-r--r--toolkit/jetpack/framescript/util.js25
-rw-r--r--toolkit/jetpack/index.js3
-rw-r--r--toolkit/jetpack/jetpack-id/index.js53
-rw-r--r--toolkit/jetpack/jetpack-id/package.json28
-rw-r--r--toolkit/jetpack/method/.travis.yml5
-rw-r--r--toolkit/jetpack/method/History.md55
-rw-r--r--toolkit/jetpack/method/License.md18
-rw-r--r--toolkit/jetpack/method/Readme.md117
-rw-r--r--toolkit/jetpack/method/core.js225
-rw-r--r--toolkit/jetpack/method/package.json41
-rw-r--r--toolkit/jetpack/method/test/browser.js20
-rw-r--r--toolkit/jetpack/method/test/common.js272
-rw-r--r--toolkit/jetpack/modules/system/Startup.js57
-rw-r--r--toolkit/jetpack/modules/system/moz.build9
-rw-r--r--toolkit/jetpack/moz.build481
-rw-r--r--toolkit/jetpack/mozilla-toolkit-versioning/index.js112
-rw-r--r--toolkit/jetpack/mozilla-toolkit-versioning/lib/utils.js15
-rw-r--r--toolkit/jetpack/mozilla-toolkit-versioning/package.json21
-rw-r--r--toolkit/jetpack/node/os.js90
-rw-r--r--toolkit/jetpack/sdk/addon/bootstrap.js182
-rw-r--r--toolkit/jetpack/sdk/addon/events.js56
-rw-r--r--toolkit/jetpack/sdk/addon/host.js12
-rw-r--r--toolkit/jetpack/sdk/addon/installer.js121
-rw-r--r--toolkit/jetpack/sdk/addon/manager.js18
-rw-r--r--toolkit/jetpack/sdk/addon/runner.js180
-rw-r--r--toolkit/jetpack/sdk/addon/window.js66
-rw-r--r--toolkit/jetpack/sdk/base64.js47
-rw-r--r--toolkit/jetpack/sdk/browser/events.js20
-rw-r--r--toolkit/jetpack/sdk/clipboard.js337
-rw-r--r--toolkit/jetpack/sdk/console/plain-text.js78
-rw-r--r--toolkit/jetpack/sdk/console/traceback.js86
-rw-r--r--toolkit/jetpack/sdk/content/content-worker.js305
-rw-r--r--toolkit/jetpack/sdk/content/content.js17
-rw-r--r--toolkit/jetpack/sdk/content/context-menu.js408
-rw-r--r--toolkit/jetpack/sdk/content/events.js57
-rw-r--r--toolkit/jetpack/sdk/content/l10n-html.js133
-rw-r--r--toolkit/jetpack/sdk/content/loader.js74
-rw-r--r--toolkit/jetpack/sdk/content/mod.js68
-rw-r--r--toolkit/jetpack/sdk/content/page-mod.js236
-rw-r--r--toolkit/jetpack/sdk/content/page-worker.js154
-rw-r--r--toolkit/jetpack/sdk/content/sandbox.js426
-rw-r--r--toolkit/jetpack/sdk/content/sandbox/events.js12
-rw-r--r--toolkit/jetpack/sdk/content/tab-events.js58
-rw-r--r--toolkit/jetpack/sdk/content/thumbnail.js51
-rw-r--r--toolkit/jetpack/sdk/content/utils.js105
-rw-r--r--toolkit/jetpack/sdk/content/worker-child.js158
-rw-r--r--toolkit/jetpack/sdk/content/worker.js180
-rw-r--r--toolkit/jetpack/sdk/context-menu.js1188
-rw-r--r--toolkit/jetpack/sdk/context-menu/context.js147
-rw-r--r--toolkit/jetpack/sdk/context-menu/core.js384
-rw-r--r--toolkit/jetpack/sdk/context-menu/readers.js112
-rw-r--r--toolkit/jetpack/sdk/context-menu@2.js32
-rw-r--r--toolkit/jetpack/sdk/core/disposable.js186
-rw-r--r--toolkit/jetpack/sdk/core/heritage.js184
-rw-r--r--toolkit/jetpack/sdk/core/namespace.js43
-rw-r--r--toolkit/jetpack/sdk/core/observer.js89
-rw-r--r--toolkit/jetpack/sdk/core/promise.js118
-rw-r--r--toolkit/jetpack/sdk/core/reference.js29
-rw-r--r--toolkit/jetpack/sdk/deprecated/api-utils.js197
-rw-r--r--toolkit/jetpack/sdk/deprecated/events/assembler.js54
-rw-r--r--toolkit/jetpack/sdk/deprecated/sync-worker.js288
-rw-r--r--toolkit/jetpack/sdk/deprecated/unit-test-finder.js199
-rw-r--r--toolkit/jetpack/sdk/deprecated/unit-test.js584
-rw-r--r--toolkit/jetpack/sdk/deprecated/window-utils.js193
-rw-r--r--toolkit/jetpack/sdk/dom/events-shimmed.js18
-rw-r--r--toolkit/jetpack/sdk/dom/events.js192
-rw-r--r--toolkit/jetpack/sdk/dom/events/keys.js63
-rw-r--r--toolkit/jetpack/sdk/event/chrome.js65
-rw-r--r--toolkit/jetpack/sdk/event/core.js193
-rw-r--r--toolkit/jetpack/sdk/event/dom.js78
-rw-r--r--toolkit/jetpack/sdk/event/target.js74
-rw-r--r--toolkit/jetpack/sdk/event/utils.js328
-rw-r--r--toolkit/jetpack/sdk/frame/hidden-frame.js115
-rw-r--r--toolkit/jetpack/sdk/frame/utils.js94
-rw-r--r--toolkit/jetpack/sdk/fs/path.js500
-rw-r--r--toolkit/jetpack/sdk/hotkeys.js40
-rw-r--r--toolkit/jetpack/sdk/indexed-db.js79
-rw-r--r--toolkit/jetpack/sdk/input/browser.js73
-rw-r--r--toolkit/jetpack/sdk/input/customizable-ui.js28
-rw-r--r--toolkit/jetpack/sdk/input/frame.js85
-rw-r--r--toolkit/jetpack/sdk/input/system.js113
-rw-r--r--toolkit/jetpack/sdk/io/buffer.js351
-rw-r--r--toolkit/jetpack/sdk/io/byte-streams.js104
-rw-r--r--toolkit/jetpack/sdk/io/file.js196
-rw-r--r--toolkit/jetpack/sdk/io/fs.js984
-rw-r--r--toolkit/jetpack/sdk/io/stream.js440
-rw-r--r--toolkit/jetpack/sdk/io/text-streams.js235
-rw-r--r--toolkit/jetpack/sdk/keyboard/hotkeys.js110
-rw-r--r--toolkit/jetpack/sdk/keyboard/observer.js58
-rw-r--r--toolkit/jetpack/sdk/keyboard/utils.js189
-rw-r--r--toolkit/jetpack/sdk/l10n.js91
-rw-r--r--toolkit/jetpack/sdk/l10n/core.js9
-rw-r--r--toolkit/jetpack/sdk/l10n/html.js32
-rw-r--r--toolkit/jetpack/sdk/l10n/json/core.js36
-rw-r--r--toolkit/jetpack/sdk/l10n/loader.js70
-rw-r--r--toolkit/jetpack/sdk/l10n/locale.js127
-rw-r--r--toolkit/jetpack/sdk/l10n/plural-rules.js407
-rw-r--r--toolkit/jetpack/sdk/l10n/prefs.js51
-rw-r--r--toolkit/jetpack/sdk/l10n/properties/core.js87
-rw-r--r--toolkit/jetpack/sdk/lang/functional.js47
-rw-r--r--toolkit/jetpack/sdk/lang/functional/concurrent.js110
-rw-r--r--toolkit/jetpack/sdk/lang/functional/core.js290
-rw-r--r--toolkit/jetpack/sdk/lang/functional/helpers.js29
-rw-r--r--toolkit/jetpack/sdk/lang/type.js388
-rw-r--r--toolkit/jetpack/sdk/lang/weak-set.js75
-rw-r--r--toolkit/jetpack/sdk/loader/cuddlefish.js102
-rw-r--r--toolkit/jetpack/sdk/loader/sandbox.js74
-rw-r--r--toolkit/jetpack/sdk/messaging.js12
-rw-r--r--toolkit/jetpack/sdk/model/core.js23
-rw-r--r--toolkit/jetpack/sdk/net/url.js94
-rw-r--r--toolkit/jetpack/sdk/net/xhr.js36
-rw-r--r--toolkit/jetpack/sdk/notifications.js112
-rw-r--r--toolkit/jetpack/sdk/output/system.js71
-rw-r--r--toolkit/jetpack/sdk/page-mod.js190
-rw-r--r--toolkit/jetpack/sdk/page-mod/match-pattern.js10
-rw-r--r--toolkit/jetpack/sdk/page-worker.js194
-rw-r--r--toolkit/jetpack/sdk/panel.js427
-rw-r--r--toolkit/jetpack/sdk/panel/events.js27
-rw-r--r--toolkit/jetpack/sdk/panel/utils.js451
-rw-r--r--toolkit/jetpack/sdk/passwords.js61
-rw-r--r--toolkit/jetpack/sdk/passwords/utils.js107
-rw-r--r--toolkit/jetpack/sdk/places/bookmarks.js395
-rw-r--r--toolkit/jetpack/sdk/places/contract.js73
-rw-r--r--toolkit/jetpack/sdk/places/events.js128
-rw-r--r--toolkit/jetpack/sdk/places/favicon.js49
-rw-r--r--toolkit/jetpack/sdk/places/history.js65
-rw-r--r--toolkit/jetpack/sdk/places/host/host-bookmarks.js238
-rw-r--r--toolkit/jetpack/sdk/places/host/host-query.js179
-rw-r--r--toolkit/jetpack/sdk/places/host/host-tags.js92
-rw-r--r--toolkit/jetpack/sdk/places/utils.js268
-rw-r--r--toolkit/jetpack/sdk/platform/xpcom.js241
-rw-r--r--toolkit/jetpack/sdk/preferences/event-target.js61
-rw-r--r--toolkit/jetpack/sdk/preferences/native-options.js193
-rw-r--r--toolkit/jetpack/sdk/preferences/service.js137
-rw-r--r--toolkit/jetpack/sdk/preferences/utils.js42
-rw-r--r--toolkit/jetpack/sdk/private-browsing.js12
-rw-r--r--toolkit/jetpack/sdk/private-browsing/utils.js54
-rw-r--r--toolkit/jetpack/sdk/querystring.js121
-rw-r--r--toolkit/jetpack/sdk/remote/child.js284
-rw-r--r--toolkit/jetpack/sdk/remote/core.js8
-rw-r--r--toolkit/jetpack/sdk/remote/parent.js338
-rw-r--r--toolkit/jetpack/sdk/remote/utils.js39
-rw-r--r--toolkit/jetpack/sdk/request.js248
-rw-r--r--toolkit/jetpack/sdk/selection.js470
-rw-r--r--toolkit/jetpack/sdk/self.js61
-rw-r--r--toolkit/jetpack/sdk/simple-prefs.js26
-rw-r--r--toolkit/jetpack/sdk/simple-storage.js235
-rw-r--r--toolkit/jetpack/sdk/stylesheet/style.js71
-rw-r--r--toolkit/jetpack/sdk/stylesheet/utils.js75
-rw-r--r--toolkit/jetpack/sdk/system.js172
-rw-r--r--toolkit/jetpack/sdk/system/child_process.js332
-rw-r--r--toolkit/jetpack/sdk/system/child_process/subprocess.js186
-rw-r--r--toolkit/jetpack/sdk/system/environment.js33
-rw-r--r--toolkit/jetpack/sdk/system/events-shimmed.js16
-rw-r--r--toolkit/jetpack/sdk/system/events.js181
-rw-r--r--toolkit/jetpack/sdk/system/globals.js46
-rw-r--r--toolkit/jetpack/sdk/system/process.js62
-rw-r--r--toolkit/jetpack/sdk/system/runtime.js28
-rw-r--r--toolkit/jetpack/sdk/system/unload.js104
-rw-r--r--toolkit/jetpack/sdk/system/xul-app.js12
-rw-r--r--toolkit/jetpack/sdk/system/xul-app.jsm242
-rw-r--r--toolkit/jetpack/sdk/tab/events.js74
-rw-r--r--toolkit/jetpack/sdk/tabs.js17
-rw-r--r--toolkit/jetpack/sdk/tabs/common.js34
-rw-r--r--toolkit/jetpack/sdk/tabs/events.js39
-rw-r--r--toolkit/jetpack/sdk/tabs/helpers.js22
-rw-r--r--toolkit/jetpack/sdk/tabs/namespace.js10
-rw-r--r--toolkit/jetpack/sdk/tabs/observer.js113
-rw-r--r--toolkit/jetpack/sdk/tabs/tab-fennec.js249
-rw-r--r--toolkit/jetpack/sdk/tabs/tab-firefox.js353
-rw-r--r--toolkit/jetpack/sdk/tabs/tab.js24
-rw-r--r--toolkit/jetpack/sdk/tabs/tabs-firefox.js135
-rw-r--r--toolkit/jetpack/sdk/tabs/utils.js370
-rw-r--r--toolkit/jetpack/sdk/tabs/worker.js17
-rw-r--r--toolkit/jetpack/sdk/test.js114
-rw-r--r--toolkit/jetpack/sdk/test/assert.js366
-rw-r--r--toolkit/jetpack/sdk/test/harness.js645
-rw-r--r--toolkit/jetpack/sdk/test/httpd.js6
-rw-r--r--toolkit/jetpack/sdk/test/loader.js123
-rw-r--r--toolkit/jetpack/sdk/test/memory.js11
-rw-r--r--toolkit/jetpack/sdk/test/options.js23
-rw-r--r--toolkit/jetpack/sdk/test/runner.js131
-rw-r--r--toolkit/jetpack/sdk/test/utils.js199
-rw-r--r--toolkit/jetpack/sdk/timers.js105
-rw-r--r--toolkit/jetpack/sdk/ui.js17
-rw-r--r--toolkit/jetpack/sdk/ui/button/action.js114
-rw-r--r--toolkit/jetpack/sdk/ui/button/contract.js73
-rw-r--r--toolkit/jetpack/sdk/ui/button/toggle.js127
-rw-r--r--toolkit/jetpack/sdk/ui/button/view.js243
-rw-r--r--toolkit/jetpack/sdk/ui/button/view/events.js18
-rw-r--r--toolkit/jetpack/sdk/ui/component.js182
-rw-r--r--toolkit/jetpack/sdk/ui/frame.js16
-rw-r--r--toolkit/jetpack/sdk/ui/frame/model.js154
-rw-r--r--toolkit/jetpack/sdk/ui/frame/view.html18
-rw-r--r--toolkit/jetpack/sdk/ui/frame/view.js150
-rw-r--r--toolkit/jetpack/sdk/ui/id.js27
-rw-r--r--toolkit/jetpack/sdk/ui/sidebar.js311
-rw-r--r--toolkit/jetpack/sdk/ui/sidebar/actions.js10
-rw-r--r--toolkit/jetpack/sdk/ui/sidebar/contract.js27
-rw-r--r--toolkit/jetpack/sdk/ui/sidebar/namespace.js15
-rw-r--r--toolkit/jetpack/sdk/ui/sidebar/utils.js8
-rw-r--r--toolkit/jetpack/sdk/ui/sidebar/view.js214
-rw-r--r--toolkit/jetpack/sdk/ui/state.js239
-rw-r--r--toolkit/jetpack/sdk/ui/state/events.js18
-rw-r--r--toolkit/jetpack/sdk/ui/toolbar.js16
-rw-r--r--toolkit/jetpack/sdk/ui/toolbar/model.js151
-rw-r--r--toolkit/jetpack/sdk/ui/toolbar/view.js248
-rw-r--r--toolkit/jetpack/sdk/uri/resource.js37
-rw-r--r--toolkit/jetpack/sdk/url.js349
-rw-r--r--toolkit/jetpack/sdk/url/utils.js29
-rw-r--r--toolkit/jetpack/sdk/util/array.js123
-rw-r--r--toolkit/jetpack/sdk/util/collection.js115
-rw-r--r--toolkit/jetpack/sdk/util/contract.js55
-rw-r--r--toolkit/jetpack/sdk/util/deprecate.js40
-rw-r--r--toolkit/jetpack/sdk/util/dispatcher.js54
-rw-r--r--toolkit/jetpack/sdk/util/list.js90
-rw-r--r--toolkit/jetpack/sdk/util/match-pattern.js113
-rw-r--r--toolkit/jetpack/sdk/util/object.js104
-rw-r--r--toolkit/jetpack/sdk/util/rules.js53
-rw-r--r--toolkit/jetpack/sdk/util/sequence.js593
-rw-r--r--toolkit/jetpack/sdk/util/uuid.js19
-rw-r--r--toolkit/jetpack/sdk/view/core.js26
-rw-r--r--toolkit/jetpack/sdk/webextension.js43
-rw-r--r--toolkit/jetpack/sdk/window/browser.js54
-rw-r--r--toolkit/jetpack/sdk/window/events.js68
-rw-r--r--toolkit/jetpack/sdk/window/helpers.js81
-rw-r--r--toolkit/jetpack/sdk/window/namespace.js6
-rw-r--r--toolkit/jetpack/sdk/window/utils.js460
-rw-r--r--toolkit/jetpack/sdk/windows.js32
-rw-r--r--toolkit/jetpack/sdk/windows/fennec.js83
-rw-r--r--toolkit/jetpack/sdk/windows/firefox.js224
-rw-r--r--toolkit/jetpack/sdk/windows/observer.js53
-rw-r--r--toolkit/jetpack/sdk/windows/tabs-fennec.js172
-rw-r--r--toolkit/jetpack/sdk/worker/utils.js19
-rw-r--r--toolkit/jetpack/sdk/zip/utils.js16
-rw-r--r--toolkit/jetpack/test.js11
-rw-r--r--toolkit/jetpack/toolkit/loader.js1147
-rw-r--r--toolkit/jetpack/toolkit/require.js91
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/about.dtd (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/about.dtd)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/blocklist.dtd (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/blocklist.dtd)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/extensions.dtd (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/extensions.properties (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/extensions.properties)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/newaddon.dtd (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/newaddon.dtd)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/newaddon.properties (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/newaddon.properties)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/update.dtd (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/update.dtd)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/update.properties (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/update.properties)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/xpinstallConfirm.dtd (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/xpinstallConfirm.dtd)0
-rw-r--r--toolkit/locales/en-US/chrome/mozapps/webextensions/xpinstallConfirm.properties (renamed from toolkit/locales/en-US/chrome/mozapps/extensions/xpinstallConfirm.properties)0
-rw-r--r--toolkit/locales/jar.mn24
-rw-r--r--toolkit/moz.build5
-rw-r--r--toolkit/mozapps/webextensions/.eslintrc.js (renamed from toolkit/mozapps/extensions/.eslintrc.js)0
-rw-r--r--toolkit/mozapps/webextensions/AddonContentPolicy.cpp (renamed from toolkit/mozapps/extensions/AddonContentPolicy.cpp)0
-rw-r--r--toolkit/mozapps/webextensions/AddonContentPolicy.h (renamed from toolkit/mozapps/extensions/AddonContentPolicy.h)0
-rw-r--r--toolkit/mozapps/webextensions/AddonManager.jsm (renamed from toolkit/mozapps/extensions/AddonManager.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/AddonManagerWebAPI.cpp (renamed from toolkit/mozapps/extensions/AddonManagerWebAPI.cpp)0
-rw-r--r--toolkit/mozapps/webextensions/AddonManagerWebAPI.h (renamed from toolkit/mozapps/extensions/AddonManagerWebAPI.h)0
-rw-r--r--toolkit/mozapps/webextensions/AddonPathService.cpp (renamed from toolkit/mozapps/extensions/AddonPathService.cpp)0
-rw-r--r--toolkit/mozapps/webextensions/AddonPathService.h (renamed from toolkit/mozapps/extensions/AddonPathService.h)0
-rw-r--r--toolkit/mozapps/webextensions/ChromeManifestParser.jsm (renamed from toolkit/mozapps/extensions/ChromeManifestParser.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/DeferredSave.jsm (renamed from toolkit/mozapps/extensions/DeferredSave.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/LightweightThemeManager.jsm (renamed from toolkit/mozapps/extensions/LightweightThemeManager.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/addonManager.js (renamed from toolkit/mozapps/extensions/addonManager.js)0
-rw-r--r--toolkit/mozapps/webextensions/amContentHandler.js (renamed from toolkit/mozapps/extensions/amContentHandler.js)0
-rw-r--r--toolkit/mozapps/webextensions/amIAddonManager.idl (renamed from toolkit/mozapps/extensions/amIAddonManager.idl)0
-rw-r--r--toolkit/mozapps/webextensions/amIAddonPathService.idl (renamed from toolkit/mozapps/extensions/amIAddonPathService.idl)0
-rw-r--r--toolkit/mozapps/webextensions/amIWebInstallListener.idl (renamed from toolkit/mozapps/extensions/amIWebInstallListener.idl)0
-rw-r--r--toolkit/mozapps/webextensions/amIWebInstaller.idl (renamed from toolkit/mozapps/extensions/amIWebInstaller.idl)0
-rw-r--r--toolkit/mozapps/webextensions/amInstallTrigger.js (renamed from toolkit/mozapps/extensions/amInstallTrigger.js)0
-rw-r--r--toolkit/mozapps/webextensions/amWebAPI.js (renamed from toolkit/mozapps/extensions/amWebAPI.js)0
-rw-r--r--toolkit/mozapps/webextensions/amWebInstallListener.js (renamed from toolkit/mozapps/extensions/amWebInstallListener.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/OpenH264-license.txt (renamed from toolkit/mozapps/extensions/content/OpenH264-license.txt)0
-rw-r--r--toolkit/mozapps/webextensions/content/about.js (renamed from toolkit/mozapps/extensions/content/about.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/about.xul (renamed from toolkit/mozapps/extensions/content/about.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/blocklist.css (renamed from toolkit/mozapps/extensions/content/blocklist.css)0
-rw-r--r--toolkit/mozapps/webextensions/content/blocklist.js (renamed from toolkit/mozapps/extensions/content/blocklist.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/blocklist.xml (renamed from toolkit/mozapps/extensions/content/blocklist.xml)0
-rw-r--r--toolkit/mozapps/webextensions/content/blocklist.xul (renamed from toolkit/mozapps/extensions/content/blocklist.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/eula.js (renamed from toolkit/mozapps/extensions/content/eula.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/eula.xul (renamed from toolkit/mozapps/extensions/content/eula.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/extensions.css (renamed from toolkit/mozapps/extensions/content/extensions.css)0
-rw-r--r--toolkit/mozapps/webextensions/content/extensions.js (renamed from toolkit/mozapps/extensions/content/extensions.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/extensions.xml (renamed from toolkit/mozapps/extensions/content/extensions.xml)0
-rw-r--r--toolkit/mozapps/webextensions/content/extensions.xul (renamed from toolkit/mozapps/extensions/content/extensions.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/gmpPrefs.xul (renamed from toolkit/mozapps/extensions/content/gmpPrefs.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/list.js (renamed from toolkit/mozapps/extensions/content/list.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/list.xul (renamed from toolkit/mozapps/extensions/content/list.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/newaddon.js (renamed from toolkit/mozapps/extensions/content/newaddon.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/newaddon.xul (renamed from toolkit/mozapps/extensions/content/newaddon.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/pluginPrefs.xul (renamed from toolkit/mozapps/extensions/content/pluginPrefs.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/setting.xml (renamed from toolkit/mozapps/extensions/content/setting.xml)0
-rw-r--r--toolkit/mozapps/webextensions/content/update.js (renamed from toolkit/mozapps/extensions/content/update.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/update.xul (renamed from toolkit/mozapps/extensions/content/update.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/updateinfo.xsl (renamed from toolkit/mozapps/extensions/content/updateinfo.xsl)0
-rw-r--r--toolkit/mozapps/webextensions/content/xpinstallConfirm.css (renamed from toolkit/mozapps/extensions/content/xpinstallConfirm.css)0
-rw-r--r--toolkit/mozapps/webextensions/content/xpinstallConfirm.js (renamed from toolkit/mozapps/extensions/content/xpinstallConfirm.js)0
-rw-r--r--toolkit/mozapps/webextensions/content/xpinstallConfirm.xul (renamed from toolkit/mozapps/extensions/content/xpinstallConfirm.xul)0
-rw-r--r--toolkit/mozapps/webextensions/content/xpinstallItem.xml (renamed from toolkit/mozapps/extensions/content/xpinstallItem.xml)0
-rw-r--r--toolkit/mozapps/webextensions/docs/SystemAddons.rst (renamed from toolkit/mozapps/extensions/docs/SystemAddons.rst)0
-rw-r--r--toolkit/mozapps/webextensions/docs/index.rst (renamed from toolkit/mozapps/extensions/docs/index.rst)0
-rw-r--r--toolkit/mozapps/webextensions/extensions.manifest (renamed from toolkit/mozapps/extensions/extensions.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/internal/APIExtensionBootstrap.js (renamed from toolkit/mozapps/extensions/internal/APIExtensionBootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/internal/AddonConstants.jsm (renamed from toolkit/mozapps/extensions/internal/AddonConstants.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/AddonLogging.jsm (renamed from toolkit/mozapps/extensions/internal/AddonLogging.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/AddonRepository.jsm (renamed from toolkit/mozapps/extensions/internal/AddonRepository.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/AddonRepository_SQLiteMigrator.jsm (renamed from toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/AddonTestUtils.jsm (renamed from toolkit/mozapps/extensions/internal/AddonTestUtils.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/AddonUpdateChecker.jsm (renamed from toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/Content.js (renamed from toolkit/mozapps/extensions/internal/Content.js)0
-rw-r--r--toolkit/mozapps/webextensions/internal/E10SAddonsRollout.jsm (renamed from toolkit/mozapps/extensions/internal/E10SAddonsRollout.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/GMPProvider.jsm (renamed from toolkit/mozapps/extensions/internal/GMPProvider.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/LightweightThemeImageOptimizer.jsm (renamed from toolkit/mozapps/extensions/internal/LightweightThemeImageOptimizer.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/PluginProvider.jsm (renamed from toolkit/mozapps/extensions/internal/PluginProvider.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/ProductAddonChecker.jsm (renamed from toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/SpellCheckDictionaryBootstrap.js (renamed from toolkit/mozapps/extensions/internal/SpellCheckDictionaryBootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/internal/WebExtensionBootstrap.js (renamed from toolkit/mozapps/extensions/internal/WebExtensionBootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/internal/XPIProvider.jsm (renamed from toolkit/mozapps/extensions/internal/XPIProvider.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/internal/XPIProviderUtils.js (renamed from toolkit/mozapps/extensions/internal/XPIProviderUtils.js)0
-rw-r--r--toolkit/mozapps/webextensions/internal/moz.build (renamed from toolkit/mozapps/extensions/internal/moz.build)0
-rw-r--r--toolkit/mozapps/webextensions/jar.mn (renamed from toolkit/mozapps/extensions/jar.mn)0
-rw-r--r--toolkit/mozapps/webextensions/moz.build (renamed from toolkit/mozapps/extensions/moz.build)0
-rw-r--r--toolkit/mozapps/webextensions/nsBlocklistService.js (renamed from toolkit/mozapps/extensions/nsBlocklistService.js)0
-rw-r--r--toolkit/mozapps/webextensions/nsBlocklistServiceContent.js (renamed from toolkit/mozapps/extensions/nsBlocklistServiceContent.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/AddonManagerTesting.jsm (renamed from toolkit/mozapps/extensions/test/AddonManagerTesting.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/test/Makefile.in (renamed from toolkit/mozapps/extensions/test/Makefile.in)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_hard1_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_hard1_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_hard1_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_hard1_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_hard1_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_hard1_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_regexp1_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_regexp1_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_regexp1_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft1_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft1_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft1_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft1_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft1_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft1_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft2_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft2_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft2_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft2_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft2_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft2_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft3_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft3_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft3_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft3_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft3_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft3_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft4_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft4_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft4_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft4_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft4_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft4_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft5_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft5_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft5_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft5_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/blocklist_soft5_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/blocklist_soft5_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/bootstrap_globals/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/bootstrap_globals/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/bootstrap_globals/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/bootstrap_globals/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/min1max1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/min1max1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/min1max2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/min1max2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/min1max3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/min1max3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/min1max3b/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/min1max3b/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/override1x2-1x3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/override1x2-1x3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_AddonRepository_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_AddonRepository_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_AddonRepository_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_AddonRepository_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/icon.png (renamed from toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/icon.png)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/preview.png (renamed from toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/preview.png)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/version.jsm (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/version.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/version.jsm (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/version.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/version.jsm (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/version.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap1_4/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap1_4/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap2_1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap2_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap_const/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap_const/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bootstrap_const/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bootstrap_const/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_a_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_a_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_a_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_a_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_b_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_b_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_b_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_b_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_c_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_c_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_c_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_c_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_d_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_d_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_d_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_d_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_e_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_e_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_e_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_e_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_f_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_f_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_f_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_f_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_g_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_g_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug299716_g_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug299716_g_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_4/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_4/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_5/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_5/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_6/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_6/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_7/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_7/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_8/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_8/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug324121_9/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug324121_9/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug335238_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug335238_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug335238_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug335238_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug335238_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug335238_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug335238_4/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug335238_4/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug371495/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug371495/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug394300_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug394300_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug394300_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug394300_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug397778/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug397778/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug425657/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug425657/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug470377_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug470377_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug470377_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug470377_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug470377_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug470377_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug470377_4/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug470377_4/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug470377_5/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug470377_5/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug521905/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug521905/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug567173/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug567173/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug567184/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bug567184/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug567184/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug567184/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug587088_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug587088_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug587088_1/testfile (renamed from toolkit/mozapps/extensions/test/addons/test_bug587088_1/testfile)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug587088_1/testfile1 (renamed from toolkit/mozapps/extensions/test/addons/test_bug587088_1/testfile1)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug587088_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug587088_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug587088_2/testfile (renamed from toolkit/mozapps/extensions/test/addons/test_bug587088_2/testfile)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug587088_2/testfile2 (renamed from toolkit/mozapps/extensions/test/addons/test_bug587088_2/testfile2)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug594058/directory/file1 (renamed from toolkit/mozapps/extensions/test/addons/test_bug594058/directory/file1)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug594058/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug594058/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug595573/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug595573/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug655254/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug655254_2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bug655254_2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug655254_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug655254_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug659772/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug659772/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug675371/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_bug675371/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug675371/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug675371/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug675371/test.js (renamed from toolkit/mozapps/extensions/test/addons/test_bug675371/test.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug740612_1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bug740612_1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug740612_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug740612_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug740612_2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_bug740612_2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug740612_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug740612_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_bug757663/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_bug757663/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_cacheflush1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_cacheflush1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_cacheflush2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_cacheflush2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_1/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_1/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_2/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_2/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/inner.jar (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/inner.jar)bin180 -> 180 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/components/components.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/components/components.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/components/other/something.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/components/other/something.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_5/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_5/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_5/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_5/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_6/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_6/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_chromemanifest_6/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_chromemanifest_6/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_data_directory/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_data_directory/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_db_sanity_1_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_db_sanity_1_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_db_sanity_1_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_db_sanity_1_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_v2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_complete_v2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_v2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_complete_v2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_webextension_v2/manifest.json (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_complete_webextension_v2/manifest.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_v2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_defer_v2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_v2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_defer_v2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_webextension_v2/manifest.json (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_defer_webextension_v2/manifest.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_v2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_v2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_v2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_v2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_webextension_v2/manifest.json (renamed from toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_webextension_v2/manifest.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_dictionary/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_dictionary/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_dictionary/dictionaries/ab-CD.dic (renamed from toolkit/mozapps/extensions/test/addons/test_dictionary/dictionaries/ab-CD.dic)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_dictionary/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_dictionary/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_dictionary_2/dictionaries/ab-CD.dic (renamed from toolkit/mozapps/extensions/test/addons/test_dictionary_2/dictionaries/ab-CD.dic)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_dictionary_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_dictionary_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_dictionary_3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_dictionary_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_dictionary_4/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_dictionary_4/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_dictionary_5/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_dictionary_5/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_distribution1_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_distribution1_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_experiment1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_experiment1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_experiment1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_experiment1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_filepointer/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_filepointer/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_getresource/icon.png (renamed from toolkit/mozapps/extensions/test/addons/test_getresource/icon.png)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_getresource/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_getresource/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_getresource/subdir/subfile.txt (renamed from toolkit/mozapps/extensions/test/addons/test_getresource/subdir/subfile.txt)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_hotfix_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_hotfix_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_hotfix_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_hotfix_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install1/icon.png (renamed from toolkit/mozapps/extensions/test/addons/test_install1/icon.png)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install1/icon64.png (renamed from toolkit/mozapps/extensions/test/addons/test_install1/icon64.png)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install2_1/icon.png (renamed from toolkit/mozapps/extensions/test/addons/test_install2_1/icon.png)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install2_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install2_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install2_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install2_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install3/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install4/addon4.xpi (renamed from toolkit/mozapps/extensions/test/addons/test_install4/addon4.xpi)bin509 -> 509 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install4/addon5.jar (renamed from toolkit/mozapps/extensions/test/addons/test_install4/addon5.jar)bin512 -> 512 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install4/addon6.xpi (renamed from toolkit/mozapps/extensions/test/addons/test_install4/addon6.xpi)bin512 -> 512 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install4/addon7.jar (renamed from toolkit/mozapps/extensions/test/addons/test_install4/addon7.jar)bin512 -> 512 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install4/badaddon.jar (renamed from toolkit/mozapps/extensions/test/addons/test_install4/badaddon.jar)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install4/badaddon.xpi (renamed from toolkit/mozapps/extensions/test/addons/test_install4/badaddon.xpi)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install4/icon.png (renamed from toolkit/mozapps/extensions/test/addons/test_install4/icon.png)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install4/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install4/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install5/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_install5/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install5/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install5/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install6/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install6/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install7/addon1.xpi (renamed from toolkit/mozapps/extensions/test/addons/test_install7/addon1.xpi)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install7/addon2.xpi (renamed from toolkit/mozapps/extensions/test/addons/test_install7/addon2.xpi)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install7/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install7/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_install8/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_install8/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_jetpack/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_jetpack/harness-options.json (renamed from toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_jetpack/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_langpack/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_langpack/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_langpack/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_langpack/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_locale/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_locale/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_locked2_5/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_locked2_5/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_locked2_6/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_locked2_6/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_migrate4_6/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_migrate4_6/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_migrate4_7/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_migrate4_7/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_migrate6/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_migrate6/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_migrate7/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_migrate7/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_migrate8/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/test_migrate8/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_migrate8/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_migrate8/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_migrate9/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_migrate9/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_symbol/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_symbol/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_symbol/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_symbol/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_theme/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_theme/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_theme/preview.png (renamed from toolkit/mozapps/extensions/test/addons/test_theme/preview.png)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_undoincompatible/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_undoincompatible/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_undoincompatible/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_undoincompatible/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_undouninstall1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_undouninstall1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_undouninstall1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_undouninstall1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_update/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_update/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_update12/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_update12/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_update8/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_update8/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_update_multi1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_update_multi1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_update_multi2/addon.xpi (renamed from toolkit/mozapps/extensions/test/addons/test_update_multi2/addon.xpi)bin693 -> 693 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_update_multi2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_updateid1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_updateid1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_updateid2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/test_updateid2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/upgradeable1x2-3_1/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/upgradeable1x2-3_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/upgradeable1x2-3_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/upgradeable1x2-3_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/webextension_1/chrome.manifest (renamed from toolkit/mozapps/extensions/test/addons/webextension_1/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/webextension_1/manifest.json (renamed from toolkit/mozapps/extensions/test/addons/webextension_1/manifest.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/webextension_2/install.rdf (renamed from toolkit/mozapps/extensions/test/addons/webextension_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/webextension_2/manifest.json (renamed from toolkit/mozapps/extensions/test/addons/webextension_2/manifest.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/webextension_3/_locales/en/messages.json (renamed from toolkit/mozapps/extensions/test/addons/webextension_3/_locales/en/messages.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/webextension_3/_locales/fr/messages.json (renamed from toolkit/mozapps/extensions/test/addons/webextension_3/_locales/fr/messages.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/addons/webextension_3/manifest.json (renamed from toolkit/mozapps/extensions/test/addons/webextension_3/manifest.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/.eslintrc.js (renamed from toolkit/mozapps/extensions/test/browser/.eslintrc.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addon_about.xul (renamed from toolkit/mozapps/extensions/test/browser/addon_about.xul)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addon_prefs.xul (renamed from toolkit/mozapps/extensions/test/browser/addon_prefs.xul)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_1.xpi)bin4426 -> 4426 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_10.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_10.xpi)bin4425 -> 4425 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_10/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_10/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_2.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_2.xpi)bin4427 -> 4427 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_2/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_3.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_3.xpi)bin4425 -> 4425 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_3/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_3/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_4.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_4.xpi)bin4432 -> 4432 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_4/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_4/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_5.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_5.xpi)bin4427 -> 4427 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_5/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_5/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_6.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_6.xpi)bin4424 -> 4424 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_6/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_6/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_7.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_7.xpi)bin4424 -> 4424 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_7/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_7/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_8_1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_8_1.xpi)bin4427 -> 4427 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_8_1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_8_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_9_1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_9_1.xpi)bin4421 -> 4421 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_9_1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_9_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_1.xpi)bin4425 -> 4425 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_2.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_2.xpi)bin4427 -> 4427 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_2/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_1.xpi)bin4449 -> 4449 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_2.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_2.xpi)bin4440 -> 4440 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_2/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop1.xpi)bin4424 -> 4424 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop2.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop2.xpi)bin4420 -> 4420 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop2/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_experiment1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_experiment1.xpi)bin4328 -> 4328 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_experiment1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_experiment1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1.xpi)bin5811 -> 5811 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/chrome.manifest (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/options.xul (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/options.xul)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/settings.dtd (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/settings.dtd)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom.xpi)bin6155 -> 6155 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/binding.xml (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/binding.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/bootstrap.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/chrome.manifest (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/options.xul (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/options.xul)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/string.dtd (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/string.dtd)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info.xpi)bin5279 -> 5279 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/bootstrap.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/options.xul (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/options.xul)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_install1_1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_install1_1.xpi)bin4489 -> 4489 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_install1_1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_install1_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_install1_2.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_install1_2.xpi)bin4415 -> 4415 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_install1_2/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_install1_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_installssl.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_installssl.xpi)bin4430 -> 4430 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_installssl/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_installssl/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_searching.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_searching.xpi)bin4808 -> 4808 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_searching/bootstrap.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_searching/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_searching/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_searching/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_1.xpi)bin5479 -> 5479 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/chrome.manifest (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/frame-script.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/frame-script.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_2.xpi)bin5481 -> 5481 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/chrome.manifest (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/chrome.manifest)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/frame-script.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/frame-script.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install.xpi)bin4782 -> 4782 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install/bootstrap.js (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install/install.rdf (renamed from toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/options_signed.xpi (renamed from toolkit/mozapps/extensions/test/browser/addons/options_signed.xpi)bin4560 -> 4560 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/options_signed/manifest.json (renamed from toolkit/mozapps/extensions/test/browser/addons/options_signed/manifest.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/addons/options_signed/options.html (renamed from toolkit/mozapps/extensions/test/browser/addons/options_signed/options.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/blockNoPlugins.xml (renamed from toolkit/mozapps/extensions/test/browser/blockNoPlugins.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/blockPluginHard.xml (renamed from toolkit/mozapps/extensions/test/browser/blockPluginHard.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser-common.ini (renamed from toolkit/mozapps/extensions/test/browser/browser-common.ini)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser-window.ini (renamed from toolkit/mozapps/extensions/test/browser/browser-window.ini)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser.ini (renamed from toolkit/mozapps/extensions/test/browser/browser.ini)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_CTP_plugins.js (renamed from toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_about.js (renamed from toolkit/mozapps/extensions/test/browser/browser_about.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_addonrepository_performance.js (renamed from toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug523784.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug523784.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug557943.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug557943.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug557956.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug557956.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug557956.rdf (renamed from toolkit/mozapps/extensions/test/browser/browser_bug557956.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug557956.xml (renamed from toolkit/mozapps/extensions/test/browser/browser_bug557956.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug557956_8_2.xpi (renamed from toolkit/mozapps/extensions/test/browser/browser_bug557956_8_2.xpi)bin4438 -> 4438 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug557956_9_2.xpi (renamed from toolkit/mozapps/extensions/test/browser/browser_bug557956_9_2.xpi)bin4426 -> 4426 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug562797.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug562797.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug562854.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug562854.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug562890.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug562890.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug562899.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug562899.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug562992.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug562992.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug567127.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug567127.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug567137.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug567137.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug570760.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug570760.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug572561.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug572561.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug573062.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug573062.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug577990.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug577990.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug580298.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug580298.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug581076.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug581076.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug586574.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug586574.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug587970.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug587970.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug590347.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug590347.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug591465.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug591465.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug591465.xml (renamed from toolkit/mozapps/extensions/test/browser/browser_bug591465.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug591663.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug591663.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug593535.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug593535.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug593535.xml (renamed from toolkit/mozapps/extensions/test/browser/browser_bug593535.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug596336.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug596336.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug608316.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug608316.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug610764.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug610764.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug616841.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug616841.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug618502.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug618502.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug679604.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug679604.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_bug714593.js (renamed from toolkit/mozapps/extensions/test/browser/browser_bug714593.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_cancelCompatCheck.js (renamed from toolkit/mozapps/extensions/test/browser/browser_cancelCompatCheck.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_checkAddonCompatibility.js (renamed from toolkit/mozapps/extensions/test/browser/browser_checkAddonCompatibility.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_details.js (renamed from toolkit/mozapps/extensions/test/browser/browser_details.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_discovery.js (renamed from toolkit/mozapps/extensions/test/browser/browser_discovery.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_discovery_install.js (renamed from toolkit/mozapps/extensions/test/browser/browser_discovery_install.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_dragdrop.js (renamed from toolkit/mozapps/extensions/test/browser/browser_dragdrop.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_eula.js (renamed from toolkit/mozapps/extensions/test/browser/browser_eula.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_eula.xml (renamed from toolkit/mozapps/extensions/test/browser/browser_eula.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_experiments.js (renamed from toolkit/mozapps/extensions/test/browser/browser_experiments.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_globalwarnings.js (renamed from toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_gmpProvider.js (renamed from toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_hotfix.js (renamed from toolkit/mozapps/extensions/test/browser/browser_hotfix.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_inlinesettings.js (renamed from toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_browser.js (renamed from toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_custom.js (renamed from toolkit/mozapps/extensions/test/browser/browser_inlinesettings_custom.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_info.js (renamed from toolkit/mozapps/extensions/test/browser/browser_inlinesettings_info.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_install.js (renamed from toolkit/mozapps/extensions/test/browser/browser_install.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_install.rdf (renamed from toolkit/mozapps/extensions/test/browser/browser_install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_install.rdf^headers^ (renamed from toolkit/mozapps/extensions/test/browser/browser_install.rdf^headers^)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_install.xml (renamed from toolkit/mozapps/extensions/test/browser/browser_install.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_install1_3.xpi (renamed from toolkit/mozapps/extensions/test/browser/browser_install1_3.xpi)bin4419 -> 4419 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_installssl.js (renamed from toolkit/mozapps/extensions/test/browser/browser_installssl.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_list.js (renamed from toolkit/mozapps/extensions/test/browser/browser_list.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_manualupdates.js (renamed from toolkit/mozapps/extensions/test/browser/browser_manualupdates.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_metadataTimeout.js (renamed from toolkit/mozapps/extensions/test/browser/browser_metadataTimeout.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_newaddon.js (renamed from toolkit/mozapps/extensions/test/browser/browser_newaddon.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_openDialog.js (renamed from toolkit/mozapps/extensions/test/browser/browser_openDialog.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_plugin_enabled_state_locked.js (renamed from toolkit/mozapps/extensions/test/browser/browser_plugin_enabled_state_locked.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_pluginprefs.js (renamed from toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_purchase.js (renamed from toolkit/mozapps/extensions/test/browser/browser_purchase.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_purchase.xml (renamed from toolkit/mozapps/extensions/test/browser/browser_purchase.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_recentupdates.js (renamed from toolkit/mozapps/extensions/test/browser/browser_recentupdates.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_searching.js (renamed from toolkit/mozapps/extensions/test/browser/browser_searching.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_searching.xml (renamed from toolkit/mozapps/extensions/test/browser/browser_searching.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_searching_empty.xml (renamed from toolkit/mozapps/extensions/test/browser/browser_searching_empty.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_sorting.js (renamed from toolkit/mozapps/extensions/test/browser/browser_sorting.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_sorting_plugins.js (renamed from toolkit/mozapps/extensions/test/browser/browser_sorting_plugins.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_system_addons_are_e10s.js (renamed from toolkit/mozapps/extensions/test/browser/browser_system_addons_are_e10s.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_tabsettings.js (renamed from toolkit/mozapps/extensions/test/browser/browser_tabsettings.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_task_next_test.js (renamed from toolkit/mozapps/extensions/test/browser/browser_task_next_test.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_types.js (renamed from toolkit/mozapps/extensions/test/browser/browser_types.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_uninstalling.js (renamed from toolkit/mozapps/extensions/test/browser/browser_uninstalling.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_update.js (renamed from toolkit/mozapps/extensions/test/browser/browser_update.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_updateid.js (renamed from toolkit/mozapps/extensions/test/browser/browser_updateid.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_updatessl.js (renamed from toolkit/mozapps/extensions/test/browser/browser_updatessl.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_updatessl.rdf (renamed from toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_updatessl.rdf^headers^ (renamed from toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf^headers^)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_webapi.js (renamed from toolkit/mozapps/extensions/test/browser/browser_webapi.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_webapi_access.js (renamed from toolkit/mozapps/extensions/test/browser/browser_webapi_access.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_webapi_addon_listener.js (renamed from toolkit/mozapps/extensions/test/browser/browser_webapi_addon_listener.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_webapi_enable.js (renamed from toolkit/mozapps/extensions/test/browser/browser_webapi_enable.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_webapi_install.js (renamed from toolkit/mozapps/extensions/test/browser/browser_webapi_install.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_webapi_uninstall.js (renamed from toolkit/mozapps/extensions/test/browser/browser_webapi_uninstall.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_webext_options.js (renamed from toolkit/mozapps/extensions/test/browser/browser_webext_options.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/cancelCompatCheck.sjs (renamed from toolkit/mozapps/extensions/test/browser/cancelCompatCheck.sjs)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/discovery.html (renamed from toolkit/mozapps/extensions/test/browser/discovery.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/discovery_frame.html (renamed from toolkit/mozapps/extensions/test/browser/discovery_frame.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/discovery_install.html (renamed from toolkit/mozapps/extensions/test/browser/discovery_install.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/head.js (renamed from toolkit/mozapps/extensions/test/browser/head.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/more_options.xul (renamed from toolkit/mozapps/extensions/test/browser/more_options.xul)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/moz.build (renamed from toolkit/mozapps/extensions/test/browser/moz.build)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/options.xul (renamed from toolkit/mozapps/extensions/test/browser/options.xul)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/plugin_test.html (renamed from toolkit/mozapps/extensions/test/browser/plugin_test.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/redirect.sjs (renamed from toolkit/mozapps/extensions/test/browser/redirect.sjs)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/releaseNotes.xhtml (renamed from toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/signed_hotfix.rdf (renamed from toolkit/mozapps/extensions/test/browser/signed_hotfix.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/signed_hotfix.xpi (renamed from toolkit/mozapps/extensions/test/browser/signed_hotfix.xpi)bin2745 -> 2745 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/unsigned_hotfix.rdf (renamed from toolkit/mozapps/extensions/test/browser/unsigned_hotfix.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/unsigned_hotfix.xpi (renamed from toolkit/mozapps/extensions/test/browser/unsigned_hotfix.xpi)bin560 -> 560 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/browser/webapi_addon_listener.html (renamed from toolkit/mozapps/extensions/test/browser/webapi_addon_listener.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/webapi_checkavailable.html (renamed from toolkit/mozapps/extensions/test/browser/webapi_checkavailable.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/webapi_checkchromeframe.xul (renamed from toolkit/mozapps/extensions/test/browser/webapi_checkchromeframe.xul)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/webapi_checkframed.html (renamed from toolkit/mozapps/extensions/test/browser/webapi_checkframed.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/browser/webapi_checknavigatedwindow.html (renamed from toolkit/mozapps/extensions/test/browser/webapi_checknavigatedwindow.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/mochitest/.eslintrc.js (renamed from toolkit/mozapps/extensions/test/mochitest/.eslintrc.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/mochitest/file_bug687194.xpi (renamed from toolkit/mozapps/extensions/test/mochitest/file_bug687194.xpi)bin5659 -> 5659 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/mochitest/file_empty.html (renamed from toolkit/mozapps/extensions/test/mochitest/file_empty.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/mochitest/mochitest.ini (renamed from toolkit/mozapps/extensions/test/mochitest/mochitest.ini)0
-rw-r--r--toolkit/mozapps/webextensions/test/mochitest/test_bug609794.html (renamed from toolkit/mozapps/extensions/test/mochitest/test_bug609794.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/mochitest/test_bug687194.html (renamed from toolkit/mozapps/extensions/test/mochitest/test_bug687194.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/mochitest/test_bug887098.html (renamed from toolkit/mozapps/extensions/test/mochitest/test_bug887098.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/moz.build (renamed from toolkit/mozapps/extensions/test/moz.build)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/.eslintrc.js (renamed from toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/BootstrapMonitor.jsm (renamed from toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_change.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_change.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update1.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update2.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update3.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/app_update.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/app_update.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/blocklist_update1.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/blocklist_update1.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/blocklist_update2.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/blocklist_update2.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/manual_update.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/manual_update.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_block.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/bug455906_block.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_empty.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/bug455906_empty.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_start.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/bug455906_start.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_warn.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/bug455906_warn.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/corrupt.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/corrupt.xpi)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/corruptfile.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/corruptfile.xpi)bin633 -> 633 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/empty.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/empty.xpi)bin197 -> 197 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/from_sources/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/from_sources/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/from_sources/install.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/from_sources/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/pluginInfoURL_block.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/pluginInfoURL_block.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad.txt (renamed from toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.txt)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad2.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad2.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/empty.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/productaddons/empty.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/good.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/productaddons/good.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/missing.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/productaddons/missing.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/unsigned.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/productaddons/unsigned.xpi)bin452 -> 452 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi)bin5151 -> 5151 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi)bin5298 -> 5298 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_good.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_good.xpi)bin5158 -> 5158 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_63_hash.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_hash.xpi)bin4471 -> 4471 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_63_plain.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_plain.xpi)bin4433 -> 4433 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_64_hash.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_hash.xpi)bin4474 -> 4474 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_64_plain.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_plain.xpi)bin4436 -> 4436 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_65_hash.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_65_hash.xpi)bin4487 -> 4487 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_badid.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_badid.xpi)bin6443 -> 6443 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_broken.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_broken.xpi)bin6563 -> 6563 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_signed.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_signed.xpi)bin6425 -> 6425 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi)bin2436 -> 2436 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi)bin5161 -> 5161 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi)bin5150 -> 5150 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi)bin5149 -> 5149 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi)bin5155 -> 5155 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi)bin4627 -> 4627 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi)bin4634 -> 4634 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi)bin1156 -> 1156 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi)bin691 -> 691 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_1.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi)bin4692 -> 4692 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi)bin4808 -> 4808 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi)bin4695 -> 4695 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_1.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi)bin4692 -> 4692 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi)bin4695 -> 4695 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_3.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi)bin4697 -> 4697 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_1.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi)bin4689 -> 4689 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi)bin4691 -> 4691 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_3.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi)bin4693 -> 4693 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system4_1.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi)bin4692 -> 4692 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system5_1.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi)bin4691 -> 4691 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi)bin4708 -> 4708 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi)bin4682 -> 4682 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi)bin4675 -> 4675 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_complete.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete.xpi)bin5090 -> 5090 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi)bin4706 -> 4706 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer.xpi)bin5095 -> 5095 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi)bin4701 -> 4701 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi)bin5117 -> 5117 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi)bin4716 -> 4716 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi)bin5098 -> 5098 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi)bin4707 -> 4707 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_failed_update.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_failed_update.xpi)bin735 -> 735 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_cache.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_cache.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_ignore.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_ignore.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_normal.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_normal.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_strict.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_strict.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_empty.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_empty.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_failed.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_failed.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_getAddonsByIDs.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_getAddonsByIDs.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_backgroundupdate.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_metadata_filters_1.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_metadata_filters_1.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_prefs_1.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_prefs_1.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_regexp_1.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_regexp_1.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug299716.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug299716.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug299716_2.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug299716_2.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug324121.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug324121.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug393285.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug393285.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug394300.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug394300.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug424262.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug424262.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug449027_app.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug449027_app.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug449027_toolkit.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug449027_toolkit.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug468528.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug468528.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_1.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_1.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_2.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_2.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_3.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_3.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_4.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_4.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_5.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_5.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_1.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_2.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_3.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_4.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_5.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_1.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_1.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_2.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_2.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_empty.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_empty.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_outdated_1.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_outdated_1.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_outdated_2.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_outdated_2.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug526598_1.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug526598_1.xpi)bin458 -> 458 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug526598_2.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug526598_2.xpi)bin458 -> 458 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug541420.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug541420.xpi)bin577 -> 577 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug542391.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug542391.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug554133.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug554133.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug619730.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug619730.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_bug655254.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_compatoverrides.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_compatoverrides.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_corrupt.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_complete.json (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_complete.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_defer.json (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_defer.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_ignore.json (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_ignore.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_dictionary.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/install.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/subdir/dummy.txt (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/subdir/dummy.txt)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/subdir/subdir2/dummy2.txt (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/subdir/subdir2/dummy2.txt)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist2.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist2.xml)0
-rw-r--r--[-rwxr-xr-x]toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_1.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_1.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_2.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_2.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_3.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_3.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_install.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_install.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_install.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_migrate.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_migrate.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_migrate4.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_migrate4.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_no_update.json (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_no_update.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/ancient.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/ancient.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/new.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/new.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/old.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/old.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_pluginBlocklistCtp.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_pluginBlocklistCtp.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_pluginBlocklistCtpUndo.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_pluginBlocklistCtpUndo.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_proxy/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_proxy/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_softblocked1.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_softblocked1.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_sourceURI.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_sourceURI.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_temporary/bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_temporary/bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_update.json (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_update.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_update.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_update.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_update.xml (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_update.xml)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_update_multi.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecheck.json (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.json)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecheck.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_normal.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_strict.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/test_updateid.rdf (renamed from toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/unsigned.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/unsigned.xpi)bin452 -> 452 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/data/webext-implicit-id.xpi (renamed from toolkit/mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpi)bin4182 -> 4182 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/head_addons.js (renamed from toolkit/mozapps/extensions/test/xpcshell/head_addons.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/head_unpack.js (renamed from toolkit/mozapps/extensions/test/xpcshell/head_unpack.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository_cache.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository_compatmode.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_ChromeManifestParser.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_ChromeManifestParser.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_DeferredSave.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_DeferredSave.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_LightweightThemeManager.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_ProductAddonChecker.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_XPIStates.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_XPIcancel.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_XPIcancel.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_addon_path_service.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_addon_path_service.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_asyncBlocklistLoad.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_asyncBlocklistLoad.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_backgroundupdate.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bad_json.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bad_json.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_badschema.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_badschema.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_gfx.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_blocklist_gfx.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_metadata_filters.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_prefs.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_regexp.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_blocklistchange.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_const.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_globals.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_resource.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_resource.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug1180901.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug1180901_2.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug1180901_2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug299716.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug299716_2.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug299716_2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug324121.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug324121.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug335238.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug335238.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug371495.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug371495.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug384052.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug384052.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug393285.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug394300.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug394300.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug397778.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug397778.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug406118.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug424262.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug424262.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug425657.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug425657.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug430120.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug449027.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug455906.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug465190.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug465190.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug468528.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_1.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_1_strictcompat.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1_strictcompat.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_2.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_3.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_3_strictcompat.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_4.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_1.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_2.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_3.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug521905.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug526598.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug526598.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug541420.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug541420.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug542391.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug554133.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug554133.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug559800.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug563256.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug563256.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug564030.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug564030.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug566626.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug566626.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug567184.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug567184.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug569138.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug569138.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug570173.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug576735.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug576735.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug587088.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug587088.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug594058.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug594058.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug595081.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug595081.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug595573.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug595573.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug596607.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug596607.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug616841.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug616841.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug619730.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug619730.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug620837.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug620837.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug655254.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug659772.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug659772.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug675371.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug740612.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug740612.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug753900.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug753900.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug757663.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug757663.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_bug953156.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_bug953156.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_cache_certdb.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_cacheflush.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_cacheflush.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_checkCompatibility_themeOverride.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_checkcompatibility.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_childprocess.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_childprocess.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_compatoverrides.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_corrupt.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_corrupt_strictcompat.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_corruptfile.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_corruptfile.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_dataDirectory.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_dataDirectory.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_default_providers_pref.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_default_providers_pref.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_delay_update.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_delay_update_webextension.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_dependencies.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_dependencies.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_dictionary.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_disable.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_disable.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_distribution.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_distribution.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_dss.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_dss.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_duplicateplugins.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_e10s_restartless.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_e10s_restartless.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_error.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_error.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_experiment.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_ext_management.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_filepointer.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_fuel.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_fuel.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_general.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_general.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_getresource.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_getresource.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Device.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_DriverNew.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OK.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OS.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Vendor.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js)0
-rw-r--r--[-rwxr-xr-x]toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Version.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_prefs.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_gmpProvider.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_hasbinarycomponents.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_hotfix.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_hotfix.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_hotfix_cert.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_hotfix_cert.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_install.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_install.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_install_from_sources.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_install_from_sources.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_install_icons.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_install_strictcompat.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_install_strictcompat.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_isDebuggable.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_isReady.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_isReady.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_json_updatecheck.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_langpack.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_langpack.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_locale.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_locale.js)0
-rw-r--r--[-rwxr-xr-x]toolkit/mozapps/webextensions/test/xpcshell/test_locked.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_locked.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_locked2.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_locked2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_locked_strictcompat.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_manifest.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_manifest.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_mapURIToAddonID.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_metadata_update.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_metadata_update.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_migrate1.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_migrate2.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_migrate2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_migrate3.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_migrate3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_migrate4.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_migrate4.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_migrate5.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_migrate5.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_migrateAddonRepository.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_migrate_max_version.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_migrate_max_version.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_multiprocessCompatible.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_no_addons.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_nodisable_hidden.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_onPropertyChanged_appDisabled.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_onPropertyChanged_appDisabled.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_overrideblocklist.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_pass_symbol.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_pass_symbol.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_permissions.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_permissions.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_permissions_prefs.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_pluginBlocklistCtp.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_pluginInfoURL.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_pluginchange.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_plugins.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_plugins.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_pref_properties.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_provider_markSafe.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_provider_unsafe_access_shutdown.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_provider_unsafe_access_startup.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_proxies.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_proxies.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_proxy.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_registry.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_registry.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_reload.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_reload.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_safemode.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_safemode.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_schema_change.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_seen.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_seen.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_seen_newprofile.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_shutdown.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_signed_inject.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_signed_install.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_signed_migrate.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_signed_multi.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_signed_multi.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_signed_updatepref.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_signed_verify.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_softblocked.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_sourceURI.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_startup.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_startup.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_strictcompatibility.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_switch_os.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_syncGUID.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_system_delay_update.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_system_reset.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_system_update.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_system_update.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_targetPlatforms.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_targetPlatforms.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_temporary.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_temporary.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_theme.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_theme.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_types.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_types.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_undothemeuninstall.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_undothemeuninstall.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_undouninstall.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_uninstall.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_uninstall.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_update.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_update.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_updateCancel.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_update_compatmode.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_update_ignorecompat.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_update_strictcompat.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_update_webextensions.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_updatecheck.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_updateid.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_updateid.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_upgrade.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_upgrade_strictcompat.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_webextension.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_webextension.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_webextension_embedded.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_webextension_embedded.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_webextension_icons.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_webextension_install.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_webextension_paths.js (renamed from toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/xpcshell-shared.ini (renamed from toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/xpcshell-unpack.ini (renamed from toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/xpcshell.ini (renamed from toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/.eslintrc.js (renamed from toolkit/mozapps/extensions/test/xpinstall/.eslintrc.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/amosigned.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi)bin4420 -> 4420 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/amosigned2.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/amosigned2.xpi)bin4421 -> 4421 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/authRedirect.sjs (renamed from toolkit/mozapps/extensions/test/xpinstall/authRedirect.sjs)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser.ini (renamed from toolkit/mozapps/extensions/test/xpinstall/browser.ini)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_trigger.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_trigger_iframe.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_url.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_url.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_auth.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_auth.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_auth2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_auth3.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_auth4.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_badargs.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_badargs.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_badargs2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_badargs2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_badhash.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_badhash.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_badhashtype.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_badhashtype.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_bug540558.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_bug540558.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_bug611242.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_bug611242.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_bug638292.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_bug645699.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_bug645699.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_bug672485.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_bug672485.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_cancel.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_cancel.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_concurrent_installs.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_concurrent_installs.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_cookies.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_cookies.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_cookies2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_cookies3.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_cookies4.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_corrupt.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_datauri.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_empty.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_empty.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_enabled.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_enabled2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_enabled2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_enabled3.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_enabled3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_hash.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_hash.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_hash2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_httphash.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_httphash2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_httphash3.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_httphash4.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_httphash5.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_httphash6.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_installchrome.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_installchrome.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_localfile.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_localfile.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_localfile2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_localfile2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_localfile3.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_localfile3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_localfile4.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_localfile4.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_multipackage.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_multipackage.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway3.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway4.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway4.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_offline.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_offline.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_relative.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_relative.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_signed_multipackage.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_signed_multipackage.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_signed_multiple.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_signed_multiple.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_signed_naming.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_signed_naming.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_signed_tampered.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_signed_tampered.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_signed_trigger.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_signed_trigger.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_signed_untrusted.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_signed_untrusted.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_signed_url.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_signed_url.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_softwareupdate.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_softwareupdate.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_switchtab.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_switchtab.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_trigger_redirect.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_trigger_redirect.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger_iframe.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger_xorigin.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_xorigin.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_url.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_url.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist2.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_whitelist2.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist3.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_whitelist3.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist4.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_whitelist4.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist5.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_whitelist5.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist6.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_whitelist6.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist7.js (renamed from toolkit/mozapps/extensions/test/xpinstall/browser_whitelist7.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/bug540558.html (renamed from toolkit/mozapps/extensions/test/xpinstall/bug540558.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/bug638292.html (renamed from toolkit/mozapps/extensions/test/xpinstall/bug638292.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/bug645699.html (renamed from toolkit/mozapps/extensions/test/xpinstall/bug645699.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/concurrent_installs.html (renamed from toolkit/mozapps/extensions/test/xpinstall/concurrent_installs.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/cookieRedirect.sjs (renamed from toolkit/mozapps/extensions/test/xpinstall/cookieRedirect.sjs)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/corrupt.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/corrupt.xpi)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/empty.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/empty.xpi)bin197 -> 197 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/enabled.html (renamed from toolkit/mozapps/extensions/test/xpinstall/enabled.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/hashRedirect.sjs (renamed from toolkit/mozapps/extensions/test/xpinstall/hashRedirect.sjs)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/head.js (renamed from toolkit/mozapps/extensions/test/xpinstall/head.js)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/incompatible.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/incompatible.xpi)bin4442 -> 4442 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/installchrome.html (renamed from toolkit/mozapps/extensions/test/xpinstall/installchrome.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/installtrigger.html (renamed from toolkit/mozapps/extensions/test/xpinstall/installtrigger.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/installtrigger_frame.html (renamed from toolkit/mozapps/extensions/test/xpinstall/installtrigger_frame.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/multipackage.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/multipackage.xpi)bin9589 -> 9589 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/navigate.html (renamed from toolkit/mozapps/extensions/test/xpinstall/navigate.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/redirect.sjs (renamed from toolkit/mozapps/extensions/test/xpinstall/redirect.sjs)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/restartless-unsigned.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/restartless-unsigned.xpi)bin528 -> 528 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/restartless.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/restartless.xpi)bin4447 -> 4447 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/signed-multipackage.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/signed-multipackage.xpi)bin2976 -> 2976 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/signed-no-cn.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/signed-no-cn.xpi)bin2241 -> 2241 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/signed-no-o.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/signed-no-o.xpi)bin2247 -> 2247 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/signed-tampered.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/signed-tampered.xpi)bin2260 -> 2260 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/signed-untrusted.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/signed-untrusted.xpi)bin2237 -> 2237 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/signed.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/signed.xpi)bin2250 -> 2250 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/signed2.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/signed2.xpi)bin2938 -> 2938 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/slowinstall.sjs (renamed from toolkit/mozapps/extensions/test/xpinstall/slowinstall.sjs)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/startsoftwareupdate.html (renamed from toolkit/mozapps/extensions/test/xpinstall/startsoftwareupdate.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/theme.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/theme.xpi)bin4450 -> 4450 bytes
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/triggerredirect.html (renamed from toolkit/mozapps/extensions/test/xpinstall/triggerredirect.html)0
-rw-r--r--toolkit/mozapps/webextensions/test/xpinstall/unsigned.xpi (renamed from toolkit/mozapps/extensions/test/xpinstall/unsigned.xpi)bin452 -> 452 bytes
-rw-r--r--toolkit/themes/linux/mozapps/extensions/extensions.css42
-rw-r--r--toolkit/themes/linux/mozapps/extensions/newaddon.css5
-rw-r--r--toolkit/themes/linux/mozapps/jar.mn32
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/category-available.png (renamed from toolkit/themes/linux/mozapps/extensions/category-available.png)bin1092 -> 1092 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/category-discover.png (renamed from toolkit/themes/linux/mozapps/extensions/category-discover.png)bin1482 -> 1482 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/category-plugins.png (renamed from toolkit/themes/linux/mozapps/extensions/category-plugins.png)bin1172 -> 1172 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/category-recent.png (renamed from toolkit/themes/linux/mozapps/extensions/category-recent.png)bin2020 -> 2020 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/category-search.png (renamed from toolkit/themes/linux/mozapps/extensions/category-search.png)bin2600 -> 2600 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/category-service.png (renamed from toolkit/themes/linux/mozapps/extensions/category-service.png)bin2063 -> 2063 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/dictionaryGeneric-16.png (renamed from toolkit/themes/linux/mozapps/extensions/dictionaryGeneric-16.png)bin584 -> 584 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/dictionaryGeneric.png (renamed from toolkit/themes/linux/mozapps/extensions/dictionaryGeneric.png)bin1290 -> 1290 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/extensionGeneric-16.png (renamed from toolkit/themes/linux/mozapps/extensions/extensionGeneric-16.png)bin713 -> 713 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/extensions.css42
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/heart.png (renamed from toolkit/themes/linux/mozapps/extensions/heart.png)bin2949 -> 2949 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/localeGeneric.png (renamed from toolkit/themes/linux/mozapps/extensions/localeGeneric.png)bin1860 -> 1860 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/newaddon.css5
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/themeGeneric-16.png (renamed from toolkit/themes/linux/mozapps/extensions/themeGeneric-16.png)bin638 -> 638 bytes
-rw-r--r--toolkit/themes/linux/mozapps/webextensions/themeGeneric.png (renamed from toolkit/themes/linux/mozapps/extensions/themeGeneric.png)bin1734 -> 1734 bytes
-rw-r--r--toolkit/themes/osx/mozapps/extensions/extensions.css51
-rw-r--r--toolkit/themes/osx/mozapps/extensions/newaddon.css5
-rw-r--r--toolkit/themes/osx/mozapps/jar.mn64
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/about.css (renamed from toolkit/themes/osx/mozapps/extensions/about.css)0
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/blocklist.css (renamed from toolkit/themes/osx/mozapps/extensions/blocklist.css)0
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/cancel.png (renamed from toolkit/themes/osx/mozapps/extensions/cancel.png)bin115 -> 115 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/category-available.png (renamed from toolkit/themes/osx/mozapps/extensions/category-available.png)bin1671 -> 1671 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/category-dictionaries.png (renamed from toolkit/themes/osx/mozapps/extensions/category-dictionaries.png)bin1769 -> 1769 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/category-discover.png (renamed from toolkit/themes/osx/mozapps/extensions/category-discover.png)bin1324 -> 1324 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/category-experiments.png (renamed from toolkit/themes/osx/mozapps/extensions/category-experiments.png)bin822 -> 822 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/category-plugins.png (renamed from toolkit/themes/osx/mozapps/extensions/category-plugins.png)bin886 -> 886 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/category-recent.png (renamed from toolkit/themes/osx/mozapps/extensions/category-recent.png)bin1642 -> 1642 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/category-search.png (renamed from toolkit/themes/osx/mozapps/extensions/category-search.png)bin2600 -> 2600 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/category-service.png (renamed from toolkit/themes/osx/mozapps/extensions/category-service.png)bin2063 -> 2063 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/dictionaryGeneric-16.png (renamed from toolkit/themes/osx/mozapps/extensions/dictionaryGeneric-16.png)bin742 -> 742 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/dictionaryGeneric.png (renamed from toolkit/themes/osx/mozapps/extensions/dictionaryGeneric.png)bin1769 -> 1769 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/discover-logo.png (renamed from toolkit/themes/osx/mozapps/extensions/discover-logo.png)bin12007 -> 12007 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/eula.css (renamed from toolkit/themes/osx/mozapps/extensions/eula.css)0
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/experimentGeneric.png (renamed from toolkit/themes/osx/mozapps/extensions/experimentGeneric.png)bin822 -> 822 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/extensionGeneric-16.png (renamed from toolkit/themes/osx/mozapps/extensions/extensionGeneric-16.png)bin554 -> 554 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/extensions.css51
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/heart.png (renamed from toolkit/themes/osx/mozapps/extensions/heart.png)bin2949 -> 2949 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/localeGeneric.png (renamed from toolkit/themes/osx/mozapps/extensions/localeGeneric.png)bin2410 -> 2410 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/newaddon.css5
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/rating-not-won.png (renamed from toolkit/themes/osx/mozapps/extensions/rating-not-won.png)bin1559 -> 1559 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/rating-won.png (renamed from toolkit/themes/osx/mozapps/extensions/rating-won.png)bin1662 -> 1662 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/search.png (renamed from toolkit/themes/osx/mozapps/extensions/search.png)bin423 -> 423 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/themeGeneric-16.png (renamed from toolkit/themes/osx/mozapps/extensions/themeGeneric-16.png)bin710 -> 710 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/themeGeneric.png (renamed from toolkit/themes/osx/mozapps/extensions/themeGeneric.png)bin2185 -> 2185 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/toolbarbutton-dropmarker.png (renamed from toolkit/themes/osx/mozapps/extensions/toolbarbutton-dropmarker.png)bin147 -> 147 bytes
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/update.css (renamed from toolkit/themes/osx/mozapps/extensions/update.css)0
-rw-r--r--toolkit/themes/osx/mozapps/webextensions/xpinstallConfirm.css (renamed from toolkit/themes/osx/mozapps/extensions/xpinstallConfirm.css)0
-rw-r--r--toolkit/themes/shared/mozapps.inc.mn16
-rw-r--r--toolkit/themes/shared/non-mac.jar.inc.mn27
-rw-r--r--toolkit/themes/shared/webextensions/alerticon-error.svg (renamed from toolkit/themes/shared/extensions/alerticon-error.svg)0
-rw-r--r--toolkit/themes/shared/webextensions/alerticon-info-negative.svg (renamed from toolkit/themes/shared/extensions/alerticon-info-negative.svg)0
-rw-r--r--toolkit/themes/shared/webextensions/alerticon-info-positive.svg (renamed from toolkit/themes/shared/extensions/alerticon-info-positive.svg)0
-rw-r--r--toolkit/themes/shared/webextensions/alerticon-warning.svg (renamed from toolkit/themes/shared/extensions/alerticon-warning.svg)0
-rw-r--r--toolkit/themes/shared/webextensions/extensionGeneric.svg (renamed from toolkit/themes/shared/extensions/extensionGeneric.svg)0
-rw-r--r--toolkit/themes/shared/webextensions/extensions.inc.css (renamed from toolkit/themes/shared/extensions/extensions.inc.css)0
-rw-r--r--toolkit/themes/shared/webextensions/navigation.png (renamed from toolkit/themes/shared/extensions/navigation.png)bin663 -> 663 bytes
-rw-r--r--toolkit/themes/shared/webextensions/newaddon.inc.css (renamed from toolkit/themes/shared/extensions/newaddon.inc.css)0
-rw-r--r--toolkit/themes/shared/webextensions/utilities.svg (renamed from toolkit/themes/shared/extensions/utilities.svg)0
-rw-r--r--toolkit/themes/windows/mozapps/extensions/extensions.css42
-rw-r--r--toolkit/themes/windows/mozapps/extensions/newaddon.css5
-rw-r--r--toolkit/themes/windows/mozapps/jar.mn52
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/about.css (renamed from toolkit/themes/windows/mozapps/extensions/about.css)0
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/blocklist.css (renamed from toolkit/themes/windows/mozapps/extensions/blocklist.css)0
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/cancel.png (renamed from toolkit/themes/windows/mozapps/extensions/cancel.png)bin115 -> 115 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-available-XP.png (renamed from toolkit/themes/windows/mozapps/extensions/category-available-XP.png)bin1671 -> 1671 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-available.png (renamed from toolkit/themes/windows/mozapps/extensions/category-available.png)bin2235 -> 2235 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-discover-XP.png (renamed from toolkit/themes/windows/mozapps/extensions/category-discover-XP.png)bin1324 -> 1324 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-discover.png (renamed from toolkit/themes/windows/mozapps/extensions/category-discover.png)bin1355 -> 1355 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-plugins-XP.png (renamed from toolkit/themes/windows/mozapps/extensions/category-plugins-XP.png)bin886 -> 886 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-plugins.png (renamed from toolkit/themes/windows/mozapps/extensions/category-plugins.png)bin962 -> 962 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-recent-XP.png (renamed from toolkit/themes/windows/mozapps/extensions/category-recent-XP.png)bin1642 -> 1642 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-recent.png (renamed from toolkit/themes/windows/mozapps/extensions/category-recent.png)bin2251 -> 2251 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-search.png (renamed from toolkit/themes/windows/mozapps/extensions/category-search.png)bin2600 -> 2600 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/category-service.png (renamed from toolkit/themes/windows/mozapps/extensions/category-service.png)bin2063 -> 2063 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/dictionaryGeneric-16.png (renamed from toolkit/themes/windows/mozapps/extensions/dictionaryGeneric-16.png)bin733 -> 733 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/dictionaryGeneric.png (renamed from toolkit/themes/windows/mozapps/extensions/dictionaryGeneric.png)bin1665 -> 1665 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/discover-logo.png (renamed from toolkit/themes/windows/mozapps/extensions/discover-logo.png)bin12007 -> 12007 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/eula.css (renamed from toolkit/themes/windows/mozapps/extensions/eula.css)0
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/experimentGeneric.png (renamed from toolkit/themes/windows/mozapps/extensions/experimentGeneric.png)bin822 -> 822 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/extensionGeneric-16-XP.png (renamed from toolkit/themes/windows/mozapps/extensions/extensionGeneric-16-XP.png)bin398 -> 398 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/extensionGeneric-16.png (renamed from toolkit/themes/windows/mozapps/extensions/extensionGeneric-16.png)bin418 -> 418 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/extensions.css42
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/heart.png (renamed from toolkit/themes/windows/mozapps/extensions/heart.png)bin2949 -> 2949 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/localeGeneric-XP.png (renamed from toolkit/themes/windows/mozapps/extensions/localeGeneric-XP.png)bin2410 -> 2410 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/localeGeneric.png (renamed from toolkit/themes/windows/mozapps/extensions/localeGeneric.png)bin2518 -> 2518 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/newaddon.css5
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/rating-not-won.png (renamed from toolkit/themes/windows/mozapps/extensions/rating-not-won.png)bin1559 -> 1559 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/rating-won.png (renamed from toolkit/themes/windows/mozapps/extensions/rating-won.png)bin1662 -> 1662 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/themeGeneric-16-XP.png (renamed from toolkit/themes/windows/mozapps/extensions/themeGeneric-16-XP.png)bin842 -> 842 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/themeGeneric-16.png (renamed from toolkit/themes/windows/mozapps/extensions/themeGeneric-16.png)bin837 -> 837 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/themeGeneric-XP.png (renamed from toolkit/themes/windows/mozapps/extensions/themeGeneric-XP.png)bin2185 -> 2185 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/themeGeneric.png (renamed from toolkit/themes/windows/mozapps/extensions/themeGeneric.png)bin2094 -> 2094 bytes
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/update.css (renamed from toolkit/themes/windows/mozapps/extensions/update.css)0
-rw-r--r--toolkit/themes/windows/mozapps/webextensions/xpinstallConfirm.css (renamed from toolkit/themes/windows/mozapps/extensions/xpinstallConfirm.css)0
-rw-r--r--toolkit/toolkit.mozbuild2
1615 files changed, 39692 insertions, 250 deletions
diff --git a/toolkit/components/moz.build b/toolkit/components/moz.build
index 509332800..ce8722910 100644
--- a/toolkit/components/moz.build
+++ b/toolkit/components/moz.build
@@ -25,7 +25,6 @@ DIRS += [
'crashmonitor',
'diskspacewatcher',
'downloads',
- 'extensions',
'exthelper',
'filewatcher',
'finalizationwitness',
@@ -68,6 +67,9 @@ DIRS += [
'xulstore'
]
+if CONFIG['MOZ_WEBEXTENSIONS']:
+ DIRS += ['webextensions']
+
if CONFIG['ENABLE_INTL_API']:
DIRS += ['mozintl']
diff --git a/toolkit/components/telemetry/tests/unit/xpcshell.ini b/toolkit/components/telemetry/tests/unit/xpcshell.ini
index 74067580a..fe58d362e 100644
--- a/toolkit/components/telemetry/tests/unit/xpcshell.ini
+++ b/toolkit/components/telemetry/tests/unit/xpcshell.ini
@@ -15,7 +15,7 @@ support-files =
system.xpi
restartless.xpi
theme.xpi
- !/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+ !/toolkit/mozapps/webextensions/test/xpcshell/head_addons.js
generated-files =
dictionary.xpi
experiment.xpi
diff --git a/toolkit/components/extensions/.eslintrc.js b/toolkit/components/webextensions/.eslintrc.js
index 70196fc6a..70196fc6a 100644
--- a/toolkit/components/extensions/.eslintrc.js
+++ b/toolkit/components/webextensions/.eslintrc.js
diff --git a/toolkit/components/extensions/Extension.jsm b/toolkit/components/webextensions/Extension.jsm
index 3468f2594..3468f2594 100644
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/webextensions/Extension.jsm
diff --git a/toolkit/components/extensions/ExtensionAPI.jsm b/toolkit/components/webextensions/ExtensionAPI.jsm
index 54dab8e3b..54dab8e3b 100644
--- a/toolkit/components/extensions/ExtensionAPI.jsm
+++ b/toolkit/components/webextensions/ExtensionAPI.jsm
diff --git a/toolkit/components/extensions/ExtensionChild.jsm b/toolkit/components/webextensions/ExtensionChild.jsm
index c953dd685..c953dd685 100644
--- a/toolkit/components/extensions/ExtensionChild.jsm
+++ b/toolkit/components/webextensions/ExtensionChild.jsm
diff --git a/toolkit/components/extensions/ExtensionCommon.jsm b/toolkit/components/webextensions/ExtensionCommon.jsm
index a339fb27e..a339fb27e 100644
--- a/toolkit/components/extensions/ExtensionCommon.jsm
+++ b/toolkit/components/webextensions/ExtensionCommon.jsm
diff --git a/toolkit/components/extensions/ExtensionContent.jsm b/toolkit/components/webextensions/ExtensionContent.jsm
index 9b9a02091..9b9a02091 100644
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/webextensions/ExtensionContent.jsm
diff --git a/toolkit/components/extensions/ExtensionManagement.jsm b/toolkit/components/webextensions/ExtensionManagement.jsm
index 324c5b71b..324c5b71b 100644
--- a/toolkit/components/extensions/ExtensionManagement.jsm
+++ b/toolkit/components/webextensions/ExtensionManagement.jsm
diff --git a/toolkit/components/extensions/ExtensionParent.jsm b/toolkit/components/webextensions/ExtensionParent.jsm
index b88500d1e..b88500d1e 100644
--- a/toolkit/components/extensions/ExtensionParent.jsm
+++ b/toolkit/components/webextensions/ExtensionParent.jsm
diff --git a/toolkit/components/extensions/ExtensionStorage.jsm b/toolkit/components/webextensions/ExtensionStorage.jsm
index 0b0ffb000..0b0ffb000 100644
--- a/toolkit/components/extensions/ExtensionStorage.jsm
+++ b/toolkit/components/webextensions/ExtensionStorage.jsm
diff --git a/toolkit/components/extensions/ExtensionTestCommon.jsm b/toolkit/components/webextensions/ExtensionTestCommon.jsm
index 02453ddfd..02453ddfd 100644
--- a/toolkit/components/extensions/ExtensionTestCommon.jsm
+++ b/toolkit/components/webextensions/ExtensionTestCommon.jsm
diff --git a/toolkit/components/extensions/ExtensionUtils.jsm b/toolkit/components/webextensions/ExtensionUtils.jsm
index e7f768c07..e7f768c07 100644
--- a/toolkit/components/extensions/ExtensionUtils.jsm
+++ b/toolkit/components/webextensions/ExtensionUtils.jsm
diff --git a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm b/toolkit/components/webextensions/ExtensionXPCShellUtils.jsm
index 339709a19..339709a19 100644
--- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
+++ b/toolkit/components/webextensions/ExtensionXPCShellUtils.jsm
diff --git a/toolkit/components/extensions/LegacyExtensionsUtils.jsm b/toolkit/components/webextensions/LegacyExtensionsUtils.jsm
index 7632548e3..7632548e3 100644
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/webextensions/LegacyExtensionsUtils.jsm
diff --git a/toolkit/components/extensions/MessageChannel.jsm b/toolkit/components/webextensions/MessageChannel.jsm
index c5b326405..c5b326405 100644
--- a/toolkit/components/extensions/MessageChannel.jsm
+++ b/toolkit/components/webextensions/MessageChannel.jsm
diff --git a/toolkit/components/extensions/NativeMessaging.jsm b/toolkit/components/webextensions/NativeMessaging.jsm
index 3d8658a3f..3d8658a3f 100644
--- a/toolkit/components/extensions/NativeMessaging.jsm
+++ b/toolkit/components/webextensions/NativeMessaging.jsm
diff --git a/toolkit/components/extensions/Schemas.jsm b/toolkit/components/webextensions/Schemas.jsm
index 159211c79..159211c79 100644
--- a/toolkit/components/extensions/Schemas.jsm
+++ b/toolkit/components/webextensions/Schemas.jsm
diff --git a/toolkit/components/extensions/ext-alarms.js b/toolkit/components/webextensions/ext-alarms.js
index 2171e7dba..2171e7dba 100644
--- a/toolkit/components/extensions/ext-alarms.js
+++ b/toolkit/components/webextensions/ext-alarms.js
diff --git a/toolkit/components/extensions/ext-backgroundPage.js b/toolkit/components/webextensions/ext-backgroundPage.js
index fce6100ca..fce6100ca 100644
--- a/toolkit/components/extensions/ext-backgroundPage.js
+++ b/toolkit/components/webextensions/ext-backgroundPage.js
diff --git a/toolkit/components/extensions/ext-browser-content.js b/toolkit/components/webextensions/ext-browser-content.js
index e14ca50d6..e14ca50d6 100644
--- a/toolkit/components/extensions/ext-browser-content.js
+++ b/toolkit/components/webextensions/ext-browser-content.js
diff --git a/toolkit/components/extensions/ext-c-backgroundPage.js b/toolkit/components/webextensions/ext-c-backgroundPage.js
index b5074dd9a..b5074dd9a 100644
--- a/toolkit/components/extensions/ext-c-backgroundPage.js
+++ b/toolkit/components/webextensions/ext-c-backgroundPage.js
diff --git a/toolkit/components/extensions/ext-c-extension.js b/toolkit/components/webextensions/ext-c-extension.js
index 669309bea..669309bea 100644
--- a/toolkit/components/extensions/ext-c-extension.js
+++ b/toolkit/components/webextensions/ext-c-extension.js
diff --git a/toolkit/components/extensions/ext-c-runtime.js b/toolkit/components/webextensions/ext-c-runtime.js
index 8adca60ca..8adca60ca 100644
--- a/toolkit/components/extensions/ext-c-runtime.js
+++ b/toolkit/components/webextensions/ext-c-runtime.js
diff --git a/toolkit/components/extensions/ext-c-storage.js b/toolkit/components/webextensions/ext-c-storage.js
index e8d53058f..e8d53058f 100644
--- a/toolkit/components/extensions/ext-c-storage.js
+++ b/toolkit/components/webextensions/ext-c-storage.js
diff --git a/toolkit/components/extensions/ext-c-test.js b/toolkit/components/webextensions/ext-c-test.js
index b0c92f79f..b0c92f79f 100644
--- a/toolkit/components/extensions/ext-c-test.js
+++ b/toolkit/components/webextensions/ext-c-test.js
diff --git a/toolkit/components/extensions/ext-cookies.js b/toolkit/components/webextensions/ext-cookies.js
index d0a703421..d0a703421 100644
--- a/toolkit/components/extensions/ext-cookies.js
+++ b/toolkit/components/webextensions/ext-cookies.js
diff --git a/toolkit/components/extensions/ext-downloads.js b/toolkit/components/webextensions/ext-downloads.js
index 132814ae4..132814ae4 100644
--- a/toolkit/components/extensions/ext-downloads.js
+++ b/toolkit/components/webextensions/ext-downloads.js
diff --git a/toolkit/components/extensions/ext-extension.js b/toolkit/components/webextensions/ext-extension.js
index c4bdc8b63..c4bdc8b63 100644
--- a/toolkit/components/extensions/ext-extension.js
+++ b/toolkit/components/webextensions/ext-extension.js
diff --git a/toolkit/components/extensions/ext-i18n.js b/toolkit/components/webextensions/ext-i18n.js
index bb4bde4bd..bb4bde4bd 100644
--- a/toolkit/components/extensions/ext-i18n.js
+++ b/toolkit/components/webextensions/ext-i18n.js
diff --git a/toolkit/components/extensions/ext-idle.js b/toolkit/components/webextensions/ext-idle.js
index c5be4b600..c5be4b600 100644
--- a/toolkit/components/extensions/ext-idle.js
+++ b/toolkit/components/webextensions/ext-idle.js
diff --git a/toolkit/components/extensions/ext-management.js b/toolkit/components/webextensions/ext-management.js
index 59a7959d7..59a7959d7 100644
--- a/toolkit/components/extensions/ext-management.js
+++ b/toolkit/components/webextensions/ext-management.js
diff --git a/toolkit/components/extensions/ext-notifications.js b/toolkit/components/webextensions/ext-notifications.js
index 1df96a2ac..1df96a2ac 100644
--- a/toolkit/components/extensions/ext-notifications.js
+++ b/toolkit/components/webextensions/ext-notifications.js
diff --git a/toolkit/components/extensions/ext-runtime.js b/toolkit/components/webextensions/ext-runtime.js
index aed3ffd4b..aed3ffd4b 100644
--- a/toolkit/components/extensions/ext-runtime.js
+++ b/toolkit/components/webextensions/ext-runtime.js
diff --git a/toolkit/components/extensions/ext-storage.js b/toolkit/components/webextensions/ext-storage.js
index b1e22c46c..b1e22c46c 100644
--- a/toolkit/components/extensions/ext-storage.js
+++ b/toolkit/components/webextensions/ext-storage.js
diff --git a/toolkit/components/extensions/ext-topSites.js b/toolkit/components/webextensions/ext-topSites.js
index a66ac85d9..a66ac85d9 100644
--- a/toolkit/components/extensions/ext-topSites.js
+++ b/toolkit/components/webextensions/ext-topSites.js
diff --git a/toolkit/components/extensions/ext-webNavigation.js b/toolkit/components/webextensions/ext-webNavigation.js
index 904f3a4a7..904f3a4a7 100644
--- a/toolkit/components/extensions/ext-webNavigation.js
+++ b/toolkit/components/webextensions/ext-webNavigation.js
diff --git a/toolkit/components/extensions/ext-webRequest.js b/toolkit/components/webextensions/ext-webRequest.js
index f92330131..f92330131 100644
--- a/toolkit/components/extensions/ext-webRequest.js
+++ b/toolkit/components/webextensions/ext-webRequest.js
diff --git a/toolkit/components/extensions/extensions-toolkit.manifest b/toolkit/components/webextensions/extensions-toolkit.manifest
index 4ec65a984..4ec65a984 100644
--- a/toolkit/components/extensions/extensions-toolkit.manifest
+++ b/toolkit/components/webextensions/extensions-toolkit.manifest
diff --git a/toolkit/components/extensions/jar.mn b/toolkit/components/webextensions/jar.mn
index 6d343e1b7..6d343e1b7 100644
--- a/toolkit/components/extensions/jar.mn
+++ b/toolkit/components/webextensions/jar.mn
diff --git a/toolkit/components/extensions/moz.build b/toolkit/components/webextensions/moz.build
index f32f526f9..f32f526f9 100644
--- a/toolkit/components/extensions/moz.build
+++ b/toolkit/components/webextensions/moz.build
diff --git a/toolkit/components/extensions/schemas/LICENSE b/toolkit/components/webextensions/schemas/LICENSE
index 9314092fd..9314092fd 100644
--- a/toolkit/components/extensions/schemas/LICENSE
+++ b/toolkit/components/webextensions/schemas/LICENSE
diff --git a/toolkit/components/extensions/schemas/alarms.json b/toolkit/components/webextensions/schemas/alarms.json
index 2a72a2842..2a72a2842 100644
--- a/toolkit/components/extensions/schemas/alarms.json
+++ b/toolkit/components/webextensions/schemas/alarms.json
diff --git a/toolkit/components/extensions/schemas/cookies.json b/toolkit/components/webextensions/schemas/cookies.json
index a7de6eb42..a7de6eb42 100644
--- a/toolkit/components/extensions/schemas/cookies.json
+++ b/toolkit/components/webextensions/schemas/cookies.json
diff --git a/toolkit/components/extensions/schemas/downloads.json b/toolkit/components/webextensions/schemas/downloads.json
index dcd43e4e1..dcd43e4e1 100644
--- a/toolkit/components/extensions/schemas/downloads.json
+++ b/toolkit/components/webextensions/schemas/downloads.json
diff --git a/toolkit/components/extensions/schemas/events.json b/toolkit/components/webextensions/schemas/events.json
index ea3cbb5d2..ea3cbb5d2 100644
--- a/toolkit/components/extensions/schemas/events.json
+++ b/toolkit/components/webextensions/schemas/events.json
diff --git a/toolkit/components/extensions/schemas/experiments.json b/toolkit/components/webextensions/schemas/experiments.json
index c687173a9..c687173a9 100644
--- a/toolkit/components/extensions/schemas/experiments.json
+++ b/toolkit/components/webextensions/schemas/experiments.json
diff --git a/toolkit/components/extensions/schemas/extension.json b/toolkit/components/webextensions/schemas/extension.json
index 5a1b6c935..5a1b6c935 100644
--- a/toolkit/components/extensions/schemas/extension.json
+++ b/toolkit/components/webextensions/schemas/extension.json
diff --git a/toolkit/components/extensions/schemas/extension_types.json b/toolkit/components/webextensions/schemas/extension_types.json
index 1a88e4e60..1a88e4e60 100644
--- a/toolkit/components/extensions/schemas/extension_types.json
+++ b/toolkit/components/webextensions/schemas/extension_types.json
diff --git a/toolkit/components/extensions/schemas/i18n.json b/toolkit/components/webextensions/schemas/i18n.json
index 12dc45dfc..12dc45dfc 100644
--- a/toolkit/components/extensions/schemas/i18n.json
+++ b/toolkit/components/webextensions/schemas/i18n.json
diff --git a/toolkit/components/extensions/schemas/idle.json b/toolkit/components/webextensions/schemas/idle.json
index e0b3b951e..e0b3b951e 100644
--- a/toolkit/components/extensions/schemas/idle.json
+++ b/toolkit/components/webextensions/schemas/idle.json
diff --git a/toolkit/components/extensions/schemas/jar.mn b/toolkit/components/webextensions/schemas/jar.mn
index 0bdf35b0d..0bdf35b0d 100644
--- a/toolkit/components/extensions/schemas/jar.mn
+++ b/toolkit/components/webextensions/schemas/jar.mn
diff --git a/toolkit/components/extensions/schemas/management.json b/toolkit/components/webextensions/schemas/management.json
index 413ff1d0d..413ff1d0d 100644
--- a/toolkit/components/extensions/schemas/management.json
+++ b/toolkit/components/webextensions/schemas/management.json
diff --git a/toolkit/components/extensions/schemas/manifest.json b/toolkit/components/webextensions/schemas/manifest.json
index 09e6b56fb..09e6b56fb 100644
--- a/toolkit/components/extensions/schemas/manifest.json
+++ b/toolkit/components/webextensions/schemas/manifest.json
diff --git a/toolkit/components/extensions/schemas/moz.build b/toolkit/components/webextensions/schemas/moz.build
index aac3a838c..aac3a838c 100644
--- a/toolkit/components/extensions/schemas/moz.build
+++ b/toolkit/components/webextensions/schemas/moz.build
diff --git a/toolkit/components/extensions/schemas/native_host_manifest.json b/toolkit/components/webextensions/schemas/native_host_manifest.json
index 4ad2ea7f1..4ad2ea7f1 100644
--- a/toolkit/components/extensions/schemas/native_host_manifest.json
+++ b/toolkit/components/webextensions/schemas/native_host_manifest.json
diff --git a/toolkit/components/extensions/schemas/notifications.json b/toolkit/components/webextensions/schemas/notifications.json
index 12878e8c8..12878e8c8 100644
--- a/toolkit/components/extensions/schemas/notifications.json
+++ b/toolkit/components/webextensions/schemas/notifications.json
diff --git a/toolkit/components/extensions/schemas/runtime.json b/toolkit/components/webextensions/schemas/runtime.json
index b3f12a768..b3f12a768 100644
--- a/toolkit/components/extensions/schemas/runtime.json
+++ b/toolkit/components/webextensions/schemas/runtime.json
diff --git a/toolkit/components/extensions/schemas/storage.json b/toolkit/components/webextensions/schemas/storage.json
index a54a20942..a54a20942 100644
--- a/toolkit/components/extensions/schemas/storage.json
+++ b/toolkit/components/webextensions/schemas/storage.json
diff --git a/toolkit/components/extensions/schemas/test.json b/toolkit/components/webextensions/schemas/test.json
index 25a62a96b..25a62a96b 100644
--- a/toolkit/components/extensions/schemas/test.json
+++ b/toolkit/components/webextensions/schemas/test.json
diff --git a/toolkit/components/extensions/schemas/top_sites.json b/toolkit/components/webextensions/schemas/top_sites.json
index fbfbc4b62..fbfbc4b62 100644
--- a/toolkit/components/extensions/schemas/top_sites.json
+++ b/toolkit/components/webextensions/schemas/top_sites.json
diff --git a/toolkit/components/extensions/schemas/web_navigation.json b/toolkit/components/webextensions/schemas/web_navigation.json
index 1e13b181a..1e13b181a 100644
--- a/toolkit/components/extensions/schemas/web_navigation.json
+++ b/toolkit/components/webextensions/schemas/web_navigation.json
diff --git a/toolkit/components/extensions/schemas/web_request.json b/toolkit/components/webextensions/schemas/web_request.json
index 4035aea6e..4035aea6e 100644
--- a/toolkit/components/extensions/schemas/web_request.json
+++ b/toolkit/components/webextensions/schemas/web_request.json
diff --git a/toolkit/components/extensions/test/mochitest/.eslintrc.js b/toolkit/components/webextensions/test/mochitest/.eslintrc.js
index 53938410b..53938410b 100644
--- a/toolkit/components/extensions/test/mochitest/.eslintrc.js
+++ b/toolkit/components/webextensions/test/mochitest/.eslintrc.js
diff --git a/toolkit/components/extensions/test/mochitest/chrome.ini b/toolkit/components/webextensions/test/mochitest/chrome.ini
index 26585cad7..26585cad7 100644
--- a/toolkit/components/extensions/test/mochitest/chrome.ini
+++ b/toolkit/components/webextensions/test/mochitest/chrome.ini
diff --git a/toolkit/components/extensions/test/mochitest/chrome_head.js b/toolkit/components/webextensions/test/mochitest/chrome_head.js
index da2f53a02..da2f53a02 100644
--- a/toolkit/components/extensions/test/mochitest/chrome_head.js
+++ b/toolkit/components/webextensions/test/mochitest/chrome_head.js
diff --git a/toolkit/components/extensions/test/mochitest/file_WebNavigation_page1.html b/toolkit/components/webextensions/test/mochitest/file_WebNavigation_page1.html
index 663ebc611..663ebc611 100644
--- a/toolkit/components/extensions/test/mochitest/file_WebNavigation_page1.html
+++ b/toolkit/components/webextensions/test/mochitest/file_WebNavigation_page1.html
diff --git a/toolkit/components/extensions/test/mochitest/file_WebNavigation_page2.html b/toolkit/components/webextensions/test/mochitest/file_WebNavigation_page2.html
index cc1acc83d..cc1acc83d 100644
--- a/toolkit/components/extensions/test/mochitest/file_WebNavigation_page2.html
+++ b/toolkit/components/webextensions/test/mochitest/file_WebNavigation_page2.html
diff --git a/toolkit/components/extensions/test/mochitest/file_WebNavigation_page3.html b/toolkit/components/webextensions/test/mochitest/file_WebNavigation_page3.html
index a0a26a2e9..a0a26a2e9 100644
--- a/toolkit/components/extensions/test/mochitest/file_WebNavigation_page3.html
+++ b/toolkit/components/webextensions/test/mochitest/file_WebNavigation_page3.html
diff --git a/toolkit/components/extensions/test/mochitest/file_WebRequest_page3.html b/toolkit/components/webextensions/test/mochitest/file_WebRequest_page3.html
index 5807dd439..5807dd439 100644
--- a/toolkit/components/extensions/test/mochitest/file_WebRequest_page3.html
+++ b/toolkit/components/webextensions/test/mochitest/file_WebRequest_page3.html
diff --git a/toolkit/components/extensions/test/mochitest/file_csp.html b/toolkit/components/webextensions/test/mochitest/file_csp.html
index 206e44390..206e44390 100644
--- a/toolkit/components/extensions/test/mochitest/file_csp.html
+++ b/toolkit/components/webextensions/test/mochitest/file_csp.html
diff --git a/toolkit/components/extensions/test/mochitest/file_csp.html^headers^ b/toolkit/components/webextensions/test/mochitest/file_csp.html^headers^
index 4c6fa3c26..4c6fa3c26 100644
--- a/toolkit/components/extensions/test/mochitest/file_csp.html^headers^
+++ b/toolkit/components/webextensions/test/mochitest/file_csp.html^headers^
diff --git a/toolkit/components/extensions/test/mochitest/file_ext_test_api_injection.js b/toolkit/components/webextensions/test/mochitest/file_ext_test_api_injection.js
index 06dfae65e..06dfae65e 100644
--- a/toolkit/components/extensions/test/mochitest/file_ext_test_api_injection.js
+++ b/toolkit/components/webextensions/test/mochitest/file_ext_test_api_injection.js
diff --git a/toolkit/components/extensions/test/mochitest/file_image_bad.png b/toolkit/components/webextensions/test/mochitest/file_image_bad.png
index 4c3be5084..4c3be5084 100644
--- a/toolkit/components/extensions/test/mochitest/file_image_bad.png
+++ b/toolkit/components/webextensions/test/mochitest/file_image_bad.png
Binary files differ
diff --git a/toolkit/components/extensions/test/mochitest/file_image_good.png b/toolkit/components/webextensions/test/mochitest/file_image_good.png
index 769c63634..769c63634 100644
--- a/toolkit/components/extensions/test/mochitest/file_image_good.png
+++ b/toolkit/components/webextensions/test/mochitest/file_image_good.png
Binary files differ
diff --git a/toolkit/components/extensions/test/mochitest/file_image_redirect.png b/toolkit/components/webextensions/test/mochitest/file_image_redirect.png
index 4c3be5084..4c3be5084 100644
--- a/toolkit/components/extensions/test/mochitest/file_image_redirect.png
+++ b/toolkit/components/webextensions/test/mochitest/file_image_redirect.png
Binary files differ
diff --git a/toolkit/components/extensions/test/mochitest/file_mixed.html b/toolkit/components/webextensions/test/mochitest/file_mixed.html
index f3c7dda58..f3c7dda58 100644
--- a/toolkit/components/extensions/test/mochitest/file_mixed.html
+++ b/toolkit/components/webextensions/test/mochitest/file_mixed.html
diff --git a/toolkit/components/extensions/test/mochitest/file_permission_xhr.html b/toolkit/components/webextensions/test/mochitest/file_permission_xhr.html
index 22a55f90d..22a55f90d 100644
--- a/toolkit/components/extensions/test/mochitest/file_permission_xhr.html
+++ b/toolkit/components/webextensions/test/mochitest/file_permission_xhr.html
diff --git a/toolkit/components/extensions/test/mochitest/file_privilege_escalation.html b/toolkit/components/webextensions/test/mochitest/file_privilege_escalation.html
index 258f7058d..258f7058d 100644
--- a/toolkit/components/extensions/test/mochitest/file_privilege_escalation.html
+++ b/toolkit/components/webextensions/test/mochitest/file_privilege_escalation.html
diff --git a/toolkit/components/extensions/test/mochitest/file_sample.html b/toolkit/components/webextensions/test/mochitest/file_sample.html
index a20e49a1f..a20e49a1f 100644
--- a/toolkit/components/extensions/test/mochitest/file_sample.html
+++ b/toolkit/components/webextensions/test/mochitest/file_sample.html
diff --git a/toolkit/components/extensions/test/mochitest/file_script_bad.js b/toolkit/components/webextensions/test/mochitest/file_script_bad.js
index c425122c7..c425122c7 100644
--- a/toolkit/components/extensions/test/mochitest/file_script_bad.js
+++ b/toolkit/components/webextensions/test/mochitest/file_script_bad.js
diff --git a/toolkit/components/extensions/test/mochitest/file_script_good.js b/toolkit/components/webextensions/test/mochitest/file_script_good.js
index 1848edf68..1848edf68 100644
--- a/toolkit/components/extensions/test/mochitest/file_script_good.js
+++ b/toolkit/components/webextensions/test/mochitest/file_script_good.js
diff --git a/toolkit/components/extensions/test/mochitest/file_script_redirect.js b/toolkit/components/webextensions/test/mochitest/file_script_redirect.js
index c89a196c2..c89a196c2 100644
--- a/toolkit/components/extensions/test/mochitest/file_script_redirect.js
+++ b/toolkit/components/webextensions/test/mochitest/file_script_redirect.js
diff --git a/toolkit/components/extensions/test/mochitest/file_script_xhr.js b/toolkit/components/webextensions/test/mochitest/file_script_xhr.js
index 07f80eb2e..07f80eb2e 100644
--- a/toolkit/components/extensions/test/mochitest/file_script_xhr.js
+++ b/toolkit/components/webextensions/test/mochitest/file_script_xhr.js
diff --git a/toolkit/components/extensions/test/mochitest/file_style_bad.css b/toolkit/components/webextensions/test/mochitest/file_style_bad.css
index 8dbc8dc7a..8dbc8dc7a 100644
--- a/toolkit/components/extensions/test/mochitest/file_style_bad.css
+++ b/toolkit/components/webextensions/test/mochitest/file_style_bad.css
diff --git a/toolkit/components/extensions/test/mochitest/file_style_good.css b/toolkit/components/webextensions/test/mochitest/file_style_good.css
index 46f9774b5..46f9774b5 100644
--- a/toolkit/components/extensions/test/mochitest/file_style_good.css
+++ b/toolkit/components/webextensions/test/mochitest/file_style_good.css
diff --git a/toolkit/components/extensions/test/mochitest/file_style_redirect.css b/toolkit/components/webextensions/test/mochitest/file_style_redirect.css
index 8dbc8dc7a..8dbc8dc7a 100644
--- a/toolkit/components/extensions/test/mochitest/file_style_redirect.css
+++ b/toolkit/components/webextensions/test/mochitest/file_style_redirect.css
diff --git a/toolkit/components/extensions/test/mochitest/file_teardown_test.js b/toolkit/components/webextensions/test/mochitest/file_teardown_test.js
index 7246012ad..7246012ad 100644
--- a/toolkit/components/extensions/test/mochitest/file_teardown_test.js
+++ b/toolkit/components/webextensions/test/mochitest/file_teardown_test.js
diff --git a/toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect.html b/toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect.html
index cba3043f7..cba3043f7 100644
--- a/toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect.html
+++ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect.html
diff --git a/toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html b/toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html
index c5b436979..c5b436979 100644
--- a/toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html
+++ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html
diff --git a/toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html^headers^ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html^headers^
index 574a392a1..574a392a1 100644
--- a/toolkit/components/extensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html^headers^
+++ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_clientRedirect_httpHeaders.html^headers^
diff --git a/toolkit/components/extensions/test/mochitest/file_webNavigation_frameClientRedirect.html b/toolkit/components/webextensions/test/mochitest/file_webNavigation_frameClientRedirect.html
index d360bcbb1..d360bcbb1 100644
--- a/toolkit/components/extensions/test/mochitest/file_webNavigation_frameClientRedirect.html
+++ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_frameClientRedirect.html
diff --git a/toolkit/components/extensions/test/mochitest/file_webNavigation_frameRedirect.html b/toolkit/components/webextensions/test/mochitest/file_webNavigation_frameRedirect.html
index 06dbd4374..06dbd4374 100644
--- a/toolkit/components/extensions/test/mochitest/file_webNavigation_frameRedirect.html
+++ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_frameRedirect.html
diff --git a/toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe.html b/toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe.html
index 307990714..307990714 100644
--- a/toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe.html
+++ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe.html
diff --git a/toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe_page1.html b/toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe_page1.html
index 55bb7aa6a..55bb7aa6a 100644
--- a/toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe_page1.html
+++ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe_page1.html
diff --git a/toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe_page2.html b/toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe_page2.html
index 8f589f8bb..8f589f8bb 100644
--- a/toolkit/components/extensions/test/mochitest/file_webNavigation_manualSubframe_page2.html
+++ b/toolkit/components/webextensions/test/mochitest/file_webNavigation_manualSubframe_page2.html
diff --git a/toolkit/components/extensions/test/mochitest/file_with_about_blank.html b/toolkit/components/webextensions/test/mochitest/file_with_about_blank.html
index af51c2e52..af51c2e52 100644
--- a/toolkit/components/extensions/test/mochitest/file_with_about_blank.html
+++ b/toolkit/components/webextensions/test/mochitest/file_with_about_blank.html
diff --git a/toolkit/components/extensions/test/mochitest/head.js b/toolkit/components/webextensions/test/mochitest/head.js
index 1b1a29472..1b1a29472 100644
--- a/toolkit/components/extensions/test/mochitest/head.js
+++ b/toolkit/components/webextensions/test/mochitest/head.js
diff --git a/toolkit/components/extensions/test/mochitest/head_cookies.js b/toolkit/components/webextensions/test/mochitest/head_cookies.js
index 9f6966551..9f6966551 100644
--- a/toolkit/components/extensions/test/mochitest/head_cookies.js
+++ b/toolkit/components/webextensions/test/mochitest/head_cookies.js
diff --git a/toolkit/components/extensions/test/mochitest/head_webrequest.js b/toolkit/components/webextensions/test/mochitest/head_webrequest.js
index 96924e505..96924e505 100644
--- a/toolkit/components/extensions/test/mochitest/head_webrequest.js
+++ b/toolkit/components/webextensions/test/mochitest/head_webrequest.js
diff --git a/toolkit/components/extensions/test/mochitest/mochitest.ini b/toolkit/components/webextensions/test/mochitest/mochitest.ini
index 45586237e..45586237e 100644
--- a/toolkit/components/extensions/test/mochitest/mochitest.ini
+++ b/toolkit/components/webextensions/test/mochitest/mochitest.ini
diff --git a/toolkit/components/extensions/test/mochitest/redirection.sjs b/toolkit/components/webextensions/test/mochitest/redirection.sjs
index 370ecd213..370ecd213 100644
--- a/toolkit/components/extensions/test/mochitest/redirection.sjs
+++ b/toolkit/components/webextensions/test/mochitest/redirection.sjs
diff --git a/toolkit/components/extensions/test/mochitest/return_headers.sjs b/toolkit/components/webextensions/test/mochitest/return_headers.sjs
index 54e2e5fb4..54e2e5fb4 100644
--- a/toolkit/components/extensions/test/mochitest/return_headers.sjs
+++ b/toolkit/components/webextensions/test/mochitest/return_headers.sjs
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_debug_global.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_debug_global.html
index 0edf5ea86..0edf5ea86 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_debug_global.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_debug_global.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_page.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html
index 3c4774652..3c4774652 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_page.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html
index e08121a8f..e08121a8f 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_downloads_saveAs.html
index c1aaae035..c1aaae035 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_downloads_saveAs.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_eventpage_warning.html
index ecea8237e..ecea8237e 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_eventpage_warning.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_hybrid_addons.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_hybrid_addons.html
index a74c551f0..a74c551f0 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_hybrid_addons.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_hybrid_addons.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_idle.html
index 3c3063e67..3c3063e67 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_idle.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_shutdown_cleanup.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_shutdown_cleanup.html
index e3098e6b1..e3098e6b1 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_shutdown_cleanup.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_shutdown_cleanup.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_storage_cleanup.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_storage_cleanup.html
index 010769500..010769500 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_storage_cleanup.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_storage_cleanup.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_trustworthy_origin.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_trustworthy_origin.html
index 573c08806..573c08806 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_trustworthy_origin.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_trustworthy_origin.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html
index 768eb31fd..768eb31fd 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_background_events.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_webrequest_background_events.html
index a13c4d475..a13c4d475 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_background_events.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_webrequest_background_events.html
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html b/toolkit/components/webextensions/test/mochitest/test_chrome_native_messaging_paths.html
index 29a148063..29a148063 100644
--- a/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html
+++ b/toolkit/components/webextensions/test/mochitest/test_chrome_native_messaging_paths.html
diff --git a/toolkit/components/extensions/test/mochitest/test_clipboard.html b/toolkit/components/webextensions/test/mochitest/test_clipboard.html
index 900ee5f10..900ee5f10 100644
--- a/toolkit/components/extensions/test/mochitest/test_clipboard.html
+++ b/toolkit/components/webextensions/test/mochitest/test_clipboard.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_all_apis.js b/toolkit/components/webextensions/test/mochitest/test_ext_all_apis.js
index 0f617c37e..0f617c37e 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_all_apis.js
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_all_apis.js
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_background_api_injection.html b/toolkit/components/webextensions/test/mochitest/test_ext_background_api_injection.html
index f43a59f81..f43a59f81 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_api_injection.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_background_api_injection.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html b/toolkit/components/webextensions/test/mochitest/test_ext_background_canvas.html
index bff7190cb..bff7190cb 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_background_canvas.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_background_generated_url.html b/toolkit/components/webextensions/test/mochitest/test_ext_background_generated_url.html
index f4fcf3d34..f4fcf3d34 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_generated_url.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_background_generated_url.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_background_teardown.html b/toolkit/components/webextensions/test/mochitest/test_ext_background_teardown.html
index bb6b2e970..bb6b2e970 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_teardown.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_background_teardown.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_content_security_policy.html b/toolkit/components/webextensions/test/mochitest/test_ext_content_security_policy.html
index a36f29563..a36f29563 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_content_security_policy.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_content_security_policy.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html
index 39f1bfabd..39f1bfabd 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_about_blank.html
index 3766678e7..3766678e7 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_about_blank.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_api_injection.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_api_injection.html
index abf3d349f..abf3d349f 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_api_injection.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_api_injection.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_async_loading.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_async_loading.html
index d78f7ce02..d78f7ce02 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_async_loading.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_async_loading.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_context.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_context.html
index 97b1645dd..97b1645dd 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_context.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_context.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_create_iframe.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_create_iframe.html
index 8aac3e213..8aac3e213 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_create_iframe.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_create_iframe.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_css.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_css.html
index 5630a1d68..5630a1d68 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_css.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_css.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_devtools_metadata.html
index 137a3cda4..137a3cda4 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_devtools_metadata.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_exporthelpers.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html
index f3414901d..f3414901d 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_exporthelpers.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_incognito.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_incognito.html
index a2f38dce6..a2f38dce6 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_incognito.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_incognito.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_permission.html
index eaf815092..eaf815092 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_permission.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_teardown.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_teardown.html
index 33a8c4ccc..33a8c4ccc 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_teardown.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_teardown.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies.html b/toolkit/components/webextensions/test/mochitest/test_ext_cookies.html
index d414a4e46..d414a4e46 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_cookies.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_containers.html
index bc4994eec..bc4994eec 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_containers.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_expiry.html
index 3927d9e94..3927d9e94 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_expiry.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_permissions_bad.html
index 15a62855a..15a62855a 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_permissions_bad.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_permissions_good.html
index 31e83188c..31e83188c 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_permissions_good.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html b/toolkit/components/webextensions/test/mochitest/test_ext_exclude_include_globs.html
index 640522b40..640522b40 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_exclude_include_globs.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_generate.html b/toolkit/components/webextensions/test/mochitest/test_ext_generate.html
index cfafcbad9..cfafcbad9 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_generate.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_generate.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_geturl.html b/toolkit/components/webextensions/test/mochitest/test_ext_geturl.html
index 6e39c2f5d..6e39c2f5d 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_geturl.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_geturl.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_i18n.html b/toolkit/components/webextensions/test/mochitest/test_ext_i18n.html
index 1f7330bbb..1f7330bbb 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_i18n.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html b/toolkit/components/webextensions/test/mochitest/test_ext_i18n_css.html
index 7c6a8eeaa..7c6a8eeaa 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_i18n_css.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html b/toolkit/components/webextensions/test/mochitest/test_ext_inIncognitoContext_window.html
index 675cbb298..675cbb298 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_inIncognitoContext_window.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_jsversion.html b/toolkit/components/webextensions/test/mochitest/test_ext_jsversion.html
index da0c355e0..da0c355e0 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_jsversion.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_jsversion.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html b/toolkit/components/webextensions/test/mochitest/test_ext_listener_proxies.html
index ca8db873e..ca8db873e 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_listener_proxies.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html b/toolkit/components/webextensions/test/mochitest/test_ext_notifications.html
index d1b798cf9..d1b798cf9 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_notifications.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html b/toolkit/components/webextensions/test/mochitest/test_ext_permission_xhr.html
index 07967d5d0..07967d5d0 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_permission_xhr.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect.html
index 60351eaee..60351eaee 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect2.html
index dce12b21b..dce12b21b 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect2.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect_twoway.html
index e84134eff..e84134eff 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_connect_twoway.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_disconnect.html
index 5764d0a3c..5764d0a3c 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_disconnect.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_id.html b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_id.html
index 4cdefda41..4cdefda41 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_id.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_runtime_id.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html b/toolkit/components/webextensions/test/mochitest/test_ext_sandbox_var.html
index 426a71ac6..426a71ac6 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_sandbox_var.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_schema.html b/toolkit/components/webextensions/test/mochitest/test_ext_schema.html
index 8a0e11c56..8a0e11c56 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_schema.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_schema.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_doublereply.html
index a3ef37cad..a3ef37cad 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_doublereply.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_no_receiver.html
index 96af6558e..96af6558e 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_no_receiver.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply.html
index a4ac708b2..a4ac708b2 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply2.html
index 1ebc1b40f..1ebc1b40f 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply2.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_storage_content.html b/toolkit/components/webextensions/test/mochitest/test_ext_storage_content.html
index 09a33814a..09a33814a 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage_content.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_storage_content.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_storage_tab.html b/toolkit/components/webextensions/test/mochitest/test_ext_storage_tab.html
index 32d8e6af0..32d8e6af0 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage_tab.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_storage_tab.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html b/toolkit/components/webextensions/test/mochitest/test_ext_subframes_privileges.html
index 1f3a9a3c9..1f3a9a3c9 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_subframes_privileges.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_tab_teardown.html b/toolkit/components/webextensions/test/mochitest/test_ext_tab_teardown.html
index dc351e48a..dc351e48a 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_tab_teardown.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_tab_teardown.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_test.html b/toolkit/components/webextensions/test/mochitest/test_ext_test.html
index fef31e0e2..fef31e0e2 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_test.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_test.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_unload_frame.html b/toolkit/components/webextensions/test/mochitest/test_ext_unload_frame.html
index 5572de281..5572de281 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_unload_frame.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_unload_frame.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html b/toolkit/components/webextensions/test/mochitest/test_ext_web_accessible_resources.html
index fa3228739..fa3228739 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_web_accessible_resources.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html b/toolkit/components/webextensions/test/mochitest/test_ext_webnavigation.html
index 2287fd9b1..2287fd9b1 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_webnavigation.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html b/toolkit/components/webextensions/test/mochitest/test_ext_webnavigation_filters.html
index a0de5e9e5..a0de5e9e5 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_webnavigation_filters.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html b/toolkit/components/webextensions/test/mochitest/test_ext_webrequest_background_events.html
index 78efeab35..78efeab35 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_webrequest_background_events.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html b/toolkit/components/webextensions/test/mochitest/test_ext_webrequest_basic.html
index ef77fee3b..ef77fee3b 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_webrequest_basic.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_suspend.html b/toolkit/components/webextensions/test/mochitest/test_ext_webrequest_suspend.html
index c8423ec7c..c8423ec7c 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_suspend.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_webrequest_suspend.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html b/toolkit/components/webextensions/test/mochitest/test_ext_webrequest_upload.html
index 998ab9800..998ab9800 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_webrequest_upload.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_window_postMessage.html b/toolkit/components/webextensions/test/mochitest/test_ext_window_postMessage.html
index 7d49d55ba..7d49d55ba 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_window_postMessage.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_window_postMessage.html
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_xhr_capabilities.html b/toolkit/components/webextensions/test/mochitest/test_ext_xhr_capabilities.html
index 1afdadb9f..1afdadb9f 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_xhr_capabilities.html
+++ b/toolkit/components/webextensions/test/mochitest/test_ext_xhr_capabilities.html
diff --git a/toolkit/components/extensions/test/mochitest/webrequest_chromeworker.js b/toolkit/components/webextensions/test/mochitest/webrequest_chromeworker.js
index ccfb2ac1f..ccfb2ac1f 100644
--- a/toolkit/components/extensions/test/mochitest/webrequest_chromeworker.js
+++ b/toolkit/components/webextensions/test/mochitest/webrequest_chromeworker.js
diff --git a/toolkit/components/extensions/test/mochitest/webrequest_test.jsm b/toolkit/components/webextensions/test/mochitest/webrequest_test.jsm
index bfb148301..bfb148301 100644
--- a/toolkit/components/extensions/test/mochitest/webrequest_test.jsm
+++ b/toolkit/components/webextensions/test/mochitest/webrequest_test.jsm
diff --git a/toolkit/components/extensions/test/mochitest/webrequest_worker.js b/toolkit/components/webextensions/test/mochitest/webrequest_worker.js
index dcffd0857..dcffd0857 100644
--- a/toolkit/components/extensions/test/mochitest/webrequest_worker.js
+++ b/toolkit/components/webextensions/test/mochitest/webrequest_worker.js
diff --git a/toolkit/components/extensions/test/xpcshell/.eslintrc.js b/toolkit/components/webextensions/test/xpcshell/.eslintrc.js
index 3758537ef..3758537ef 100644
--- a/toolkit/components/extensions/test/xpcshell/.eslintrc.js
+++ b/toolkit/components/webextensions/test/xpcshell/.eslintrc.js
diff --git a/toolkit/components/extensions/test/xpcshell/data/file_download.html b/toolkit/components/webextensions/test/xpcshell/data/file_download.html
index d970c6325..d970c6325 100644
--- a/toolkit/components/extensions/test/xpcshell/data/file_download.html
+++ b/toolkit/components/webextensions/test/xpcshell/data/file_download.html
diff --git a/toolkit/components/extensions/test/xpcshell/data/file_download.txt b/toolkit/components/webextensions/test/xpcshell/data/file_download.txt
index 6293c7af7..6293c7af7 100644
--- a/toolkit/components/extensions/test/xpcshell/data/file_download.txt
+++ b/toolkit/components/webextensions/test/xpcshell/data/file_download.txt
diff --git a/toolkit/components/extensions/test/xpcshell/head.js b/toolkit/components/webextensions/test/xpcshell/head.js
index 9e22be6da..9e22be6da 100644
--- a/toolkit/components/extensions/test/xpcshell/head.js
+++ b/toolkit/components/webextensions/test/xpcshell/head.js
diff --git a/toolkit/components/extensions/test/xpcshell/head_native_messaging.js b/toolkit/components/webextensions/test/xpcshell/head_native_messaging.js
index f7c619b76..f7c619b76 100644
--- a/toolkit/components/extensions/test/xpcshell/head_native_messaging.js
+++ b/toolkit/components/webextensions/test/xpcshell/head_native_messaging.js
diff --git a/toolkit/components/extensions/test/xpcshell/head_sync.js b/toolkit/components/webextensions/test/xpcshell/head_sync.js
index 9b66b78e7..9b66b78e7 100644
--- a/toolkit/components/extensions/test/xpcshell/head_sync.js
+++ b/toolkit/components/webextensions/test/xpcshell/head_sync.js
diff --git a/toolkit/components/extensions/test/xpcshell/native_messaging.ini b/toolkit/components/webextensions/test/xpcshell/native_messaging.ini
index d0e1da163..d0e1da163 100644
--- a/toolkit/components/extensions/test/xpcshell/native_messaging.ini
+++ b/toolkit/components/webextensions/test/xpcshell/native_messaging.ini
diff --git a/toolkit/components/extensions/test/xpcshell/test_csp_custom_policies.js b/toolkit/components/webextensions/test/xpcshell/test_csp_custom_policies.js
index b6213baac..b6213baac 100644
--- a/toolkit/components/extensions/test/xpcshell/test_csp_custom_policies.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_csp_custom_policies.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_csp_validator.js b/toolkit/components/webextensions/test/xpcshell/test_csp_validator.js
index 59a7322bc..59a7322bc 100644
--- a/toolkit/components/extensions/test/xpcshell/test_csp_validator.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_csp_validator.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_alarms.js b/toolkit/components/webextensions/test/xpcshell/test_ext_alarms.js
index 936c984c6..936c984c6 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_alarms.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_does_not_fire.js b/toolkit/components/webextensions/test/xpcshell/test_ext_alarms_does_not_fire.js
index 11407b108..11407b108 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_does_not_fire.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_alarms_does_not_fire.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_periodic.js b/toolkit/components/webextensions/test/xpcshell/test_ext_alarms_periodic.js
index 6bcdf4e33..6bcdf4e33 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_periodic.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_alarms_periodic.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_replaces.js b/toolkit/components/webextensions/test/xpcshell/test_ext_alarms_replaces.js
index 96f61acb5..96f61acb5 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_replaces.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_alarms_replaces.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_api_permissions.js b/toolkit/components/webextensions/test/xpcshell/test_ext_api_permissions.js
index d653d0e7a..d653d0e7a 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_api_permissions.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_api_permissions.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_apimanager.js b/toolkit/components/webextensions/test/xpcshell/test_ext_apimanager.js
index 3f6672a11..3f6672a11 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_apimanager.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_apimanager.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_background_generated_load_events.js b/toolkit/components/webextensions/test/xpcshell/test_ext_background_generated_load_events.js
index 26282fcb9..26282fcb9 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_background_generated_load_events.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_background_generated_load_events.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_background_generated_reload.js b/toolkit/components/webextensions/test/xpcshell/test_ext_background_generated_reload.js
index 4bf59b798..4bf59b798 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_background_generated_reload.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_background_generated_reload.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_background_global_history.js b/toolkit/components/webextensions/test/xpcshell/test_ext_background_global_history.js
index 092a9f5b3..092a9f5b3 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_background_global_history.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_background_global_history.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_background_private_browsing.js b/toolkit/components/webextensions/test/xpcshell/test_ext_background_private_browsing.js
index 8e8b5e0b0..8e8b5e0b0 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_background_private_browsing.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_background_private_browsing.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_background_runtime_connect_params.js b/toolkit/components/webextensions/test/xpcshell/test_ext_background_runtime_connect_params.js
index 426833edd..426833edd 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_background_runtime_connect_params.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_background_runtime_connect_params.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_background_sub_windows.js b/toolkit/components/webextensions/test/xpcshell/test_ext_background_sub_windows.js
index c5f2f1332..c5f2f1332 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_background_sub_windows.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_background_sub_windows.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_background_window_properties.js b/toolkit/components/webextensions/test/xpcshell/test_ext_background_window_properties.js
index 948e2913e..948e2913e 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_background_window_properties.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_background_window_properties.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_contexts.js b/toolkit/components/webextensions/test/xpcshell/test_ext_contexts.js
index 56a14e189..56a14e189 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_contexts.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_contexts.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_downloads.js b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js
index 058b9b18c..058b9b18c 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_downloads.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_download.js b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads_download.js
index 37ddd4d7c..37ddd4d7c 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_download.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads_download.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_misc.js b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads_misc.js
index d08aab666..d08aab666 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_misc.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads_misc.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads_search.js
index 4caa82456..4caa82456 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads_search.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_experiments.js b/toolkit/components/webextensions/test/xpcshell/test_ext_experiments.js
index bc6bfcd68..bc6bfcd68 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_experiments.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_experiments.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_extension.js b/toolkit/components/webextensions/test/xpcshell/test_ext_extension.js
index f18845f6a..f18845f6a 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_extension.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_extension.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_idle.js b/toolkit/components/webextensions/test/xpcshell/test_ext_idle.js
index 89bcac217..89bcac217 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_idle.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_idle.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_json_parser.js b/toolkit/components/webextensions/test/xpcshell/test_ext_json_parser.js
index 652f41315..652f41315 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_json_parser.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_json_parser.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js b/toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_context.js
index 63d5361a1..63d5361a1 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_context.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_context.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_embedding.js b/toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_embedding.js
index ea5d78524..ea5d78524 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_embedding.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_embedding.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_localStorage.js b/toolkit/components/webextensions/test/xpcshell/test_ext_localStorage.js
index 0f0b41085..0f0b41085 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_localStorage.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_localStorage.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_management.js b/toolkit/components/webextensions/test/xpcshell/test_ext_management.js
index b19554a57..b19554a57 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_management.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_management.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_management_uninstall_self.js b/toolkit/components/webextensions/test/xpcshell/test_ext_management_uninstall_self.js
index 7d80a9c23..7d80a9c23 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_management_uninstall_self.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_management_uninstall_self.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_manifest_content_security_policy.js b/toolkit/components/webextensions/test/xpcshell/test_ext_manifest_content_security_policy.js
index 2b0084980..2b0084980 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_manifest_content_security_policy.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_manifest_content_security_policy.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_manifest_incognito.js b/toolkit/components/webextensions/test/xpcshell/test_ext_manifest_incognito.js
index 94649692e..94649692e 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_manifest_incognito.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_manifest_incognito.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_manifest_minimum_chrome_version.js b/toolkit/components/webextensions/test/xpcshell/test_ext_manifest_minimum_chrome_version.js
index fad5661bb..fad5661bb 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_manifest_minimum_chrome_version.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_manifest_minimum_chrome_version.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js b/toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging.js
index 5a6b628f5..5a6b628f5 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging_perf.js b/toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging_perf.js
index 693f67dde..693f67dde 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging_perf.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging_perf.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging_unresponsive.js b/toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging_unresponsive.js
index a75a1d49d..a75a1d49d 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging_unresponsive.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_native_messaging_unresponsive.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_onmessage_removelistener.js b/toolkit/components/webextensions/test/xpcshell/test_ext_onmessage_removelistener.js
index 6f8b553fc..6f8b553fc 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_onmessage_removelistener.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_onmessage_removelistener.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_connect_no_receiver.js b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_connect_no_receiver.js
index 2a1342cde..2a1342cde 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_connect_no_receiver.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_connect_no_receiver.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js
index a280206fa..a280206fa 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_getPlatformInfo.js b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_getPlatformInfo.js
index 29bad0c10..29bad0c10 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_getPlatformInfo.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_getPlatformInfo.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js
index fa6461412..fa6461412 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage.js b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage.js
index fec8e13dd..fec8e13dd 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js
index f1a8d5a36..f1a8d5a36 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_no_receiver.js b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_no_receiver.js
index f906333d2..f906333d2 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_no_receiver.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_no_receiver.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_self.js b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_self.js
index e4f5e951f..e4f5e951f 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_self.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_runtime_sendMessage_self.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_schemas.js b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas.js
index d838be5b5..d838be5b5 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_schemas.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_allowed_contexts.js b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_allowed_contexts.js
index 606459764..606459764 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_allowed_contexts.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_allowed_contexts.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_api_injection.js b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js
index 36d88d722..36d88d722 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_api_injection.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_async.js
index 6397d1f96..6397d1f96 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_async.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_simple.js b/toolkit/components/webextensions/test/xpcshell/test_ext_simple.js
index 91b10354c..91b10354c 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_simple.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_simple.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_storage.js b/toolkit/components/webextensions/test/xpcshell/test_ext_storage.js
index df46dfb63..df46dfb63 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_storage.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_storage.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_topSites.js b/toolkit/components/webextensions/test/xpcshell/test_ext_topSites.js
index eb3f552ed..eb3f552ed 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_topSites.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_topSites.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js b/toolkit/components/webextensions/test/xpcshell/test_getAPILevelForWindow.js
index 68741a6cc..68741a6cc 100644
--- a/toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_getAPILevelForWindow.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_locale_converter.js b/toolkit/components/webextensions/test/xpcshell/test_locale_converter.js
index c8b1ee92b..c8b1ee92b 100644
--- a/toolkit/components/extensions/test/xpcshell/test_locale_converter.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_locale_converter.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_locale_data.js b/toolkit/components/webextensions/test/xpcshell/test_locale_data.js
index c3cd44e57..c3cd44e57 100644
--- a/toolkit/components/extensions/test/xpcshell/test_locale_data.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_locale_data.js
diff --git a/toolkit/components/extensions/test/xpcshell/test_native_messaging.js b/toolkit/components/webextensions/test/xpcshell/test_native_messaging.js
index 1fcb7799e..1fcb7799e 100644
--- a/toolkit/components/extensions/test/xpcshell/test_native_messaging.js
+++ b/toolkit/components/webextensions/test/xpcshell/test_native_messaging.js
diff --git a/toolkit/components/extensions/test/xpcshell/xpcshell.ini b/toolkit/components/webextensions/test/xpcshell/xpcshell.ini
index d2c6fd5d0..d2c6fd5d0 100644
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/webextensions/test/xpcshell/xpcshell.ini
diff --git a/toolkit/jetpack/app-extension/application.ini b/toolkit/jetpack/app-extension/application.ini
new file mode 100644
index 000000000..6cec69a16
--- /dev/null
+++ b/toolkit/jetpack/app-extension/application.ini
@@ -0,0 +1,11 @@
+[App]
+Vendor=Varma
+Name=Test App
+Version=1.0
+BuildID=20060101
+Copyright=Copyright (c) 2009 Atul Varma
+ID=xulapp@toolness.com
+
+[Gecko]
+MinVersion=1.9.2.0
+MaxVersion=2.0.*
diff --git a/toolkit/jetpack/app-extension/bootstrap.js b/toolkit/jetpack/app-extension/bootstrap.js
new file mode 100644
index 000000000..c2207c75f
--- /dev/null
+++ b/toolkit/jetpack/app-extension/bootstrap.js
@@ -0,0 +1,362 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// @see http://dxr.mozilla.org/mozilla-central/source/js/src/xpconnect/loader/mozJSComponentLoader.cpp
+
+'use strict';
+
+// IMPORTANT: Avoid adding any initialization tasks here, if you need to do
+// something before add-on is loaded consider addon/runner module instead!
+
+const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu,
+ results: Cr, manager: Cm } = Components;
+const ioService = Cc['@mozilla.org/network/io-service;1'].
+ getService(Ci.nsIIOService);
+const resourceHandler = ioService.getProtocolHandler('resource').
+ QueryInterface(Ci.nsIResProtocolHandler);
+const systemPrincipal = CC('@mozilla.org/systemprincipal;1', 'nsIPrincipal')();
+const scriptLoader = Cc['@mozilla.org/moz/jssubscript-loader;1'].
+ getService(Ci.mozIJSSubScriptLoader);
+const prefService = Cc['@mozilla.org/preferences-service;1'].
+ getService(Ci.nsIPrefService).
+ QueryInterface(Ci.nsIPrefBranch);
+const appInfo = Cc["@mozilla.org/xre/app-info;1"].
+ getService(Ci.nsIXULAppInfo);
+const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
+ getService(Ci.nsIVersionComparator);
+
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
+
+const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {}).exports;
+
+
+const REASON = [ 'unknown', 'startup', 'shutdown', 'enable', 'disable',
+ 'install', 'uninstall', 'upgrade', 'downgrade' ];
+
+const bind = Function.call.bind(Function.bind);
+
+var loader = null;
+var unload = null;
+var cuddlefishSandbox = null;
+var nukeTimer = null;
+
+var resourceDomains = [];
+function setResourceSubstitution(domain, uri) {
+ resourceDomains.push(domain);
+ resourceHandler.setSubstitution(domain, uri);
+}
+
+// Utility function that synchronously reads local resource from the given
+// `uri` and returns content string.
+function readURI(uri) {
+ let channel = NetUtil.newChannel({
+ uri: NetUtil.newURI(uri, 'UTF-8'),
+ loadUsingSystemPrincipal: true
+ });
+
+ let stream = channel.open2();
+
+ let cstream = Cc['@mozilla.org/intl/converter-input-stream;1'].
+ createInstance(Ci.nsIConverterInputStream);
+ cstream.init(stream, 'UTF-8', 0, 0);
+
+ let str = {};
+ let data = '';
+ let read = 0;
+ do {
+ read = cstream.readString(0xffffffff, str);
+ data += str.value;
+ } while (read != 0);
+
+ cstream.close();
+
+ return data;
+}
+
+// We don't do anything on install & uninstall yet, but in a future
+// we should allow add-ons to cleanup after uninstall.
+function install(data, reason) {}
+function uninstall(data, reason) {}
+
+function startup(data, reasonCode) {
+ try {
+ let reason = REASON[reasonCode];
+ // URI for the root of the XPI file.
+ // 'jar:' URI if the addon is packed, 'file:' URI otherwise.
+ // (Used by l10n module in order to fetch `locale` folder)
+ let rootURI = data.resourceURI.spec;
+
+ // TODO: Maybe we should perform read harness-options.json asynchronously,
+ // since we can't do anything until 'sessionstore-windows-restored' anyway.
+ let options = JSON.parse(readURI(rootURI + './harness-options.json'));
+
+ let id = options.jetpackID;
+ let name = options.name;
+
+ // Clean the metadata
+ options.metadata[name]['permissions'] = options.metadata[name]['permissions'] || {};
+
+ // freeze the permissionss
+ Object.freeze(options.metadata[name]['permissions']);
+ // freeze the metadata
+ Object.freeze(options.metadata[name]);
+
+ // Register a new resource 'domain' for this addon which is mapping to
+ // XPI's `resources` folder.
+ // Generate the domain name by using jetpack ID, which is the extension ID
+ // by stripping common characters that doesn't work as a domain name:
+ let uuidRe =
+ /^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/;
+
+ let domain = id.
+ toLowerCase().
+ replace(/@/g, '-at-').
+ replace(/\./g, '-dot-').
+ replace(uuidRe, '$1');
+
+ let prefixURI = 'resource://' + domain + '/';
+ let resourcesURI = ioService.newURI(rootURI + '/resources/', null, null);
+ setResourceSubstitution(domain, resourcesURI);
+
+ // Create path to URLs mapping supported by loader.
+ let paths = {
+ // Relative modules resolve to add-on package lib
+ './': prefixURI + name + '/lib/',
+ './tests/': prefixURI + name + '/tests/',
+ '': 'resource://gre/modules/commonjs/'
+ };
+
+ // Maps addon lib and tests ressource folders for each package
+ paths = Object.keys(options.metadata).reduce(function(result, name) {
+ result[name + '/'] = prefixURI + name + '/lib/'
+ result[name + '/tests/'] = prefixURI + name + '/tests/'
+ return result;
+ }, paths);
+
+ // We need to map tests folder when we run sdk tests whose package name
+ // is stripped
+ if (name == 'addon-sdk')
+ paths['tests/'] = prefixURI + name + '/tests/';
+
+ let useBundledSDK = options['force-use-bundled-sdk'];
+ if (!useBundledSDK) {
+ try {
+ useBundledSDK = prefService.getBoolPref("extensions.addon-sdk.useBundledSDK");
+ }
+ catch (e) {
+ // Pref doesn't exist, allow using Firefox shipped SDK
+ }
+ }
+
+ // Starting with Firefox 21.0a1, we start using modules shipped into firefox
+ // Still allow using modules from the xpi if the manifest tell us to do so.
+ // And only try to look for sdk modules in xpi if the xpi actually ship them
+ if (options['is-sdk-bundled'] &&
+ (vc.compare(appInfo.version, '21.0a1') < 0 || useBundledSDK)) {
+ // Maps sdk module folders to their resource folder
+ paths[''] = prefixURI + 'addon-sdk/lib/';
+ // test.js is usually found in root commonjs or SDK_ROOT/lib/ folder,
+ // so that it isn't shipped in the xpi. Keep a copy of it in sdk/ folder
+ // until we no longer support SDK modules in XPI:
+ paths['test'] = prefixURI + 'addon-sdk/lib/sdk/test.js';
+ }
+
+ // Retrieve list of module folder overloads based on preferences in order to
+ // eventually used a local modules instead of files shipped into Firefox.
+ let branch = prefService.getBranch('extensions.modules.' + id + '.path');
+ paths = branch.getChildList('', {}).reduce(function (result, name) {
+ // Allows overloading of any sub folder by replacing . by / in pref name
+ let path = name.substr(1).split('.').join('/');
+ // Only accept overloading folder by ensuring always ending with `/`
+ if (path) path += '/';
+ let fileURI = branch.getCharPref(name);
+
+ // On mobile, file URI has to end with a `/` otherwise, setSubstitution
+ // takes the parent folder instead.
+ if (fileURI[fileURI.length-1] !== '/')
+ fileURI += '/';
+
+ // Maps the given file:// URI to a resource:// in order to avoid various
+ // failure that happens with file:// URI and be close to production env
+ let resourcesURI = ioService.newURI(fileURI, null, null);
+ let resName = 'extensions.modules.' + domain + '.commonjs.path' + name;
+ setResourceSubstitution(resName, resourcesURI);
+
+ result[path] = 'resource://' + resName + '/';
+ return result;
+ }, paths);
+
+ // Make version 2 of the manifest
+ let manifest = options.manifest;
+
+ // Import `cuddlefish.js` module using a Sandbox and bootstrap loader.
+ let cuddlefishPath = 'loader/cuddlefish.js';
+ let cuddlefishURI = 'resource://gre/modules/commonjs/sdk/' + cuddlefishPath;
+ if (paths['sdk/']) { // sdk folder has been overloaded
+ // (from pref, or cuddlefish is still in the xpi)
+ cuddlefishURI = paths['sdk/'] + cuddlefishPath;
+ }
+ else if (paths['']) { // root modules folder has been overloaded
+ cuddlefishURI = paths[''] + 'sdk/' + cuddlefishPath;
+ }
+
+ cuddlefishSandbox = loadSandbox(cuddlefishURI);
+ let cuddlefish = cuddlefishSandbox.exports;
+
+ // Normalize `options.mainPath` so that it looks like one that will come
+ // in a new version of linker.
+ let main = options.mainPath;
+
+ unload = cuddlefish.unload;
+ loader = cuddlefish.Loader({
+ paths: paths,
+ // modules manifest.
+ manifest: manifest,
+
+ // Add-on ID used by different APIs as a unique identifier.
+ id: id,
+ // Add-on name.
+ name: name,
+ // Add-on version.
+ version: options.metadata[name].version,
+ // Add-on package descriptor.
+ metadata: options.metadata[name],
+ // Add-on load reason.
+ loadReason: reason,
+
+ prefixURI: prefixURI,
+ // Add-on URI.
+ rootURI: rootURI,
+ // options used by system module.
+ // File to write 'OK' or 'FAIL' (exit code emulation).
+ resultFile: options.resultFile,
+ // Arguments passed as --static-args
+ staticArgs: options.staticArgs,
+
+ // Option to prevent automatic kill of firefox during tests
+ noQuit: options.no_quit,
+
+ // Add-on preferences branch name
+ preferencesBranch: options.preferencesBranch,
+
+ // Arguments related to test runner.
+ modules: {
+ '@test/options': {
+ iterations: options.iterations,
+ filter: options.filter,
+ profileMemory: options.profileMemory,
+ stopOnError: options.stopOnError,
+ verbose: options.verbose,
+ parseable: options.parseable,
+ checkMemory: options.check_memory,
+ }
+ }
+ });
+
+ let module = cuddlefish.Module('sdk/loader/cuddlefish', cuddlefishURI);
+ let require = cuddlefish.Require(loader, module);
+
+ // Init the 'sdk/webextension' module from the bootstrap addon parameter.
+ require("sdk/webextension").initFromBootstrapAddonParam(data);
+
+ require('sdk/addon/runner').startup(reason, {
+ loader: loader,
+ main: main,
+ prefsURI: rootURI + 'defaults/preferences/prefs.js'
+ });
+ } catch (error) {
+ dump('Bootstrap error: ' +
+ (error.message ? error.message : String(error)) + '\n' +
+ (error.stack || error.fileName + ': ' + error.lineNumber) + '\n');
+ throw error;
+ }
+};
+
+function loadSandbox(uri) {
+ let proto = {
+ sandboxPrototype: {
+ loadSandbox: loadSandbox,
+ ChromeWorker: ChromeWorker
+ }
+ };
+ let sandbox = Cu.Sandbox(systemPrincipal, proto);
+ // Create a fake commonjs environnement just to enable loading loader.js
+ // correctly
+ sandbox.exports = {};
+ sandbox.module = { uri: uri, exports: sandbox.exports };
+ sandbox.require = function (id) {
+ if (id !== "chrome")
+ throw new Error("Bootstrap sandbox `require` method isn't implemented.");
+
+ return Object.freeze({ Cc: Cc, Ci: Ci, Cu: Cu, Cr: Cr, Cm: Cm,
+ CC: bind(CC, Components), components: Components,
+ ChromeWorker: ChromeWorker });
+ };
+ scriptLoader.loadSubScript(uri, sandbox, 'UTF-8');
+ return sandbox;
+}
+
+function unloadSandbox(sandbox) {
+ if (Cu.getClassName(sandbox, true) == "Sandbox")
+ Cu.nukeSandbox(sandbox);
+}
+
+function setTimeout(callback, delay) {
+ let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+ timer.initWithCallback({ notify: callback }, delay,
+ Ci.nsITimer.TYPE_ONE_SHOT);
+ return timer;
+}
+
+function shutdown(data, reasonCode) {
+ let reason = REASON[reasonCode];
+ if (loader) {
+ unload(loader, reason);
+ unload = null;
+
+ // Don't waste time cleaning up if the application is shutting down
+ if (reason != "shutdown") {
+ // Avoid leaking all modules when something goes wrong with one particular
+ // module. Do not clean it up immediatly in order to allow executing some
+ // actions on addon disabling.
+ // We need to keep a reference to the timer, otherwise it is collected
+ // and won't ever fire.
+ nukeTimer = setTimeout(nukeModules, 1000);
+
+ // Bug 944951 - bootstrap.js must remove the added resource: URIs on unload
+ resourceDomains.forEach(domain => {
+ resourceHandler.setSubstitution(domain, null);
+ })
+ }
+ }
+};
+
+function nukeModules() {
+ nukeTimer = null;
+ // module objects store `exports` which comes from sandboxes
+ // We should avoid keeping link to these object to avoid leaking sandboxes
+ for (let key in loader.modules) {
+ delete loader.modules[key];
+ }
+ // Direct links to sandboxes should be removed too
+ for (let key in loader.sandboxes) {
+ let sandbox = loader.sandboxes[key];
+ delete loader.sandboxes[key];
+ // Bug 775067: From FF17 we can kill all CCW from a given sandbox
+ unloadSandbox(sandbox);
+ }
+ unloadSandbox(loader.sharedGlobalSandbox);
+ loader = null;
+
+ // both `toolkit/loader` and `system/xul-app` are loaded as JSM's via
+ // `cuddlefish.js`, and needs to be unloaded to avoid memory leaks, when
+ // the addon is unload.
+
+ unloadSandbox(cuddlefishSandbox.loaderSandbox);
+
+ // Bug 764840: We need to unload cuddlefish otherwise it will stay alive
+ // and keep a reference to this compartment.
+ unloadSandbox(cuddlefishSandbox);
+ cuddlefishSandbox = null;
+}
diff --git a/toolkit/jetpack/app-extension/install.rdf b/toolkit/jetpack/app-extension/install.rdf
new file mode 100644
index 000000000..641d1cc21
--- /dev/null
+++ b/toolkit/jetpack/app-extension/install.rdf
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>xulapp@toolness.com</em:id>
+ <em:version>1.0</em:version>
+ <em:type>2</em:type>
+ <em:bootstrap>true</em:bootstrap>
+ <em:unpack>false</em:unpack>
+
+ <!-- Firefox -->
+ <em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>26.0</em:minVersion>
+ <em:maxVersion>30.0</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+
+ <!-- Front End MetaData -->
+ <em:name>Test App</em:name>
+ <em:description>Harness for tests.</em:description>
+ <em:creator>Mozilla Corporation</em:creator>
+ <em:homepageURL></em:homepageURL>
+ <em:optionsType></em:optionsType>
+ <em:optionsURL></em:optionsURL>
+ <em:updateURL></em:updateURL>
+ </Description>
+</RDF>
diff --git a/toolkit/jetpack/dev/debuggee.js b/toolkit/jetpack/dev/debuggee.js
new file mode 100644
index 000000000..0ca0bd37a
--- /dev/null
+++ b/toolkit/jetpack/dev/debuggee.js
@@ -0,0 +1,95 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cu } = require("chrome");
+const { Class } = require("../sdk/core/heritage");
+const { MessagePort, MessageChannel } = require("../sdk/messaging");
+const { require: devtoolsRequire } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+const { DebuggerServer } = devtoolsRequire("devtools/server/main");
+
+const outputs = new WeakMap();
+const inputs = new WeakMap();
+const targets = new WeakMap();
+const transports = new WeakMap();
+
+const inputFor = port => inputs.get(port);
+const outputFor = port => outputs.get(port);
+const transportFor = port => transports.get(port);
+
+const fromTarget = target => {
+ const debuggee = new Debuggee();
+ const { port1, port2 } = new MessageChannel();
+ inputs.set(debuggee, port1);
+ outputs.set(debuggee, port2);
+ targets.set(debuggee, target);
+
+ return debuggee;
+};
+exports.fromTarget = fromTarget;
+
+const Debuggee = Class({
+ extends: MessagePort.prototype,
+ close: function() {
+ const server = transportFor(this);
+ if (server) {
+ transports.delete(this);
+ server.close();
+ }
+ outputFor(this).close();
+ },
+ start: function() {
+ const target = targets.get(this);
+ if (target.isLocalTab) {
+ // Since a remote protocol connection will be made, let's start the
+ // DebuggerServer here, once and for all tools.
+ if (!DebuggerServer.initialized) {
+ DebuggerServer.init();
+ DebuggerServer.addBrowserActors();
+ }
+
+ transports.set(this, DebuggerServer.connectPipe());
+ }
+ // TODO: Implement support for remote connections (See Bug 980421)
+ else {
+ throw Error("Remote targets are not yet supported");
+ }
+
+ // pipe messages send to the debuggee to an actual
+ // server via remote debugging protocol transport.
+ inputFor(this).addEventListener("message", ({data}) =>
+ transportFor(this).send(data));
+
+ // pipe messages received from the remote debugging
+ // server transport onto the this debuggee.
+ transportFor(this).hooks = {
+ onPacket: packet => inputFor(this).postMessage(packet),
+ onClosed: () => inputFor(this).close()
+ };
+
+ inputFor(this).start();
+ outputFor(this).start();
+ },
+ postMessage: function(data) {
+ return outputFor(this).postMessage(data);
+ },
+ get onmessage() {
+ return outputFor(this).onmessage;
+ },
+ set onmessage(onmessage) {
+ outputFor(this).onmessage = onmessage;
+ },
+ addEventListener: function(...args) {
+ return outputFor(this).addEventListener(...args);
+ },
+ removeEventListener: function(...args) {
+ return outputFor(this).removeEventListener(...args);
+ }
+});
+exports.Debuggee = Debuggee;
diff --git a/toolkit/jetpack/dev/frame-script.js b/toolkit/jetpack/dev/frame-script.js
new file mode 100644
index 000000000..33a197419
--- /dev/null
+++ b/toolkit/jetpack/dev/frame-script.js
@@ -0,0 +1,120 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+(function({content, sendSyncMessage, addMessageListener, sendAsyncMessage}) {
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const observerService = Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService);
+
+const channels = new Map();
+const handles = new WeakMap();
+
+// Takes remote port handle and creates a local one.
+// also set's up a messaging channel between them.
+// This is temporary workaround until Bug 914974 is fixed
+// and port can be transfered through message manager.
+const demarshal = (handle) => {
+ if (handle.type === "MessagePort") {
+ if (!channels.has(handle.id)) {
+ const channel = new content.MessageChannel();
+ channels.set(handle.id, channel);
+ handles.set(channel.port1, handle);
+ channel.port1.onmessage = onOutPort;
+ }
+ return channels.get(handle.id).port2;
+ }
+ return null;
+};
+
+const onOutPort = event => {
+ const handle = handles.get(event.target);
+ sendAsyncMessage("sdk/port/message", {
+ port: handle,
+ message: event.data
+ });
+};
+
+const onInPort = ({data}) => {
+ const channel = channels.get(data.port.id);
+ if (channel)
+ channel.port1.postMessage(data.message);
+};
+
+const onOutEvent = event =>
+ sendSyncMessage("sdk/event/" + event.type,
+ { type: event.type,
+ data: event.data });
+
+const onInMessage = (message) => {
+ const {type, data, origin, bubbles, cancelable, ports} = message.data;
+
+ const event = new content.MessageEvent(type, {
+ bubbles: bubbles,
+ cancelable: cancelable,
+ data: data,
+ origin: origin,
+ target: content,
+ source: content,
+ ports: ports.map(demarshal)
+ });
+ content.dispatchEvent(event);
+};
+
+const onReady = event => {
+ channels.clear();
+};
+
+addMessageListener("sdk/event/message", onInMessage);
+addMessageListener("sdk/port/message", onInPort);
+
+const observer = {
+ handleEvent: ({target, type}) => {
+ observer.observe(target, type);
+ },
+ observe: (document, topic, data) => {
+ // When frame associated with message manager is removed from document `docShell`
+ // is set to `null` but observer is still kept alive. At this point accesing
+ // `content.document` throws "can't access dead object" exceptions. In order to
+ // avoid leaking observer and logged errors observer is going to be removed when
+ // `docShell` is set to `null`.
+ if (!docShell) {
+ observerService.removeObserver(observer, topic);
+ }
+ else if (document === content.document) {
+ if (topic.endsWith("-document-interactive")) {
+ sendAsyncMessage("sdk/event/ready", {
+ type: "ready",
+ readyState: document.readyState,
+ uri: document.documentURI
+ });
+ }
+ if (topic.endsWith("-document-loaded")) {
+ sendAsyncMessage("sdk/event/load", {
+ type: "load",
+ readyState: document.readyState,
+ uri: document.documentURI
+ });
+ }
+ if (topic === "unload") {
+ channels.clear();
+ sendAsyncMessage("sdk/event/unload", {
+ type: "unload",
+ readyState: "uninitialized",
+ uri: document.documentURI
+ });
+ }
+ }
+ }
+};
+
+observerService.addObserver(observer, "content-document-interactive", false);
+observerService.addObserver(observer, "content-document-loaded", false);
+observerService.addObserver(observer, "chrome-document-interactive", false);
+observerService.addObserver(observer, "chrome-document-loaded", false);
+addEventListener("unload", observer, false);
+
+})(this);
diff --git a/toolkit/jetpack/dev/panel.js b/toolkit/jetpack/dev/panel.js
new file mode 100644
index 000000000..1ef6a303a
--- /dev/null
+++ b/toolkit/jetpack/dev/panel.js
@@ -0,0 +1,259 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cu } = require("chrome");
+const { Class } = require("../sdk/core/heritage");
+const { curry } = require("../sdk/lang/functional");
+const { EventTarget } = require("../sdk/event/target");
+const { Disposable, setup, dispose } = require("../sdk/core/disposable");
+const { emit, off, setListeners } = require("../sdk/event/core");
+const { when } = require("../sdk/event/utils");
+const { getFrameElement } = require("../sdk/window/utils");
+const { contract, validate } = require("../sdk/util/contract");
+const { data: { url: resolve }} = require("../sdk/self");
+const { identify } = require("../sdk/ui/id");
+const { isLocalURL, URL } = require("../sdk/url");
+const { encode } = require("../sdk/base64");
+const { marshal, demarshal } = require("./ports");
+const { fromTarget } = require("./debuggee");
+const { removed } = require("../sdk/dom/events");
+const { id: addonID } = require("../sdk/self");
+const { viewFor } = require("../sdk/view/core");
+const { createView } = require("./panel/view");
+
+const OUTER_FRAME_URI = module.uri.replace(/\.js$/, ".html");
+const FRAME_SCRIPT = module.uri.replace("/panel.js", "/frame-script.js");
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+const HTML_NS = "http://www.w3.org/1999/xhtml";
+
+const makeID = name =>
+ ("dev-panel-" + addonID + "-" + name).
+ split("/").join("-").
+ split(".").join("-").
+ split(" ").join("-").
+ replace(/[^A-Za-z0-9_\-]/g, "");
+
+
+// Weak mapping between `Panel` instances and their frame's
+// `nsIMessageManager`.
+const managers = new WeakMap();
+// Return `nsIMessageManager` for the given `Panel` instance.
+const managerFor = x => managers.get(x);
+
+// Weak mappinging between iframe's and their owner
+// `Panel` instances.
+const panels = new WeakMap();
+const panelFor = frame => panels.get(frame);
+
+// Weak mapping between panels and debugees they're targeting.
+const debuggees = new WeakMap();
+const debuggeeFor = panel => debuggees.get(panel);
+
+const frames = new WeakMap();
+const frameFor = panel => frames.get(panel);
+
+const setAttributes = (node, attributes) => {
+ for (var key in attributes)
+ node.setAttribute(key, attributes[key]);
+};
+
+const onStateChange = ({target, data}) => {
+ const panel = panelFor(target);
+ panel.readyState = data.readyState;
+ emit(panel, data.type, { target: panel, type: data.type });
+};
+
+// port event listener on the message manager that demarshalls
+// and forwards to the actual receiver. This is a workaround
+// until Bug 914974 is fixed.
+const onPortMessage = ({data, target}) => {
+ const port = demarshal(target, data.port);
+ if (port)
+ port.postMessage(data.message);
+};
+
+// When frame is removed from the toolbox destroy panel
+// associated with it to release all the resources.
+const onFrameRemove = frame => {
+ panelFor(frame).destroy();
+};
+
+const onFrameInited = frame => {
+ frame.style.visibility = "visible";
+}
+
+const inited = frame => new Promise(resolve => {
+ const { messageManager } = frame.frameLoader;
+ const listener = message => {
+ messageManager.removeMessageListener("sdk/event/ready", listener);
+ resolve(frame);
+ };
+ messageManager.addMessageListener("sdk/event/ready", listener);
+});
+
+const getTarget = ({target}) => target;
+
+const Panel = Class({
+ extends: Disposable,
+ implements: [EventTarget],
+ get id() {
+ return makeID(this.name || this.label);
+ },
+ readyState: "uninitialized",
+ ready: function() {
+ const { readyState } = this;
+ const isReady = readyState === "complete" ||
+ readyState === "interactive";
+ return isReady ? Promise.resolve(this) :
+ when(this, "ready").then(getTarget);
+ },
+ loaded: function() {
+ const { readyState } = this;
+ const isLoaded = readyState === "complete";
+ return isLoaded ? Promise.resolve(this) :
+ when(this, "load").then(getTarget);
+ },
+ unloaded: function() {
+ const { readyState } = this;
+ const isUninitialized = readyState === "uninitialized";
+ return isUninitialized ? Promise.resolve(this) :
+ when(this, "unload").then(getTarget);
+ },
+ postMessage: function(data, ports=[]) {
+ const manager = managerFor(this);
+ manager.sendAsyncMessage("sdk/event/message", {
+ type: "message",
+ bubbles: false,
+ cancelable: false,
+ data: data,
+ origin: this.url,
+ ports: ports.map(marshal(manager))
+ });
+ }
+});
+exports.Panel = Panel;
+
+validate.define(Panel, contract({
+ label: {
+ is: ["string"],
+ msg: "The `option.label` must be a provided"
+ },
+ tooltip: {
+ is: ["string", "undefined"],
+ msg: "The `option.tooltip` must be a string"
+ },
+ icon: {
+ is: ["string"],
+ map: x => x && resolve(x),
+ ok: x => isLocalURL(x),
+ msg: "The `options.icon` must be a valid local URI."
+ },
+ url: {
+ map: x => resolve(x.toString()),
+ is: ["string"],
+ ok: x => isLocalURL(x),
+ msg: "The `options.url` must be a valid local URI."
+ },
+ invertIconForLightTheme: {
+ is: ["boolean", "undefined"],
+ msg: "The `options.invertIconForLightTheme` must be a boolean."
+ },
+ invertIconForDarkTheme: {
+ is: ["boolean", "undefined"],
+ msg: "The `options.invertIconForDarkTheme` must be a boolean."
+ }
+}));
+
+setup.define(Panel, (panel, {window, toolbox, url}) => {
+ // Hack: Given that iframe created by devtools API is no good for us,
+ // we obtain original iframe and replace it with the one that has
+ // desired configuration.
+ const original = getFrameElement(window);
+ const container = original.parentNode;
+ original.remove();
+ const frame = createView(panel, container.ownerDocument);
+
+ // Following modifications are a temporary workaround until Bug 1049188
+ // is fixed.
+ // Enforce certain iframe customizations regardless of users request.
+ setAttributes(frame, {
+ "id": original.id,
+ "src": url,
+ "flex": 1,
+ "forceOwnRefreshDriver": "",
+ "tooltip": "aHTMLTooltip"
+ });
+ frame.style.visibility = "hidden";
+ frame.classList.add("toolbox-panel-iframe");
+ // Inject iframe into designated node until add-on author decides
+ // to inject it elsewhere instead.
+ if (!frame.parentNode)
+ container.appendChild(frame);
+
+ // associate view with a panel
+ frames.set(panel, frame);
+
+ // associate panel model with a frame view.
+ panels.set(frame, panel);
+
+ const debuggee = fromTarget(toolbox.target);
+ // associate debuggee with a panel.
+ debuggees.set(panel, debuggee);
+
+
+ // Setup listeners for the frame message manager.
+ const { messageManager } = frame.frameLoader;
+ messageManager.addMessageListener("sdk/event/ready", onStateChange);
+ messageManager.addMessageListener("sdk/event/load", onStateChange);
+ messageManager.addMessageListener("sdk/event/unload", onStateChange);
+ messageManager.addMessageListener("sdk/port/message", onPortMessage);
+ messageManager.loadFrameScript(FRAME_SCRIPT, false);
+
+ managers.set(panel, messageManager);
+
+ // destroy panel if frame is removed.
+ removed(frame).then(onFrameRemove);
+ // show frame when it is initialized.
+ inited(frame).then(onFrameInited);
+
+
+ // set listeners if there are ones defined on the prototype.
+ setListeners(panel, Object.getPrototypeOf(panel));
+
+
+ panel.setup({ debuggee: debuggee });
+});
+
+createView.define(Panel, (panel, document) => {
+ const frame = document.createElement("iframe");
+ setAttributes(frame, {
+ "sandbox": "allow-scripts",
+ // We end up using chrome iframe with forced message manager
+ // as fixing a swapFrameLoader seemed like a giant task (see
+ // Bug 1075490).
+ "type": "chrome",
+ "forcemessagemanager": true,
+ "transparent": true,
+ "seamless": "seamless",
+ });
+ return frame;
+});
+
+dispose.define(Panel, function(panel) {
+ debuggeeFor(panel).close();
+
+ debuggees.delete(panel);
+ managers.delete(panel);
+ frames.delete(panel);
+ panel.readyState = "destroyed";
+ panel.dispose();
+});
+
+viewFor.define(Panel, frameFor);
diff --git a/toolkit/jetpack/dev/panel/view.js b/toolkit/jetpack/dev/panel/view.js
new file mode 100644
index 000000000..41cf9c221
--- /dev/null
+++ b/toolkit/jetpack/dev/panel/view.js
@@ -0,0 +1,14 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { method } = require("method/core");
+
+const createView = method("dev/panel/view#createView");
+exports.createView = createView;
diff --git a/toolkit/jetpack/dev/ports.js b/toolkit/jetpack/dev/ports.js
new file mode 100644
index 000000000..a41f59eb7
--- /dev/null
+++ b/toolkit/jetpack/dev/ports.js
@@ -0,0 +1,64 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+// This module provides `marshal` and `demarshal` functions
+// that can be used to send MessagePort's over `nsIFrameMessageManager`
+// until Bug 914974 is fixed.
+
+const { add, iterator } = require("../sdk/lang/weak-set");
+const { curry } = require("../sdk/lang/functional");
+
+var id = 0;
+const ports = new WeakMap();
+
+// Takes `nsIFrameMessageManager` and `MessagePort` instances
+// and returns a handle representing given `port`. Messages
+// received on given `port` will be forwarded to a message
+// manager under `sdk/port/message` and messages like:
+// { port: { type: "MessagePort", id: 2}, data: data }
+// Where id is an identifier associated with a given `port`
+// and `data` is an `event.data` received on port.
+const marshal = curry((manager, port) => {
+ if (!ports.has(port)) {
+ id = id + 1;
+ const handle = {type: "MessagePort", id: id};
+ // Bind id to the given port
+ ports.set(port, handle);
+
+ // Obtain a weak reference to a port.
+ add(exports, port);
+
+ port.onmessage = event => {
+ manager.sendAsyncMessage("sdk/port/message", {
+ port: handle,
+ message: event.data
+ });
+ };
+
+ return handle;
+ }
+ return ports.get(port);
+});
+exports.marshal = marshal;
+
+// Takes `nsIFrameMessageManager` instance and a handle returned
+// `marshal(manager, port)` returning a `port` that was passed
+// to it. Note that `port` may be GC-ed in which case returned
+// value will be `null`.
+const demarshal = curry((manager, {type, id}) => {
+ if (type === "MessagePort") {
+ for (let port of iterator(exports)) {
+ if (id === ports.get(port).id)
+ return port;
+ }
+ }
+ return null;
+});
+exports.demarshal = demarshal;
diff --git a/toolkit/jetpack/dev/theme.js b/toolkit/jetpack/dev/theme.js
new file mode 100644
index 000000000..05930a502
--- /dev/null
+++ b/toolkit/jetpack/dev/theme.js
@@ -0,0 +1,135 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Class } = require("../sdk/core/heritage");
+const { EventTarget } = require("../sdk/event/target");
+const { Disposable, setup, dispose } = require("../sdk/core/disposable");
+const { contract, validate } = require("../sdk/util/contract");
+const { id: addonID } = require("../sdk/self");
+const { onEnable, onDisable } = require("dev/theme/hooks");
+const { isString, instanceOf, isFunction } = require("sdk/lang/type");
+const { add } = require("sdk/util/array");
+const { data } = require("../sdk/self");
+const { isLocalURL } = require("../sdk/url");
+
+const makeID = name =>
+ ("dev-theme-" + addonID + (name ? "-" + name : "")).
+ split(/[ . /]/).join("-").
+ replace(/[^A-Za-z0-9_\-]/g, "");
+
+const Theme = Class({
+ extends: Disposable,
+ implements: [EventTarget],
+
+ initialize: function(options) {
+ this.name = options.name;
+ this.label = options.label;
+ this.styles = options.styles;
+
+ // Event handlers
+ this.onEnable = options.onEnable;
+ this.onDisable = options.onDisable;
+ },
+ get id() {
+ return makeID(this.name || this.label);
+ },
+ setup: function() {
+ // Any initialization steps done at the registration time.
+ },
+ getStyles: function() {
+ if (!this.styles) {
+ return [];
+ }
+
+ if (isString(this.styles)) {
+ if (isLocalURL(this.styles)) {
+ return [data.url(this.styles)];
+ }
+ }
+
+ let result = [];
+ for (let style of this.styles) {
+ if (isString(style)) {
+ if (isLocalURL(style)) {
+ style = data.url(style);
+ }
+ add(result, style);
+ } else if (instanceOf(style, Theme)) {
+ result = result.concat(style.getStyles());
+ }
+ }
+ return result;
+ },
+ getClassList: function() {
+ let result = [];
+ for (let style of this.styles) {
+ if (instanceOf(style, Theme)) {
+ result = result.concat(style.getClassList());
+ }
+ }
+
+ if (this.name) {
+ add(result, this.name);
+ }
+
+ return result;
+ }
+});
+
+exports.Theme = Theme;
+
+// Initialization & dispose
+
+setup.define(Theme, (theme) => {
+ theme.classList = [];
+ theme.setup();
+});
+
+dispose.define(Theme, function(theme) {
+ theme.dispose();
+});
+
+// Validation
+
+validate.define(Theme, contract({
+ label: {
+ is: ["string"],
+ msg: "The `option.label` must be a provided"
+ },
+}));
+
+// Support theme events: apply and unapply the theme.
+
+onEnable.define(Theme, (theme, {window, oldTheme}) => {
+ if (isFunction(theme.onEnable)) {
+ theme.onEnable(window, oldTheme);
+ }
+});
+
+onDisable.define(Theme, (theme, {window, newTheme}) => {
+ if (isFunction(theme.onDisable)) {
+ theme.onDisable(window, newTheme);
+ }
+});
+
+// Support for built-in themes
+
+const LightTheme = Theme({
+ name: "theme-light",
+ styles: "chrome://devtools/skin/light-theme.css",
+});
+
+const DarkTheme = Theme({
+ name: "theme-dark",
+ styles: "chrome://devtools/skin/dark-theme.css",
+});
+
+exports.LightTheme = LightTheme;
+exports.DarkTheme = DarkTheme;
diff --git a/toolkit/jetpack/dev/theme/hooks.js b/toolkit/jetpack/dev/theme/hooks.js
new file mode 100644
index 000000000..9987f853b
--- /dev/null
+++ b/toolkit/jetpack/dev/theme/hooks.js
@@ -0,0 +1,17 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { method } = require("method/core");
+
+const onEnable = method("dev/theme/hooks#onEnable");
+const onDisable = method("dev/theme/hooks#onDisable");
+
+exports.onEnable = onEnable;
+exports.onDisable = onDisable;
diff --git a/toolkit/jetpack/dev/toolbox.js b/toolkit/jetpack/dev/toolbox.js
new file mode 100644
index 000000000..43f37759f
--- /dev/null
+++ b/toolkit/jetpack/dev/toolbox.js
@@ -0,0 +1,107 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cu, Cc, Ci } = require("chrome");
+const { Class } = require("../sdk/core/heritage");
+const { Disposable, setup } = require("../sdk/core/disposable");
+const { contract, validate } = require("../sdk/util/contract");
+const { each, pairs, values } = require("../sdk/util/sequence");
+const { onEnable, onDisable } = require("../dev/theme/hooks");
+
+const { gDevTools } = Cu.import("resource://devtools/client/framework/gDevTools.jsm", {});
+
+// This is temporary workaround to allow loading of the developer tools client - volcan
+// into a toolbox panel, this hack won't be necessary as soon as devtools patch will be
+// shipped in nightly, after which it can be removed. Bug 1038517
+const registerSDKURI = () => {
+ const ioService = Cc['@mozilla.org/network/io-service;1']
+ .getService(Ci.nsIIOService);
+ const resourceHandler = ioService.getProtocolHandler("resource")
+ .QueryInterface(Ci.nsIResProtocolHandler);
+
+ const uri = module.uri.replace("dev/toolbox.js", "");
+ resourceHandler.setSubstitution("sdk", ioService.newURI(uri, null, null));
+};
+
+registerSDKURI();
+
+const Tool = Class({
+ extends: Disposable,
+ setup: function(params={}) {
+ const { panels } = validate(this, params);
+ const { themes } = validate(this, params);
+
+ this.panels = panels;
+ this.themes = themes;
+
+ each(([key, Panel]) => {
+ const { url, label, tooltip, icon, invertIconForLightTheme,
+ invertIconForDarkTheme } = validate(Panel.prototype);
+ const { id } = Panel.prototype;
+
+ gDevTools.registerTool({
+ id: id,
+ url: "about:blank",
+ label: label,
+ tooltip: tooltip,
+ icon: icon,
+ invertIconForLightTheme: invertIconForLightTheme,
+ invertIconForDarkTheme: invertIconForDarkTheme,
+ isTargetSupported: target => target.isLocalTab,
+ build: (window, toolbox) => {
+ const panel = new Panel();
+ setup(panel, { window: window,
+ toolbox: toolbox,
+ url: url });
+
+ return panel.ready();
+ }
+ });
+ }, pairs(panels));
+
+ each(([key, theme]) => {
+ validate(theme);
+ setup(theme);
+
+ gDevTools.registerTheme({
+ id: theme.id,
+ label: theme.label,
+ stylesheets: theme.getStyles(),
+ classList: theme.getClassList(),
+ onApply: (window, oldTheme) => {
+ onEnable(theme, { window: window,
+ oldTheme: oldTheme });
+ },
+ onUnapply: (window, newTheme) => {
+ onDisable(theme, { window: window,
+ newTheme: newTheme });
+ }
+ });
+ }, pairs(themes));
+ },
+ dispose: function() {
+ each(Panel => gDevTools.unregisterTool(Panel.prototype.id),
+ values(this.panels));
+
+ each(Theme => gDevTools.unregisterTheme(Theme.prototype.id),
+ values(this.themes));
+ }
+});
+
+validate.define(Tool, contract({
+ panels: {
+ is: ["object", "undefined"]
+ },
+ themes: {
+ is: ["object", "undefined"]
+ }
+}));
+
+exports.Tool = Tool;
diff --git a/toolkit/jetpack/dev/utils.js b/toolkit/jetpack/dev/utils.js
new file mode 100644
index 000000000..48db39e04
--- /dev/null
+++ b/toolkit/jetpack/dev/utils.js
@@ -0,0 +1,40 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { Cu } = require("chrome");
+const { gDevTools } = Cu.import("resource://devtools/client/framework/gDevTools.jsm", {});
+const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+
+const { getActiveTab } = require("../sdk/tabs/utils");
+const { getMostRecentBrowserWindow } = require("../sdk/window/utils");
+
+const targetFor = target => {
+ target = target || getActiveTab(getMostRecentBrowserWindow());
+ return devtools.TargetFactory.forTab(target);
+};
+
+const getId = id => ((id.prototype && id.prototype.id) || id.id || id);
+
+const getCurrentPanel = toolbox => toolbox.getCurrentPanel();
+exports.getCurrentPanel = getCurrentPanel;
+
+const openToolbox = (id, tab) => {
+ id = getId(id);
+ return gDevTools.showToolbox(targetFor(tab), id);
+};
+exports.openToolbox = openToolbox;
+
+const closeToolbox = tab => gDevTools.closeToolbox(targetFor(tab));
+exports.closeToolbox = closeToolbox;
+
+const getToolbox = tab => gDevTools.getToolbox(targetFor(tab));
+exports.getToolbox = getToolbox;
+
+const openToolboxPanel = (id, tab) => {
+ id = getId(id);
+ return gDevTools.showToolbox(targetFor(tab), id).then(getCurrentPanel);
+};
+exports.openToolboxPanel = openToolboxPanel;
diff --git a/toolkit/jetpack/dev/volcan.js b/toolkit/jetpack/dev/volcan.js
new file mode 100644
index 000000000..6a68ed12d
--- /dev/null
+++ b/toolkit/jetpack/dev/volcan.js
@@ -0,0 +1,3848 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.volcan=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
+"use strict";
+
+var Client = _dereq_("../client").Client;
+
+function connect(port) {
+ var client = new Client();
+ return client.connect(port);
+}
+exports.connect = connect;
+
+},{"../client":4}],2:[function(_dereq_,module,exports){
+"use strict";
+
+exports.Promise = Promise;
+
+},{}],3:[function(_dereq_,module,exports){
+"use strict";
+
+var describe = Object.getOwnPropertyDescriptor;
+var Class = function(fields) {
+ var names = Object.keys(fields);
+ var constructor = names.indexOf("constructor") >= 0 ? fields.constructor :
+ function() {};
+ var ancestor = fields.extends || Object;
+
+ var descriptor = names.reduce(function(descriptor, key) {
+ descriptor[key] = describe(fields, key);
+ return descriptor;
+ }, {});
+
+ var prototype = Object.create(ancestor.prototype, descriptor);
+
+ constructor.prototype = prototype;
+ prototype.constructor = constructor;
+
+ return constructor;
+};
+exports.Class = Class;
+
+},{}],4:[function(_dereq_,module,exports){
+"use strict";
+
+var Class = _dereq_("./class").Class;
+var TypeSystem = _dereq_("./type-system").TypeSystem;
+var values = _dereq_("./util").values;
+var Promise = _dereq_("es6-promise").Promise;
+var MessageEvent = _dereq_("./event").MessageEvent;
+
+var specification = _dereq_("./specification/core.json");
+
+function recoverActorDescriptions(error) {
+ console.warn("Failed to fetch protocol specification (see reason below). " +
+ "Using a fallback protocal specification!",
+ error);
+ return _dereq_("./specification/protocol.json");
+}
+
+// Type to represent superviser actor relations to actors they supervise
+// in terms of lifetime management.
+var Supervisor = Class({
+ constructor: function(id) {
+ this.id = id;
+ this.workers = [];
+ }
+});
+
+var Telemetry = Class({
+ add: function(id, ms) {
+ console.log("telemetry::", id, ms)
+ }
+});
+
+// Consider making client a root actor.
+
+var Client = Class({
+ constructor: function() {
+ this.root = null;
+ this.telemetry = new Telemetry();
+
+ this.setupConnection();
+ this.setupLifeManagement();
+ this.setupTypeSystem();
+ },
+
+ setupConnection: function() {
+ this.requests = [];
+ },
+ setupLifeManagement: function() {
+ this.cache = Object.create(null);
+ this.graph = Object.create(null);
+ this.get = this.get.bind(this);
+ this.release = this.release.bind(this);
+ },
+ setupTypeSystem: function() {
+ this.typeSystem = new TypeSystem(this);
+ this.typeSystem.registerTypes(specification);
+ },
+
+ connect: function(port) {
+ var client = this;
+ return new Promise(function(resolve, reject) {
+ client.port = port;
+ port.onmessage = client.receive.bind(client);
+ client.onReady = resolve;
+ client.onFail = reject;
+
+ port.start();
+ });
+ },
+ send: function(packet) {
+ this.port.postMessage(packet);
+ },
+ request: function(packet) {
+ var client = this;
+ return new Promise(function(resolve, reject) {
+ client.requests.push(packet.to, { resolve: resolve, reject: reject });
+ client.send(packet);
+ });
+ },
+
+ receive: function(event) {
+ var packet = event.data;
+ if (!this.root) {
+ if (packet.from !== "root")
+ throw Error("Initial packet must be from root");
+ if (!("applicationType" in packet))
+ throw Error("Initial packet must contain applicationType field");
+
+ this.root = this.typeSystem.read("root", null, "root");
+ this.root
+ .protocolDescription()
+ .catch(recoverActorDescriptions)
+ .then(this.typeSystem.registerTypes.bind(this.typeSystem))
+ .then(this.onReady.bind(this, this.root), this.onFail);
+ } else {
+ var actor = this.get(packet.from) || this.root;
+ var event = actor.events[packet.type];
+ if (event) {
+ var message = new MessageEvent(packet.type, {
+ data: event.read(packet)
+ });
+ actor.dispatchEvent(message);
+ } else {
+ var index = this.requests.indexOf(actor.id);
+ if (index >= 0) {
+ var request = this.requests.splice(index, 2).pop();
+ if (packet.error)
+ request.reject(packet);
+ else
+ request.resolve(packet);
+ } else {
+ console.error(Error("Unexpected packet " + JSON.stringify(packet, 2, 2)),
+ packet,
+ this.requests.slice(0));
+ }
+ }
+ }
+ },
+
+ get: function(id) {
+ return this.cache[id];
+ },
+ supervisorOf: function(actor) {
+ for (var id in this.graph) {
+ if (this.graph[id].indexOf(actor.id) >= 0) {
+ return id;
+ }
+ }
+ },
+ workersOf: function(actor) {
+ return this.graph[actor.id];
+ },
+ supervise: function(actor, worker) {
+ var workers = this.workersOf(actor)
+ if (workers.indexOf(worker.id) < 0) {
+ workers.push(worker.id);
+ }
+ },
+ unsupervise: function(actor, worker) {
+ var workers = this.workersOf(actor);
+ var index = workers.indexOf(worker.id)
+ if (index >= 0) {
+ workers.splice(index, 1)
+ }
+ },
+
+ register: function(actor) {
+ var registered = this.get(actor.id);
+ if (!registered) {
+ this.cache[actor.id] = actor;
+ this.graph[actor.id] = [];
+ } else if (registered !== actor) {
+ throw new Error("Different actor with same id is already registered");
+ }
+ },
+ unregister: function(actor) {
+ if (this.get(actor.id)) {
+ delete this.cache[actor.id];
+ delete this.graph[actor.id];
+ }
+ },
+
+ release: function(actor) {
+ var supervisor = this.supervisorOf(actor);
+ if (supervisor)
+ this.unsupervise(supervisor, actor);
+
+ var workers = this.workersOf(actor)
+
+ if (workers) {
+ workers.map(this.get).forEach(this.release)
+ }
+ this.unregister(actor);
+ }
+});
+exports.Client = Client;
+
+},{"./class":3,"./event":5,"./specification/core.json":23,"./specification/protocol.json":24,"./type-system":25,"./util":26,"es6-promise":2}],5:[function(_dereq_,module,exports){
+"use strict";
+
+var Symbol = _dereq_("es6-symbol")
+var EventEmitter = _dereq_("events").EventEmitter;
+var Class = _dereq_("./class").Class;
+
+var $bound = Symbol("EventTarget/handleEvent");
+var $emitter = Symbol("EventTarget/emitter");
+
+function makeHandler(handler) {
+ return function(event) {
+ handler.handleEvent(event);
+ }
+}
+
+var EventTarget = Class({
+ constructor: function() {
+ Object.defineProperty(this, $emitter, {
+ enumerable: false,
+ configurable: true,
+ writable: true,
+ value: new EventEmitter()
+ });
+ },
+ addEventListener: function(type, handler) {
+ if (typeof(handler) === "function") {
+ this[$emitter].on(type, handler);
+ }
+ else if (handler && typeof(handler) === "object") {
+ if (!handler[$bound]) handler[$bound] = makeHandler(handler);
+ this[$emitter].on(type, handler[$bound]);
+ }
+ },
+ removeEventListener: function(type, handler) {
+ if (typeof(handler) === "function")
+ this[$emitter].removeListener(type, handler);
+ else if (handler && handler[$bound])
+ this[$emitter].removeListener(type, handler[$bound]);
+ },
+ dispatchEvent: function(event) {
+ event.target = this;
+ this[$emitter].emit(event.type, event);
+ }
+});
+exports.EventTarget = EventTarget;
+
+var MessageEvent = Class({
+ constructor: function(type, options) {
+ options = options || {};
+ this.type = type;
+ this.data = options.data === void(0) ? null : options.data;
+
+ this.lastEventId = options.lastEventId || "";
+ this.origin = options.origin || "";
+ this.bubbles = options.bubbles || false;
+ this.cancelable = options.cancelable || false;
+ },
+ source: null,
+ ports: null,
+ preventDefault: function() {
+ },
+ stopPropagation: function() {
+ },
+ stopImmediatePropagation: function() {
+ }
+});
+exports.MessageEvent = MessageEvent;
+
+},{"./class":3,"es6-symbol":7,"events":6}],6:[function(_dereq_,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+function EventEmitter() {
+ this._events = this._events || {};
+ this._maxListeners = this._maxListeners || undefined;
+}
+module.exports = EventEmitter;
+
+// Backwards-compat with node 0.10.x
+EventEmitter.EventEmitter = EventEmitter;
+
+EventEmitter.prototype._events = undefined;
+EventEmitter.prototype._maxListeners = undefined;
+
+// By default EventEmitters will print a warning if more than 10 listeners are
+// added to it. This is a useful default which helps finding memory leaks.
+EventEmitter.defaultMaxListeners = 10;
+
+// Obviously not all Emitters should be limited to 10. This function allows
+// that to be increased. Set to zero for unlimited.
+EventEmitter.prototype.setMaxListeners = function(n) {
+ if (!isNumber(n) || n < 0 || isNaN(n))
+ throw TypeError('n must be a positive number');
+ this._maxListeners = n;
+ return this;
+};
+
+EventEmitter.prototype.emit = function(type) {
+ var er, handler, len, args, i, listeners;
+
+ if (!this._events)
+ this._events = {};
+
+ // If there is no 'error' event listener then throw.
+ if (type === 'error') {
+ if (!this._events.error ||
+ (isObject(this._events.error) && !this._events.error.length)) {
+ er = arguments[1];
+ if (er instanceof Error) {
+ throw er; // Unhandled 'error' event
+ } else {
+ throw TypeError('Uncaught, unspecified "error" event.');
+ }
+ return false;
+ }
+ }
+
+ handler = this._events[type];
+
+ if (isUndefined(handler))
+ return false;
+
+ if (isFunction(handler)) {
+ switch (arguments.length) {
+ // fast cases
+ case 1:
+ handler.call(this);
+ break;
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ // slower
+ default:
+ len = arguments.length;
+ args = new Array(len - 1);
+ for (i = 1; i < len; i++)
+ args[i - 1] = arguments[i];
+ handler.apply(this, args);
+ }
+ } else if (isObject(handler)) {
+ len = arguments.length;
+ args = new Array(len - 1);
+ for (i = 1; i < len; i++)
+ args[i - 1] = arguments[i];
+
+ listeners = handler.slice();
+ len = listeners.length;
+ for (i = 0; i < len; i++)
+ listeners[i].apply(this, args);
+ }
+
+ return true;
+};
+
+EventEmitter.prototype.addListener = function(type, listener) {
+ var m;
+
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ if (!this._events)
+ this._events = {};
+
+ // To avoid recursion in the case that type === "newListener"! Before
+ // adding it to the listeners, first emit "newListener".
+ if (this._events.newListener)
+ this.emit('newListener', type,
+ isFunction(listener.listener) ?
+ listener.listener : listener);
+
+ if (!this._events[type])
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ else if (isObject(this._events[type]))
+ // If we've already got an array, just append.
+ this._events[type].push(listener);
+ else
+ // Adding the second element, need to change to array.
+ this._events[type] = [this._events[type], listener];
+
+ // Check for listener leak
+ if (isObject(this._events[type]) && !this._events[type].warned) {
+ var m;
+ if (!isUndefined(this._maxListeners)) {
+ m = this._maxListeners;
+ } else {
+ m = EventEmitter.defaultMaxListeners;
+ }
+
+ if (m && m > 0 && this._events[type].length > m) {
+ this._events[type].warned = true;
+ console.error('(node) warning: possible EventEmitter memory ' +
+ 'leak detected. %d listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.',
+ this._events[type].length);
+ if (typeof console.trace === 'function') {
+ // not supported in IE 10
+ console.trace();
+ }
+ }
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+
+EventEmitter.prototype.once = function(type, listener) {
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ var fired = false;
+
+ function g() {
+ this.removeListener(type, g);
+
+ if (!fired) {
+ fired = true;
+ listener.apply(this, arguments);
+ }
+ }
+
+ g.listener = listener;
+ this.on(type, g);
+
+ return this;
+};
+
+// emits a 'removeListener' event iff the listener was removed
+EventEmitter.prototype.removeListener = function(type, listener) {
+ var list, position, length, i;
+
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ if (!this._events || !this._events[type])
+ return this;
+
+ list = this._events[type];
+ length = list.length;
+ position = -1;
+
+ if (list === listener ||
+ (isFunction(list.listener) && list.listener === listener)) {
+ delete this._events[type];
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
+
+ } else if (isObject(list)) {
+ for (i = length; i-- > 0;) {
+ if (list[i] === listener ||
+ (list[i].listener && list[i].listener === listener)) {
+ position = i;
+ break;
+ }
+ }
+
+ if (position < 0)
+ return this;
+
+ if (list.length === 1) {
+ list.length = 0;
+ delete this._events[type];
+ } else {
+ list.splice(position, 1);
+ }
+
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.removeAllListeners = function(type) {
+ var key, listeners;
+
+ if (!this._events)
+ return this;
+
+ // not listening for removeListener, no need to emit
+ if (!this._events.removeListener) {
+ if (arguments.length === 0)
+ this._events = {};
+ else if (this._events[type])
+ delete this._events[type];
+ return this;
+ }
+
+ // emit removeListener for all listeners on all events
+ if (arguments.length === 0) {
+ for (key in this._events) {
+ if (key === 'removeListener') continue;
+ this.removeAllListeners(key);
+ }
+ this.removeAllListeners('removeListener');
+ this._events = {};
+ return this;
+ }
+
+ listeners = this._events[type];
+
+ if (isFunction(listeners)) {
+ this.removeListener(type, listeners);
+ } else {
+ // LIFO order
+ while (listeners.length)
+ this.removeListener(type, listeners[listeners.length - 1]);
+ }
+ delete this._events[type];
+
+ return this;
+};
+
+EventEmitter.prototype.listeners = function(type) {
+ var ret;
+ if (!this._events || !this._events[type])
+ ret = [];
+ else if (isFunction(this._events[type]))
+ ret = [this._events[type]];
+ else
+ ret = this._events[type].slice();
+ return ret;
+};
+
+EventEmitter.listenerCount = function(emitter, type) {
+ var ret;
+ if (!emitter._events || !emitter._events[type])
+ ret = 0;
+ else if (isFunction(emitter._events[type]))
+ ret = 1;
+ else
+ ret = emitter._events[type].length;
+ return ret;
+};
+
+function isFunction(arg) {
+ return typeof arg === 'function';
+}
+
+function isNumber(arg) {
+ return typeof arg === 'number';
+}
+
+function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+}
+
+function isUndefined(arg) {
+ return arg === void 0;
+}
+
+},{}],7:[function(_dereq_,module,exports){
+'use strict';
+
+module.exports = _dereq_('./is-implemented')() ? Symbol : _dereq_('./polyfill');
+
+},{"./is-implemented":8,"./polyfill":22}],8:[function(_dereq_,module,exports){
+'use strict';
+
+module.exports = function () {
+ var symbol;
+ if (typeof Symbol !== 'function') return false;
+ symbol = Symbol('test symbol');
+ try {
+ if (String(symbol) !== 'Symbol (test symbol)') return false;
+ } catch (e) { return false; }
+ if (typeof Symbol.iterator === 'symbol') return true;
+
+ // Return 'true' for polyfills
+ if (typeof Symbol.isConcatSpreadable !== 'object') return false;
+ if (typeof Symbol.isRegExp !== 'object') return false;
+ if (typeof Symbol.iterator !== 'object') return false;
+ if (typeof Symbol.toPrimitive !== 'object') return false;
+ if (typeof Symbol.toStringTag !== 'object') return false;
+ if (typeof Symbol.unscopables !== 'object') return false;
+
+ return true;
+};
+
+},{}],9:[function(_dereq_,module,exports){
+'use strict';
+
+var assign = _dereq_('es5-ext/object/assign')
+ , normalizeOpts = _dereq_('es5-ext/object/normalize-options')
+ , isCallable = _dereq_('es5-ext/object/is-callable')
+ , contains = _dereq_('es5-ext/string/#/contains')
+
+ , d;
+
+d = module.exports = function (dscr, value/*, options*/) {
+ var c, e, w, options, desc;
+ if ((arguments.length < 2) || (typeof dscr !== 'string')) {
+ options = value;
+ value = dscr;
+ dscr = null;
+ } else {
+ options = arguments[2];
+ }
+ if (dscr == null) {
+ c = w = true;
+ e = false;
+ } else {
+ c = contains.call(dscr, 'c');
+ e = contains.call(dscr, 'e');
+ w = contains.call(dscr, 'w');
+ }
+
+ desc = { value: value, configurable: c, enumerable: e, writable: w };
+ return !options ? desc : assign(normalizeOpts(options), desc);
+};
+
+d.gs = function (dscr, get, set/*, options*/) {
+ var c, e, options, desc;
+ if (typeof dscr !== 'string') {
+ options = set;
+ set = get;
+ get = dscr;
+ dscr = null;
+ } else {
+ options = arguments[3];
+ }
+ if (get == null) {
+ get = undefined;
+ } else if (!isCallable(get)) {
+ options = get;
+ get = set = undefined;
+ } else if (set == null) {
+ set = undefined;
+ } else if (!isCallable(set)) {
+ options = set;
+ set = undefined;
+ }
+ if (dscr == null) {
+ c = true;
+ e = false;
+ } else {
+ c = contains.call(dscr, 'c');
+ e = contains.call(dscr, 'e');
+ }
+
+ desc = { get: get, set: set, configurable: c, enumerable: e };
+ return !options ? desc : assign(normalizeOpts(options), desc);
+};
+
+},{"es5-ext/object/assign":10,"es5-ext/object/is-callable":13,"es5-ext/object/normalize-options":17,"es5-ext/string/#/contains":19}],10:[function(_dereq_,module,exports){
+'use strict';
+
+module.exports = _dereq_('./is-implemented')()
+ ? Object.assign
+ : _dereq_('./shim');
+
+},{"./is-implemented":11,"./shim":12}],11:[function(_dereq_,module,exports){
+'use strict';
+
+module.exports = function () {
+ var assign = Object.assign, obj;
+ if (typeof assign !== 'function') return false;
+ obj = { foo: 'raz' };
+ assign(obj, { bar: 'dwa' }, { trzy: 'trzy' });
+ return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy';
+};
+
+},{}],12:[function(_dereq_,module,exports){
+'use strict';
+
+var keys = _dereq_('../keys')
+ , value = _dereq_('../valid-value')
+
+ , max = Math.max;
+
+module.exports = function (dest, src/*, …srcn*/) {
+ var error, i, l = max(arguments.length, 2), assign;
+ dest = Object(value(dest));
+ assign = function (key) {
+ try { dest[key] = src[key]; } catch (e) {
+ if (!error) error = e;
+ }
+ };
+ for (i = 1; i < l; ++i) {
+ src = arguments[i];
+ keys(src).forEach(assign);
+ }
+ if (error !== undefined) throw error;
+ return dest;
+};
+
+},{"../keys":14,"../valid-value":18}],13:[function(_dereq_,module,exports){
+// Deprecated
+
+'use strict';
+
+module.exports = function (obj) { return typeof obj === 'function'; };
+
+},{}],14:[function(_dereq_,module,exports){
+'use strict';
+
+module.exports = _dereq_('./is-implemented')()
+ ? Object.keys
+ : _dereq_('./shim');
+
+},{"./is-implemented":15,"./shim":16}],15:[function(_dereq_,module,exports){
+'use strict';
+
+module.exports = function () {
+ try {
+ Object.keys('primitive');
+ return true;
+ } catch (e) { return false; }
+};
+
+},{}],16:[function(_dereq_,module,exports){
+'use strict';
+
+var keys = Object.keys;
+
+module.exports = function (object) {
+ return keys(object == null ? object : Object(object));
+};
+
+},{}],17:[function(_dereq_,module,exports){
+'use strict';
+
+var assign = _dereq_('./assign')
+
+ , forEach = Array.prototype.forEach
+ , create = Object.create, getPrototypeOf = Object.getPrototypeOf
+
+ , process;
+
+process = function (src, obj) {
+ var proto = getPrototypeOf(src);
+ return assign(proto ? process(proto, obj) : obj, src);
+};
+
+module.exports = function (options/*, …options*/) {
+ var result = create(null);
+ forEach.call(arguments, function (options) {
+ if (options == null) return;
+ process(Object(options), result);
+ });
+ return result;
+};
+
+},{"./assign":10}],18:[function(_dereq_,module,exports){
+'use strict';
+
+module.exports = function (value) {
+ if (value == null) throw new TypeError("Cannot use null or undefined");
+ return value;
+};
+
+},{}],19:[function(_dereq_,module,exports){
+'use strict';
+
+module.exports = _dereq_('./is-implemented')()
+ ? String.prototype.contains
+ : _dereq_('./shim');
+
+},{"./is-implemented":20,"./shim":21}],20:[function(_dereq_,module,exports){
+'use strict';
+
+var str = 'razdwatrzy';
+
+module.exports = function () {
+ if (typeof str.contains !== 'function') return false;
+ return ((str.contains('dwa') === true) && (str.contains('foo') === false));
+};
+
+},{}],21:[function(_dereq_,module,exports){
+'use strict';
+
+var indexOf = String.prototype.indexOf;
+
+module.exports = function (searchString/*, position*/) {
+ return indexOf.call(this, searchString, arguments[1]) > -1;
+};
+
+},{}],22:[function(_dereq_,module,exports){
+'use strict';
+
+var d = _dereq_('d')
+
+ , create = Object.create, defineProperties = Object.defineProperties
+ , generateName, Symbol;
+
+generateName = (function () {
+ var created = create(null);
+ return function (desc) {
+ var postfix = 0;
+ while (created[desc + (postfix || '')]) ++postfix;
+ desc += (postfix || '');
+ created[desc] = true;
+ return '@@' + desc;
+ };
+}());
+
+module.exports = Symbol = function (description) {
+ var symbol;
+ if (this instanceof Symbol) {
+ throw new TypeError('TypeError: Symbol is not a constructor');
+ }
+ symbol = create(Symbol.prototype);
+ description = (description === undefined ? '' : String(description));
+ return defineProperties(symbol, {
+ __description__: d('', description),
+ __name__: d('', generateName(description))
+ });
+};
+
+Object.defineProperties(Symbol, {
+ create: d('', Symbol('create')),
+ hasInstance: d('', Symbol('hasInstance')),
+ isConcatSpreadable: d('', Symbol('isConcatSpreadable')),
+ isRegExp: d('', Symbol('isRegExp')),
+ iterator: d('', Symbol('iterator')),
+ toPrimitive: d('', Symbol('toPrimitive')),
+ toStringTag: d('', Symbol('toStringTag')),
+ unscopables: d('', Symbol('unscopables'))
+});
+
+defineProperties(Symbol.prototype, {
+ properToString: d(function () {
+ return 'Symbol (' + this.__description__ + ')';
+ }),
+ toString: d('', function () { return this.__name__; })
+});
+Object.defineProperty(Symbol.prototype, Symbol.toPrimitive, d('',
+ function (hint) {
+ throw new TypeError("Conversion of symbol objects is not allowed");
+ }));
+Object.defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol'));
+
+},{"d":9}],23:[function(_dereq_,module,exports){
+module.exports={
+ "types": {
+ "root": {
+ "category": "actor",
+ "typeName": "root",
+ "methods": [
+ {
+ "name": "echo",
+ "request": {
+ "string": { "_arg": 0, "type": "string" }
+ },
+ "response": {
+ "string": { "_retval": "string" }
+ }
+ },
+ {
+ "name": "listTabs",
+ "request": {},
+ "response": { "_retval": "tablist" }
+ },
+ {
+ "name": "protocolDescription",
+ "request": {},
+ "response": { "_retval": "json" }
+ }
+ ],
+ "events": {
+ "tabListChanged": {}
+ }
+ },
+ "tablist": {
+ "category": "dict",
+ "typeName": "tablist",
+ "specializations": {
+ "selected": "number",
+ "tabs": "array:tab",
+ "url": "string",
+ "consoleActor": "console",
+ "inspectorActor": "inspector",
+ "styleSheetsActor": "stylesheets",
+ "styleEditorActor": "styleeditor",
+ "memoryActor": "memory",
+ "eventLoopLagActor": "eventLoopLag",
+ "preferenceActor": "preference",
+ "deviceActor": "device",
+
+ "profilerActor": "profiler",
+ "chromeDebugger": "chromeDebugger",
+ "webappsActor": "webapps"
+ }
+ },
+ "tab": {
+ "category": "actor",
+ "typeName": "tab",
+ "fields": {
+ "title": "string",
+ "url": "string",
+ "outerWindowID": "number",
+ "inspectorActor": "inspector",
+ "callWatcherActor": "call-watcher",
+ "canvasActor": "canvas",
+ "webglActor": "webgl",
+ "webaudioActor": "webaudio",
+ "storageActor": "storage",
+ "gcliActor": "gcli",
+ "memoryActor": "memory",
+ "eventLoopLag": "eventLoopLag",
+ "styleSheetsActor": "stylesheets",
+ "styleEditorActor": "styleeditor",
+
+ "consoleActor": "console",
+ "traceActor": "trace"
+ },
+ "methods": [
+ {
+ "name": "attach",
+ "request": {},
+ "response": { "_retval": "json" }
+ }
+ ],
+ "events": {
+ "tabNavigated": {
+ "typeName": "tabNavigated"
+ }
+ }
+ },
+ "console": {
+ "category": "actor",
+ "typeName": "console",
+ "methods": [
+ {
+ "name": "evaluateJS",
+ "request": {
+ "text": {
+ "_option": 0,
+ "type": "string"
+ },
+ "url": {
+ "_option": 1,
+ "type": "string"
+ },
+ "bindObjectActor": {
+ "_option": 2,
+ "type": "nullable:string"
+ },
+ "frameActor": {
+ "_option": 2,
+ "type": "nullable:string"
+ },
+ "selectedNodeActor": {
+ "_option": 2,
+ "type": "nullable:string"
+ }
+ },
+ "response": {
+ "_retval": "evaluatejsresponse"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "evaluatejsresponse": {
+ "category": "dict",
+ "typeName": "evaluatejsresponse",
+ "specializations": {
+ "result": "object",
+ "exception": "object",
+ "exceptionMessage": "string",
+ "input": "string"
+ }
+ },
+ "object": {
+ "category": "actor",
+ "typeName": "object",
+ "methods": [
+ {
+ "name": "property",
+ "request": {
+ "name": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "response": {
+ "descriptor": {
+ "_retval": "json"
+ }
+ }
+ }
+ ]
+ }
+ }
+}
+
+},{}],24:[function(_dereq_,module,exports){
+module.exports={
+ "types": {
+ "longstractor": {
+ "category": "actor",
+ "typeName": "longstractor",
+ "methods": [
+ {
+ "name": "substring",
+ "request": {
+ "type": "substring",
+ "start": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "end": {
+ "_arg": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "substring": {
+ "_retval": "primitive"
+ }
+ }
+ },
+ {
+ "name": "release",
+ "release": true,
+ "request": {
+ "type": "release"
+ },
+ "response": {}
+ }
+ ],
+ "events": {}
+ },
+ "stylesheet": {
+ "category": "actor",
+ "typeName": "stylesheet",
+ "methods": [
+ {
+ "name": "toggleDisabled",
+ "request": {
+ "type": "toggleDisabled"
+ },
+ "response": {
+ "disabled": {
+ "_retval": "boolean"
+ }
+ }
+ },
+ {
+ "name": "getText",
+ "request": {
+ "type": "getText"
+ },
+ "response": {
+ "text": {
+ "_retval": "longstring"
+ }
+ }
+ },
+ {
+ "name": "getOriginalSources",
+ "request": {
+ "type": "getOriginalSources"
+ },
+ "response": {
+ "originalSources": {
+ "_retval": "nullable:array:originalsource"
+ }
+ }
+ },
+ {
+ "name": "getOriginalLocation",
+ "request": {
+ "type": "getOriginalLocation",
+ "line": {
+ "_arg": 0,
+ "type": "number"
+ },
+ "column": {
+ "_arg": 1,
+ "type": "number"
+ }
+ },
+ "response": {
+ "_retval": "originallocationresponse"
+ }
+ },
+ {
+ "name": "update",
+ "request": {
+ "type": "update",
+ "text": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "transition": {
+ "_arg": 1,
+ "type": "boolean"
+ }
+ },
+ "response": {}
+ }
+ ],
+ "events": {
+ "property-change": {
+ "type": "propertyChange",
+ "property": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "value": {
+ "_arg": 1,
+ "type": "json"
+ }
+ },
+ "style-applied": {
+ "type": "styleApplied"
+ }
+ }
+ },
+ "originalsource": {
+ "category": "actor",
+ "typeName": "originalsource",
+ "methods": [
+ {
+ "name": "getText",
+ "request": {
+ "type": "getText"
+ },
+ "response": {
+ "text": {
+ "_retval": "longstring"
+ }
+ }
+ }
+ ],
+ "events": {}
+ },
+ "stylesheets": {
+ "category": "actor",
+ "typeName": "stylesheets",
+ "methods": [
+ {
+ "name": "getStyleSheets",
+ "request": {
+ "type": "getStyleSheets"
+ },
+ "response": {
+ "styleSheets": {
+ "_retval": "array:stylesheet"
+ }
+ }
+ },
+ {
+ "name": "addStyleSheet",
+ "request": {
+ "type": "addStyleSheet",
+ "text": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "response": {
+ "styleSheet": {
+ "_retval": "stylesheet"
+ }
+ }
+ }
+ ],
+ "events": {}
+ },
+ "originallocationresponse": {
+ "category": "dict",
+ "typeName": "originallocationresponse",
+ "specializations": {
+ "source": "string",
+ "line": "number",
+ "column": "number"
+ }
+ },
+ "domnode": {
+ "category": "actor",
+ "typeName": "domnode",
+ "methods": [
+ {
+ "name": "getNodeValue",
+ "request": {
+ "type": "getNodeValue"
+ },
+ "response": {
+ "value": {
+ "_retval": "longstring"
+ }
+ }
+ },
+ {
+ "name": "setNodeValue",
+ "request": {
+ "type": "setNodeValue",
+ "value": {
+ "_arg": 0,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "getImageData",
+ "request": {
+ "type": "getImageData",
+ "maxDim": {
+ "_arg": 0,
+ "type": "nullable:number"
+ }
+ },
+ "response": {
+ "_retval": "imageData"
+ }
+ },
+ {
+ "name": "modifyAttributes",
+ "request": {
+ "type": "modifyAttributes",
+ "modifications": {
+ "_arg": 0,
+ "type": "array:json"
+ }
+ },
+ "response": {}
+ }
+ ],
+ "events": {}
+ },
+ "appliedstyle": {
+ "category": "dict",
+ "typeName": "appliedstyle",
+ "specializations": {
+ "rule": "domstylerule#actorid",
+ "inherited": "nullable:domnode#actorid"
+ }
+ },
+ "matchedselector": {
+ "category": "dict",
+ "typeName": "matchedselector",
+ "specializations": {
+ "rule": "domstylerule#actorid",
+ "selector": "string",
+ "value": "string",
+ "status": "number"
+ }
+ },
+ "matchedselectorresponse": {
+ "category": "dict",
+ "typeName": "matchedselectorresponse",
+ "specializations": {
+ "rules": "array:domstylerule",
+ "sheets": "array:stylesheet",
+ "matched": "array:matchedselector"
+ }
+ },
+ "appliedStylesReturn": {
+ "category": "dict",
+ "typeName": "appliedStylesReturn",
+ "specializations": {
+ "entries": "array:appliedstyle",
+ "rules": "array:domstylerule",
+ "sheets": "array:stylesheet"
+ }
+ },
+ "pagestyle": {
+ "category": "actor",
+ "typeName": "pagestyle",
+ "methods": [
+ {
+ "name": "getComputed",
+ "request": {
+ "type": "getComputed",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "markMatched": {
+ "_option": 1,
+ "type": "boolean"
+ },
+ "onlyMatched": {
+ "_option": 1,
+ "type": "boolean"
+ },
+ "filter": {
+ "_option": 1,
+ "type": "string"
+ }
+ },
+ "response": {
+ "computed": {
+ "_retval": "json"
+ }
+ }
+ },
+ {
+ "name": "getMatchedSelectors",
+ "request": {
+ "type": "getMatchedSelectors",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "property": {
+ "_arg": 1,
+ "type": "string"
+ },
+ "filter": {
+ "_option": 2,
+ "type": "string"
+ }
+ },
+ "response": {
+ "_retval": "matchedselectorresponse"
+ }
+ },
+ {
+ "name": "getApplied",
+ "request": {
+ "type": "getApplied",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "inherited": {
+ "_option": 1,
+ "type": "boolean"
+ },
+ "matchedSelectors": {
+ "_option": 1,
+ "type": "boolean"
+ },
+ "filter": {
+ "_option": 1,
+ "type": "string"
+ }
+ },
+ "response": {
+ "_retval": "appliedStylesReturn"
+ }
+ },
+ {
+ "name": "getLayout",
+ "request": {
+ "type": "getLayout",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "autoMargins": {
+ "_option": 1,
+ "type": "boolean"
+ }
+ },
+ "response": {
+ "_retval": "json"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "domstylerule": {
+ "category": "actor",
+ "typeName": "domstylerule",
+ "methods": [
+ {
+ "name": "modifyProperties",
+ "request": {
+ "type": "modifyProperties",
+ "modifications": {
+ "_arg": 0,
+ "type": "array:json"
+ }
+ },
+ "response": {
+ "rule": {
+ "_retval": "domstylerule"
+ }
+ }
+ }
+ ],
+ "events": {}
+ },
+ "highlighter": {
+ "category": "actor",
+ "typeName": "highlighter",
+ "methods": [
+ {
+ "name": "showBoxModel",
+ "request": {
+ "type": "showBoxModel",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "region": {
+ "_option": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "hideBoxModel",
+ "request": {
+ "type": "hideBoxModel"
+ },
+ "response": {}
+ },
+ {
+ "name": "pick",
+ "request": {
+ "type": "pick"
+ },
+ "response": {}
+ },
+ {
+ "name": "cancelPick",
+ "request": {
+ "type": "cancelPick"
+ },
+ "response": {}
+ }
+ ],
+ "events": {}
+ },
+ "imageData": {
+ "category": "dict",
+ "typeName": "imageData",
+ "specializations": {
+ "data": "nullable:longstring",
+ "size": "json"
+ }
+ },
+ "disconnectedNode": {
+ "category": "dict",
+ "typeName": "disconnectedNode",
+ "specializations": {
+ "node": "domnode",
+ "newParents": "array:domnode"
+ }
+ },
+ "disconnectedNodeArray": {
+ "category": "dict",
+ "typeName": "disconnectedNodeArray",
+ "specializations": {
+ "nodes": "array:domnode",
+ "newParents": "array:domnode"
+ }
+ },
+ "dommutation": {
+ "category": "dict",
+ "typeName": "dommutation",
+ "specializations": {}
+ },
+ "domnodelist": {
+ "category": "actor",
+ "typeName": "domnodelist",
+ "methods": [
+ {
+ "name": "item",
+ "request": {
+ "type": "item",
+ "item": {
+ "_arg": 0,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "_retval": "disconnectedNode"
+ }
+ },
+ {
+ "name": "items",
+ "request": {
+ "type": "items",
+ "start": {
+ "_arg": 0,
+ "type": "nullable:number"
+ },
+ "end": {
+ "_arg": 1,
+ "type": "nullable:number"
+ }
+ },
+ "response": {
+ "_retval": "disconnectedNodeArray"
+ }
+ },
+ {
+ "name": "release",
+ "release": true,
+ "request": {
+ "type": "release"
+ },
+ "response": {}
+ }
+ ],
+ "events": {}
+ },
+ "domtraversalarray": {
+ "category": "dict",
+ "typeName": "domtraversalarray",
+ "specializations": {
+ "nodes": "array:domnode"
+ }
+ },
+ "domwalker": {
+ "category": "actor",
+ "typeName": "domwalker",
+ "methods": [
+ {
+ "name": "release",
+ "release": true,
+ "request": {
+ "type": "release"
+ },
+ "response": {}
+ },
+ {
+ "name": "pick",
+ "request": {
+ "type": "pick"
+ },
+ "response": {
+ "_retval": "disconnectedNode"
+ }
+ },
+ {
+ "name": "cancelPick",
+ "request": {
+ "type": "cancelPick"
+ },
+ "response": {}
+ },
+ {
+ "name": "highlight",
+ "request": {
+ "type": "highlight",
+ "node": {
+ "_arg": 0,
+ "type": "nullable:domnode"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "document",
+ "request": {
+ "type": "document",
+ "node": {
+ "_arg": 0,
+ "type": "nullable:domnode"
+ }
+ },
+ "response": {
+ "node": {
+ "_retval": "domnode"
+ }
+ }
+ },
+ {
+ "name": "documentElement",
+ "request": {
+ "type": "documentElement",
+ "node": {
+ "_arg": 0,
+ "type": "nullable:domnode"
+ }
+ },
+ "response": {
+ "node": {
+ "_retval": "domnode"
+ }
+ }
+ },
+ {
+ "name": "parents",
+ "request": {
+ "type": "parents",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "sameDocument": {
+ "_option": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "nodes": {
+ "_retval": "array:domnode"
+ }
+ }
+ },
+ {
+ "name": "retainNode",
+ "request": {
+ "type": "retainNode",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "unretainNode",
+ "request": {
+ "type": "unretainNode",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "releaseNode",
+ "request": {
+ "type": "releaseNode",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "force": {
+ "_option": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "children",
+ "request": {
+ "type": "children",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "maxNodes": {
+ "_option": 1,
+ "type": "primitive"
+ },
+ "center": {
+ "_option": 1,
+ "type": "domnode"
+ },
+ "start": {
+ "_option": 1,
+ "type": "domnode"
+ },
+ "whatToShow": {
+ "_option": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "_retval": "domtraversalarray"
+ }
+ },
+ {
+ "name": "siblings",
+ "request": {
+ "type": "siblings",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "maxNodes": {
+ "_option": 1,
+ "type": "primitive"
+ },
+ "center": {
+ "_option": 1,
+ "type": "domnode"
+ },
+ "start": {
+ "_option": 1,
+ "type": "domnode"
+ },
+ "whatToShow": {
+ "_option": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "_retval": "domtraversalarray"
+ }
+ },
+ {
+ "name": "nextSibling",
+ "request": {
+ "type": "nextSibling",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "whatToShow": {
+ "_option": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "node": {
+ "_retval": "nullable:domnode"
+ }
+ }
+ },
+ {
+ "name": "previousSibling",
+ "request": {
+ "type": "previousSibling",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "whatToShow": {
+ "_option": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "node": {
+ "_retval": "nullable:domnode"
+ }
+ }
+ },
+ {
+ "name": "querySelector",
+ "request": {
+ "type": "querySelector",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "selector": {
+ "_arg": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "_retval": "disconnectedNode"
+ }
+ },
+ {
+ "name": "querySelectorAll",
+ "request": {
+ "type": "querySelectorAll",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "selector": {
+ "_arg": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "list": {
+ "_retval": "domnodelist"
+ }
+ }
+ },
+ {
+ "name": "getSuggestionsForQuery",
+ "request": {
+ "type": "getSuggestionsForQuery",
+ "query": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "completing": {
+ "_arg": 1,
+ "type": "primitive"
+ },
+ "selectorState": {
+ "_arg": 2,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "list": {
+ "_retval": "array:array:string"
+ }
+ }
+ },
+ {
+ "name": "addPseudoClassLock",
+ "request": {
+ "type": "addPseudoClassLock",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "pseudoClass": {
+ "_arg": 1,
+ "type": "primitive"
+ },
+ "parents": {
+ "_option": 2,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "hideNode",
+ "request": {
+ "type": "hideNode",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "unhideNode",
+ "request": {
+ "type": "unhideNode",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "removePseudoClassLock",
+ "request": {
+ "type": "removePseudoClassLock",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "pseudoClass": {
+ "_arg": 1,
+ "type": "primitive"
+ },
+ "parents": {
+ "_option": 2,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "clearPseudoClassLocks",
+ "request": {
+ "type": "clearPseudoClassLocks",
+ "node": {
+ "_arg": 0,
+ "type": "nullable:domnode"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "innerHTML",
+ "request": {
+ "type": "innerHTML",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ }
+ },
+ "response": {
+ "value": {
+ "_retval": "longstring"
+ }
+ }
+ },
+ {
+ "name": "outerHTML",
+ "request": {
+ "type": "outerHTML",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ }
+ },
+ "response": {
+ "value": {
+ "_retval": "longstring"
+ }
+ }
+ },
+ {
+ "name": "setOuterHTML",
+ "request": {
+ "type": "setOuterHTML",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "value": {
+ "_arg": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "removeNode",
+ "request": {
+ "type": "removeNode",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ }
+ },
+ "response": {
+ "nextSibling": {
+ "_retval": "nullable:domnode"
+ }
+ }
+ },
+ {
+ "name": "insertBefore",
+ "request": {
+ "type": "insertBefore",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ },
+ "parent": {
+ "_arg": 1,
+ "type": "domnode"
+ },
+ "sibling": {
+ "_arg": 2,
+ "type": "nullable:domnode"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "getMutations",
+ "request": {
+ "type": "getMutations",
+ "cleanup": {
+ "_option": 0,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "mutations": {
+ "_retval": "array:dommutation"
+ }
+ }
+ },
+ {
+ "name": "isInDOMTree",
+ "request": {
+ "type": "isInDOMTree",
+ "node": {
+ "_arg": 0,
+ "type": "domnode"
+ }
+ },
+ "response": {
+ "attached": {
+ "_retval": "boolean"
+ }
+ }
+ },
+ {
+ "name": "getNodeActorFromObjectActor",
+ "request": {
+ "type": "getNodeActorFromObjectActor",
+ "objectActorID": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "response": {
+ "nodeFront": {
+ "_retval": "nullable:disconnectedNode"
+ }
+ }
+ }
+ ],
+ "events": {
+ "new-mutations": {
+ "type": "newMutations"
+ },
+ "picker-node-picked": {
+ "type": "pickerNodePicked",
+ "node": {
+ "_arg": 0,
+ "type": "disconnectedNode"
+ }
+ },
+ "picker-node-hovered": {
+ "type": "pickerNodeHovered",
+ "node": {
+ "_arg": 0,
+ "type": "disconnectedNode"
+ }
+ },
+ "highlighter-ready": {
+ "type": "highlighter-ready"
+ },
+ "highlighter-hide": {
+ "type": "highlighter-hide"
+ }
+ }
+ },
+ "inspector": {
+ "category": "actor",
+ "typeName": "inspector",
+ "methods": [
+ {
+ "name": "getWalker",
+ "request": {
+ "type": "getWalker"
+ },
+ "response": {
+ "walker": {
+ "_retval": "domwalker"
+ }
+ }
+ },
+ {
+ "name": "getPageStyle",
+ "request": {
+ "type": "getPageStyle"
+ },
+ "response": {
+ "pageStyle": {
+ "_retval": "pagestyle"
+ }
+ }
+ },
+ {
+ "name": "getHighlighter",
+ "request": {
+ "type": "getHighlighter",
+ "autohide": {
+ "_arg": 0,
+ "type": "boolean"
+ }
+ },
+ "response": {
+ "highligter": {
+ "_retval": "highlighter"
+ }
+ }
+ },
+ {
+ "name": "getImageDataFromURL",
+ "request": {
+ "type": "getImageDataFromURL",
+ "url": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "maxDim": {
+ "_arg": 1,
+ "type": "nullable:number"
+ }
+ },
+ "response": {
+ "_retval": "imageData"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "call-stack-item": {
+ "category": "dict",
+ "typeName": "call-stack-item",
+ "specializations": {
+ "name": "string",
+ "file": "string",
+ "line": "number"
+ }
+ },
+ "call-details": {
+ "category": "dict",
+ "typeName": "call-details",
+ "specializations": {
+ "type": "number",
+ "name": "string",
+ "stack": "array:call-stack-item"
+ }
+ },
+ "function-call": {
+ "category": "actor",
+ "typeName": "function-call",
+ "methods": [
+ {
+ "name": "getDetails",
+ "request": {
+ "type": "getDetails"
+ },
+ "response": {
+ "info": {
+ "_retval": "call-details"
+ }
+ }
+ }
+ ],
+ "events": {}
+ },
+ "call-watcher": {
+ "category": "actor",
+ "typeName": "call-watcher",
+ "methods": [
+ {
+ "name": "setup",
+ "oneway": true,
+ "request": {
+ "type": "setup",
+ "tracedGlobals": {
+ "_option": 0,
+ "type": "nullable:array:string"
+ },
+ "tracedFunctions": {
+ "_option": 0,
+ "type": "nullable:array:string"
+ },
+ "startRecording": {
+ "_option": 0,
+ "type": "boolean"
+ },
+ "performReload": {
+ "_option": 0,
+ "type": "boolean"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "finalize",
+ "oneway": true,
+ "request": {
+ "type": "finalize"
+ },
+ "response": {}
+ },
+ {
+ "name": "isRecording",
+ "request": {
+ "type": "isRecording"
+ },
+ "response": {
+ "_retval": "boolean"
+ }
+ },
+ {
+ "name": "resumeRecording",
+ "request": {
+ "type": "resumeRecording"
+ },
+ "response": {}
+ },
+ {
+ "name": "pauseRecording",
+ "request": {
+ "type": "pauseRecording"
+ },
+ "response": {
+ "calls": {
+ "_retval": "array:function-call"
+ }
+ }
+ },
+ {
+ "name": "eraseRecording",
+ "request": {
+ "type": "eraseRecording"
+ },
+ "response": {}
+ }
+ ],
+ "events": {}
+ },
+ "snapshot-image": {
+ "category": "dict",
+ "typeName": "snapshot-image",
+ "specializations": {
+ "index": "number",
+ "width": "number",
+ "height": "number",
+ "flipped": "boolean",
+ "pixels": "uint32-array"
+ }
+ },
+ "snapshot-overview": {
+ "category": "dict",
+ "typeName": "snapshot-overview",
+ "specializations": {
+ "calls": "array:function-call",
+ "thumbnails": "array:snapshot-image",
+ "screenshot": "snapshot-image"
+ }
+ },
+ "frame-snapshot": {
+ "category": "actor",
+ "typeName": "frame-snapshot",
+ "methods": [
+ {
+ "name": "getOverview",
+ "request": {
+ "type": "getOverview"
+ },
+ "response": {
+ "overview": {
+ "_retval": "snapshot-overview"
+ }
+ }
+ },
+ {
+ "name": "generateScreenshotFor",
+ "request": {
+ "type": "generateScreenshotFor",
+ "call": {
+ "_arg": 0,
+ "type": "function-call"
+ }
+ },
+ "response": {
+ "screenshot": {
+ "_retval": "snapshot-image"
+ }
+ }
+ }
+ ],
+ "events": {}
+ },
+ "canvas": {
+ "category": "actor",
+ "typeName": "canvas",
+ "methods": [
+ {
+ "name": "setup",
+ "oneway": true,
+ "request": {
+ "type": "setup",
+ "reload": {
+ "_option": 0,
+ "type": "boolean"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "finalize",
+ "oneway": true,
+ "request": {
+ "type": "finalize"
+ },
+ "response": {}
+ },
+ {
+ "name": "isInitialized",
+ "request": {
+ "type": "isInitialized"
+ },
+ "response": {
+ "initialized": {
+ "_retval": "boolean"
+ }
+ }
+ },
+ {
+ "name": "recordAnimationFrame",
+ "request": {
+ "type": "recordAnimationFrame"
+ },
+ "response": {
+ "snapshot": {
+ "_retval": "frame-snapshot"
+ }
+ }
+ }
+ ],
+ "events": {}
+ },
+ "gl-shader": {
+ "category": "actor",
+ "typeName": "gl-shader",
+ "methods": [
+ {
+ "name": "getText",
+ "request": {
+ "type": "getText"
+ },
+ "response": {
+ "text": {
+ "_retval": "string"
+ }
+ }
+ },
+ {
+ "name": "compile",
+ "request": {
+ "type": "compile",
+ "text": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "response": {
+ "error": {
+ "_retval": "nullable:json"
+ }
+ }
+ }
+ ],
+ "events": {}
+ },
+ "gl-program": {
+ "category": "actor",
+ "typeName": "gl-program",
+ "methods": [
+ {
+ "name": "getVertexShader",
+ "request": {
+ "type": "getVertexShader"
+ },
+ "response": {
+ "shader": {
+ "_retval": "gl-shader"
+ }
+ }
+ },
+ {
+ "name": "getFragmentShader",
+ "request": {
+ "type": "getFragmentShader"
+ },
+ "response": {
+ "shader": {
+ "_retval": "gl-shader"
+ }
+ }
+ },
+ {
+ "name": "highlight",
+ "oneway": true,
+ "request": {
+ "type": "highlight",
+ "tint": {
+ "_arg": 0,
+ "type": "array:number"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "unhighlight",
+ "oneway": true,
+ "request": {
+ "type": "unhighlight"
+ },
+ "response": {}
+ },
+ {
+ "name": "blackbox",
+ "oneway": true,
+ "request": {
+ "type": "blackbox"
+ },
+ "response": {}
+ },
+ {
+ "name": "unblackbox",
+ "oneway": true,
+ "request": {
+ "type": "unblackbox"
+ },
+ "response": {}
+ }
+ ],
+ "events": {}
+ },
+ "webgl": {
+ "category": "actor",
+ "typeName": "webgl",
+ "methods": [
+ {
+ "name": "setup",
+ "oneway": true,
+ "request": {
+ "type": "setup",
+ "reload": {
+ "_option": 0,
+ "type": "boolean"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "finalize",
+ "oneway": true,
+ "request": {
+ "type": "finalize"
+ },
+ "response": {}
+ },
+ {
+ "name": "getPrograms",
+ "request": {
+ "type": "getPrograms"
+ },
+ "response": {
+ "programs": {
+ "_retval": "array:gl-program"
+ }
+ }
+ }
+ ],
+ "events": {
+ "program-linked": {
+ "type": "programLinked",
+ "program": {
+ "_arg": 0,
+ "type": "gl-program"
+ }
+ }
+ }
+ },
+ "audionode": {
+ "category": "actor",
+ "typeName": "audionode",
+ "methods": [
+ {
+ "name": "getType",
+ "request": {
+ "type": "getType"
+ },
+ "response": {
+ "type": {
+ "_retval": "string"
+ }
+ }
+ },
+ {
+ "name": "isSource",
+ "request": {
+ "type": "isSource"
+ },
+ "response": {
+ "source": {
+ "_retval": "boolean"
+ }
+ }
+ },
+ {
+ "name": "setParam",
+ "request": {
+ "type": "setParam",
+ "param": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "value": {
+ "_arg": 1,
+ "type": "nullable:primitive"
+ }
+ },
+ "response": {
+ "error": {
+ "_retval": "nullable:json"
+ }
+ }
+ },
+ {
+ "name": "getParam",
+ "request": {
+ "type": "getParam",
+ "param": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "response": {
+ "text": {
+ "_retval": "nullable:primitive"
+ }
+ }
+ },
+ {
+ "name": "getParamFlags",
+ "request": {
+ "type": "getParamFlags",
+ "param": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "response": {
+ "flags": {
+ "_retval": "nullable:primitive"
+ }
+ }
+ },
+ {
+ "name": "getParams",
+ "request": {
+ "type": "getParams"
+ },
+ "response": {
+ "params": {
+ "_retval": "json"
+ }
+ }
+ }
+ ],
+ "events": {}
+ },
+ "webaudio": {
+ "category": "actor",
+ "typeName": "webaudio",
+ "methods": [
+ {
+ "name": "setup",
+ "oneway": true,
+ "request": {
+ "type": "setup",
+ "reload": {
+ "_option": 0,
+ "type": "boolean"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "finalize",
+ "oneway": true,
+ "request": {
+ "type": "finalize"
+ },
+ "response": {}
+ }
+ ],
+ "events": {
+ "start-context": {
+ "type": "startContext"
+ },
+ "connect-node": {
+ "type": "connectNode",
+ "source": {
+ "_option": 0,
+ "type": "audionode"
+ },
+ "dest": {
+ "_option": 0,
+ "type": "audionode"
+ }
+ },
+ "disconnect-node": {
+ "type": "disconnectNode",
+ "source": {
+ "_arg": 0,
+ "type": "audionode"
+ }
+ },
+ "connect-param": {
+ "type": "connectParam",
+ "source": {
+ "_arg": 0,
+ "type": "audionode"
+ },
+ "param": {
+ "_arg": 1,
+ "type": "string"
+ }
+ },
+ "change-param": {
+ "type": "changeParam",
+ "source": {
+ "_option": 0,
+ "type": "audionode"
+ },
+ "param": {
+ "_option": 0,
+ "type": "string"
+ },
+ "value": {
+ "_option": 0,
+ "type": "string"
+ }
+ },
+ "create-node": {
+ "type": "createNode",
+ "source": {
+ "_arg": 0,
+ "type": "audionode"
+ }
+ }
+ }
+ },
+ "old-stylesheet": {
+ "category": "actor",
+ "typeName": "old-stylesheet",
+ "methods": [
+ {
+ "name": "toggleDisabled",
+ "request": {
+ "type": "toggleDisabled"
+ },
+ "response": {
+ "disabled": {
+ "_retval": "boolean"
+ }
+ }
+ },
+ {
+ "name": "fetchSource",
+ "request": {
+ "type": "fetchSource"
+ },
+ "response": {}
+ },
+ {
+ "name": "update",
+ "request": {
+ "type": "update",
+ "text": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "transition": {
+ "_arg": 1,
+ "type": "boolean"
+ }
+ },
+ "response": {}
+ }
+ ],
+ "events": {
+ "property-change": {
+ "type": "propertyChange",
+ "property": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "value": {
+ "_arg": 1,
+ "type": "json"
+ }
+ },
+ "source-load": {
+ "type": "sourceLoad",
+ "source": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "style-applied": {
+ "type": "styleApplied"
+ }
+ }
+ },
+ "styleeditor": {
+ "category": "actor",
+ "typeName": "styleeditor",
+ "methods": [
+ {
+ "name": "newDocument",
+ "request": {
+ "type": "newDocument"
+ },
+ "response": {}
+ },
+ {
+ "name": "newStyleSheet",
+ "request": {
+ "type": "newStyleSheet",
+ "text": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "response": {
+ "styleSheet": {
+ "_retval": "old-stylesheet"
+ }
+ }
+ }
+ ],
+ "events": {
+ "document-load": {
+ "type": "documentLoad",
+ "styleSheets": {
+ "_arg": 0,
+ "type": "array:old-stylesheet"
+ }
+ }
+ }
+ },
+ "cookieobject": {
+ "category": "dict",
+ "typeName": "cookieobject",
+ "specializations": {
+ "name": "string",
+ "value": "longstring",
+ "path": "nullable:string",
+ "host": "string",
+ "isDomain": "boolean",
+ "isSecure": "boolean",
+ "isHttpOnly": "boolean",
+ "creationTime": "number",
+ "lastAccessed": "number",
+ "expires": "number"
+ }
+ },
+ "cookiestoreobject": {
+ "category": "dict",
+ "typeName": "cookiestoreobject",
+ "specializations": {
+ "total": "number",
+ "offset": "number",
+ "data": "array:nullable:cookieobject"
+ }
+ },
+ "storageobject": {
+ "category": "dict",
+ "typeName": "storageobject",
+ "specializations": {
+ "name": "string",
+ "value": "longstring"
+ }
+ },
+ "storagestoreobject": {
+ "category": "dict",
+ "typeName": "storagestoreobject",
+ "specializations": {
+ "total": "number",
+ "offset": "number",
+ "data": "array:nullable:storageobject"
+ }
+ },
+ "idbobject": {
+ "category": "dict",
+ "typeName": "idbobject",
+ "specializations": {
+ "name": "nullable:string",
+ "db": "nullable:string",
+ "objectStore": "nullable:string",
+ "origin": "nullable:string",
+ "version": "nullable:number",
+ "objectStores": "nullable:number",
+ "keyPath": "nullable:string",
+ "autoIncrement": "nullable:boolean",
+ "indexes": "nullable:string",
+ "value": "nullable:longstring"
+ }
+ },
+ "idbstoreobject": {
+ "category": "dict",
+ "typeName": "idbstoreobject",
+ "specializations": {
+ "total": "number",
+ "offset": "number",
+ "data": "array:nullable:idbobject"
+ }
+ },
+ "storeUpdateObject": {
+ "category": "dict",
+ "typeName": "storeUpdateObject",
+ "specializations": {
+ "changed": "nullable:json",
+ "deleted": "nullable:json",
+ "added": "nullable:json"
+ }
+ },
+ "cookies": {
+ "category": "actor",
+ "typeName": "cookies",
+ "methods": [
+ {
+ "name": "getStoreObjects",
+ "request": {
+ "type": "getStoreObjects",
+ "host": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "names": {
+ "_arg": 1,
+ "type": "nullable:array:string"
+ },
+ "options": {
+ "_arg": 2,
+ "type": "nullable:json"
+ }
+ },
+ "response": {
+ "_retval": "cookiestoreobject"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "localStorage": {
+ "category": "actor",
+ "typeName": "localStorage",
+ "methods": [
+ {
+ "name": "getStoreObjects",
+ "request": {
+ "type": "getStoreObjects",
+ "host": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "names": {
+ "_arg": 1,
+ "type": "nullable:array:string"
+ },
+ "options": {
+ "_arg": 2,
+ "type": "nullable:json"
+ }
+ },
+ "response": {
+ "_retval": "storagestoreobject"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "sessionStorage": {
+ "category": "actor",
+ "typeName": "sessionStorage",
+ "methods": [
+ {
+ "name": "getStoreObjects",
+ "request": {
+ "type": "getStoreObjects",
+ "host": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "names": {
+ "_arg": 1,
+ "type": "nullable:array:string"
+ },
+ "options": {
+ "_arg": 2,
+ "type": "nullable:json"
+ }
+ },
+ "response": {
+ "_retval": "storagestoreobject"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "indexedDB": {
+ "category": "actor",
+ "typeName": "indexedDB",
+ "methods": [
+ {
+ "name": "getStoreObjects",
+ "request": {
+ "type": "getStoreObjects",
+ "host": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "names": {
+ "_arg": 1,
+ "type": "nullable:array:string"
+ },
+ "options": {
+ "_arg": 2,
+ "type": "nullable:json"
+ }
+ },
+ "response": {
+ "_retval": "idbstoreobject"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "storelist": {
+ "category": "dict",
+ "typeName": "storelist",
+ "specializations": {
+ "cookies": "cookies",
+ "localStorage": "localStorage",
+ "sessionStorage": "sessionStorage",
+ "indexedDB": "indexedDB"
+ }
+ },
+ "storage": {
+ "category": "actor",
+ "typeName": "storage",
+ "methods": [
+ {
+ "name": "listStores",
+ "request": {
+ "type": "listStores"
+ },
+ "response": {
+ "_retval": "storelist"
+ }
+ }
+ ],
+ "events": {
+ "stores-update": {
+ "type": "storesUpdate",
+ "data": {
+ "_arg": 0,
+ "type": "storeUpdateObject"
+ }
+ },
+ "stores-cleared": {
+ "type": "storesCleared",
+ "data": {
+ "_arg": 0,
+ "type": "json"
+ }
+ },
+ "stores-reloaded": {
+ "type": "storesRelaoded",
+ "data": {
+ "_arg": 0,
+ "type": "json"
+ }
+ }
+ }
+ },
+ "gcli": {
+ "category": "actor",
+ "typeName": "gcli",
+ "methods": [
+ {
+ "name": "specs",
+ "request": {
+ "type": "specs"
+ },
+ "response": {
+ "_retval": "json"
+ }
+ },
+ {
+ "name": "execute",
+ "request": {
+ "type": "execute",
+ "typed": {
+ "_arg": 0,
+ "type": "string"
+ }
+ },
+ "response": {
+ "_retval": "json"
+ }
+ },
+ {
+ "name": "state",
+ "request": {
+ "type": "state",
+ "typed": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "start": {
+ "_arg": 1,
+ "type": "number"
+ },
+ "rank": {
+ "_arg": 2,
+ "type": "number"
+ }
+ },
+ "response": {
+ "_retval": "json"
+ }
+ },
+ {
+ "name": "typeparse",
+ "request": {
+ "type": "typeparse",
+ "typed": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "param": {
+ "_arg": 1,
+ "type": "string"
+ }
+ },
+ "response": {
+ "_retval": "json"
+ }
+ },
+ {
+ "name": "typeincrement",
+ "request": {
+ "type": "typeincrement",
+ "typed": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "param": {
+ "_arg": 1,
+ "type": "string"
+ }
+ },
+ "response": {
+ "_retval": "string"
+ }
+ },
+ {
+ "name": "typedecrement",
+ "request": {
+ "type": "typedecrement",
+ "typed": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "param": {
+ "_arg": 1,
+ "type": "string"
+ }
+ },
+ "response": {
+ "_retval": "string"
+ }
+ },
+ {
+ "name": "selectioninfo",
+ "request": {
+ "type": "selectioninfo",
+ "typed": {
+ "_arg": 0,
+ "type": "string"
+ },
+ "param": {
+ "_arg": 1,
+ "type": "string"
+ },
+ "action": {
+ "_arg": 1,
+ "type": "string"
+ }
+ },
+ "response": {
+ "_retval": "json"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "memory": {
+ "category": "actor",
+ "typeName": "memory",
+ "methods": [
+ {
+ "name": "measure",
+ "request": {
+ "type": "measure"
+ },
+ "response": {
+ "_retval": "json"
+ }
+ }
+ ],
+ "events": {}
+ },
+ "eventLoopLag": {
+ "category": "actor",
+ "typeName": "eventLoopLag",
+ "methods": [
+ {
+ "name": "start",
+ "request": {
+ "type": "start"
+ },
+ "response": {
+ "success": {
+ "_retval": "number"
+ }
+ }
+ },
+ {
+ "name": "stop",
+ "request": {
+ "type": "stop"
+ },
+ "response": {}
+ }
+ ],
+ "events": {
+ "event-loop-lag": {
+ "type": "event-loop-lag",
+ "time": {
+ "_arg": 0,
+ "type": "number"
+ }
+ }
+ }
+ },
+ "preference": {
+ "category": "actor",
+ "typeName": "preference",
+ "methods": [
+ {
+ "name": "getBoolPref",
+ "request": {
+ "type": "getBoolPref",
+ "value": {
+ "_arg": 0,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "value": {
+ "_retval": "boolean"
+ }
+ }
+ },
+ {
+ "name": "getCharPref",
+ "request": {
+ "type": "getCharPref",
+ "value": {
+ "_arg": 0,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "value": {
+ "_retval": "string"
+ }
+ }
+ },
+ {
+ "name": "getIntPref",
+ "request": {
+ "type": "getIntPref",
+ "value": {
+ "_arg": 0,
+ "type": "primitive"
+ }
+ },
+ "response": {
+ "value": {
+ "_retval": "number"
+ }
+ }
+ },
+ {
+ "name": "getAllPrefs",
+ "request": {
+ "type": "getAllPrefs"
+ },
+ "response": {
+ "value": {
+ "_retval": "json"
+ }
+ }
+ },
+ {
+ "name": "setBoolPref",
+ "request": {
+ "type": "setBoolPref",
+ "name": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "value": {
+ "_arg": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "setCharPref",
+ "request": {
+ "type": "setCharPref",
+ "name": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "value": {
+ "_arg": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "setIntPref",
+ "request": {
+ "type": "setIntPref",
+ "name": {
+ "_arg": 0,
+ "type": "primitive"
+ },
+ "value": {
+ "_arg": 1,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ },
+ {
+ "name": "clearUserPref",
+ "request": {
+ "type": "clearUserPref",
+ "name": {
+ "_arg": 0,
+ "type": "primitive"
+ }
+ },
+ "response": {}
+ }
+ ],
+ "events": {}
+ },
+ "device": {
+ "category": "actor",
+ "typeName": "device",
+ "methods": [
+ {
+ "name": "getDescription",
+ "request": {
+ "type": "getDescription"
+ },
+ "response": {
+ "value": {
+ "_retval": "json"
+ }
+ }
+ },
+ {
+ "name": "getWallpaper",
+ "request": {
+ "type": "getWallpaper"
+ },
+ "response": {
+ "value": {
+ "_retval": "longstring"
+ }
+ }
+ },
+ {
+ "name": "screenshotToDataURL",
+ "request": {
+ "type": "screenshotToDataURL"
+ },
+ "response": {
+ "value": {
+ "_retval": "longstring"
+ }
+ }
+ },
+ {
+ "name": "getRawPermissionsTable",
+ "request": {
+ "type": "getRawPermissionsTable"
+ },
+ "response": {
+ "value": {
+ "_retval": "json"
+ }
+ }
+ }
+ ],
+ "events": {}
+ }
+ },
+ "from": "root"
+}
+
+},{}],25:[function(_dereq_,module,exports){
+"use strict";
+
+var Class = _dereq_("./class").Class;
+var util = _dereq_("./util");
+var keys = util.keys;
+var values = util.values;
+var pairs = util.pairs;
+var query = util.query;
+var findPath = util.findPath;
+var EventTarget = _dereq_("./event").EventTarget;
+
+var TypeSystem = Class({
+ constructor: function(client) {
+ var types = Object.create(null);
+ var specification = Object.create(null);
+
+ this.specification = specification;
+ this.types = types;
+
+ var typeFor = function typeFor(typeName) {
+ typeName = typeName || "primitive";
+ if (!types[typeName]) {
+ defineType(typeName);
+ }
+
+ return types[typeName];
+ };
+ this.typeFor = typeFor;
+
+ var defineType = function(descriptor) {
+ var type = void(0);
+ if (typeof(descriptor) === "string") {
+ if (descriptor.indexOf(":") > 0)
+ type = makeCompoundType(descriptor);
+ else if (descriptor.indexOf("#") > 0)
+ type = new ActorDetail(descriptor);
+ else if (specification[descriptor])
+ type = makeCategoryType(specification[descriptor]);
+ } else {
+ type = makeCategoryType(descriptor);
+ }
+
+ if (type)
+ types[type.name] = type;
+ else
+ throw TypeError("Invalid type: " + descriptor);
+ };
+ this.defineType = defineType;
+
+
+ var makeCompoundType = function(name) {
+ var index = name.indexOf(":");
+ var baseType = name.slice(0, index);
+ var subType = name.slice(index + 1);
+
+ return baseType === "array" ? new ArrayOf(subType) :
+ baseType === "nullable" ? new Maybe(subType) :
+ null;
+ };
+
+ var makeCategoryType = function(descriptor) {
+ var category = descriptor.category;
+ return category === "dict" ? new Dictionary(descriptor) :
+ category === "actor" ? new Actor(descriptor) :
+ null;
+ };
+
+ var read = function(input, context, typeName) {
+ return typeFor(typeName).read(input, context);
+ }
+ this.read = read;
+
+ var write = function(input, context, typeName) {
+ return typeFor(typeName).write(input);
+ };
+ this.write = write;
+
+
+ var Type = Class({
+ constructor: function() {
+ },
+ get name() {
+ return this.category ? this.category + ":" + this.type :
+ this.type;
+ },
+ read: function(input, context) {
+ throw new TypeError("`Type` subclass must implement `read`");
+ },
+ write: function(input, context) {
+ throw new TypeError("`Type` subclass must implement `write`");
+ }
+ });
+
+ var Primitve = Class({
+ extends: Type,
+ constuctor: function(type) {
+ this.type = type;
+ },
+ read: function(input, context) {
+ return input;
+ },
+ write: function(input, context) {
+ return input;
+ }
+ });
+
+ var Maybe = Class({
+ extends: Type,
+ category: "nullable",
+ constructor: function(type) {
+ this.type = type;
+ },
+ read: function(input, context) {
+ return input === null ? null :
+ input === void(0) ? void(0) :
+ read(input, context, this.type);
+ },
+ write: function(input, context) {
+ return input === null ? null :
+ input === void(0) ? void(0) :
+ write(input, context, this.type);
+ }
+ });
+
+ var ArrayOf = Class({
+ extends: Type,
+ category: "array",
+ constructor: function(type) {
+ this.type = type;
+ },
+ read: function(input, context) {
+ var type = this.type;
+ return input.map(function($) { return read($, context, type) });
+ },
+ write: function(input, context) {
+ var type = this.type;
+ return input.map(function($) { return write($, context, type) });
+ }
+ });
+
+ var makeField = function makeField(name, type) {
+ return {
+ enumerable: true,
+ configurable: true,
+ get: function() {
+ Object.defineProperty(this, name, {
+ configurable: false,
+ value: read(this.state[name], this.context, type)
+ });
+ return this[name];
+ }
+ }
+ };
+
+ var makeFields = function(descriptor) {
+ return pairs(descriptor).reduce(function(fields, pair) {
+ var name = pair[0], type = pair[1];
+ fields[name] = makeField(name, type);
+ return fields;
+ }, {});
+ }
+
+ var DictionaryType = Class({});
+
+ var Dictionary = Class({
+ extends: Type,
+ category: "dict",
+ get name() { return this.type; },
+ constructor: function(descriptor) {
+ this.type = descriptor.typeName;
+ this.types = descriptor.specializations;
+
+ var proto = Object.defineProperties({
+ extends: DictionaryType,
+ constructor: function(state, context) {
+ Object.defineProperties(this, {
+ state: {
+ enumerable: false,
+ writable: true,
+ configurable: true,
+ value: state
+ },
+ context: {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: context
+ }
+ });
+ }
+ }, makeFields(this.types));
+
+ this.class = new Class(proto);
+ },
+ read: function(input, context) {
+ return new this.class(input, context);
+ },
+ write: function(input, context) {
+ var output = {};
+ for (var key in input) {
+ output[key] = write(value, context, types[key]);
+ }
+ return output;
+ }
+ });
+
+ var makeMethods = function(descriptors) {
+ return descriptors.reduce(function(methods, descriptor) {
+ methods[descriptor.name] = {
+ enumerable: true,
+ configurable: true,
+ writable: false,
+ value: makeMethod(descriptor)
+ };
+ return methods;
+ }, {});
+ };
+
+ var makeEvents = function(descriptors) {
+ return pairs(descriptors).reduce(function(events, pair) {
+ var name = pair[0], descriptor = pair[1];
+ var event = new Event(name, descriptor);
+ events[event.eventType] = event;
+ return events;
+ }, Object.create(null));
+ };
+
+ var Actor = Class({
+ extends: Type,
+ category: "actor",
+ get name() { return this.type; },
+ constructor: function(descriptor) {
+ this.type = descriptor.typeName;
+
+ var events = makeEvents(descriptor.events || {});
+ var fields = makeFields(descriptor.fields || {});
+ var methods = makeMethods(descriptor.methods || []);
+
+
+ var proto = {
+ extends: Front,
+ constructor: function() {
+ Front.apply(this, arguments);
+ },
+ events: events
+ };
+ Object.defineProperties(proto, fields);
+ Object.defineProperties(proto, methods);
+
+ this.class = Class(proto);
+ },
+ read: function(input, context, detail) {
+ var state = typeof(input) === "string" ? { actor: input } : input;
+
+ var actor = client.get(state.actor) || new this.class(state, context);
+ actor.form(state, detail, context);
+
+ return actor;
+ },
+ write: function(input, context, detail) {
+ return input.id;
+ }
+ });
+ exports.Actor = Actor;
+
+
+ var ActorDetail = Class({
+ extends: Actor,
+ constructor: function(name) {
+ var parts = name.split("#")
+ this.actorType = parts[0]
+ this.detail = parts[1];
+ },
+ read: function(input, context) {
+ return typeFor(this.actorType).read(input, context, this.detail);
+ },
+ write: function(input, context) {
+ return typeFor(this.actorType).write(input, context, this.detail);
+ }
+ });
+ exports.ActorDetail = ActorDetail;
+
+ var Method = Class({
+ extends: Type,
+ constructor: function(descriptor) {
+ this.type = descriptor.name;
+ this.path = findPath(descriptor.response, "_retval");
+ this.responseType = this.path && query(descriptor.response, this.path)._retval;
+ this.requestType = descriptor.request.type;
+
+ var params = [];
+ for (var key in descriptor.request) {
+ if (key !== "type") {
+ var param = descriptor.request[key];
+ var index = "_arg" in param ? param._arg : param._option;
+ var isParam = param._option === index;
+ var isArgument = param._arg === index;
+ params[index] = {
+ type: param.type,
+ key: key,
+ index: index,
+ isParam: isParam,
+ isArgument: isArgument
+ };
+ }
+ }
+ this.params = params;
+ },
+ read: function(input, context) {
+ return read(query(input, this.path), context, this.responseType);
+ },
+ write: function(input, context) {
+ return this.params.reduce(function(result, param) {
+ result[param.key] = write(input[param.index], context, param.type);
+ return result;
+ }, {type: this.type});
+ }
+ });
+ exports.Method = Method;
+
+ var profiler = function(method, id) {
+ return function() {
+ var start = new Date();
+ return method.apply(this, arguments).then(function(result) {
+ var end = new Date();
+ client.telemetry.add(id, +end - start);
+ return result;
+ });
+ };
+ };
+
+ var destructor = function(method) {
+ return function() {
+ return method.apply(this, arguments).then(function(result) {
+ client.release(this);
+ return result;
+ });
+ };
+ };
+
+ function makeMethod(descriptor) {
+ var type = new Method(descriptor);
+ var method = descriptor.oneway ? makeUnidirecationalMethod(descriptor, type) :
+ makeBidirectionalMethod(descriptor, type);
+
+ if (descriptor.telemetry)
+ method = profiler(method);
+ if (descriptor.release)
+ method = destructor(method);
+
+ return method;
+ }
+
+ var makeUnidirecationalMethod = function(descriptor, type) {
+ return function() {
+ var packet = type.write(arguments, this);
+ packet.to = this.id;
+ client.send(packet);
+ return Promise.resolve(void(0));
+ };
+ };
+
+ var makeBidirectionalMethod = function(descriptor, type) {
+ return function() {
+ var context = this.context;
+ var packet = type.write(arguments, context);
+ var context = this.context;
+ packet.to = this.id;
+ return client.request(packet).then(function(packet) {
+ return type.read(packet, context);
+ });
+ };
+ };
+
+ var Event = Class({
+ constructor: function(name, descriptor) {
+ this.name = descriptor.type || name;
+ this.eventType = descriptor.type || name;
+ this.types = Object.create(null);
+
+ var types = this.types;
+ for (var key in descriptor) {
+ if (key === "type") {
+ types[key] = "string";
+ } else {
+ types[key] = descriptor[key].type;
+ }
+ }
+ },
+ read: function(input, context) {
+ var output = {};
+ var types = this.types;
+ for (var key in input) {
+ output[key] = read(input[key], context, types[key]);
+ }
+ return output;
+ },
+ write: function(input, context) {
+ var output = {};
+ var types = this.types;
+ for (var key in this.types) {
+ output[key] = write(input[key], context, types[key]);
+ }
+ return output;
+ }
+ });
+
+ var Front = Class({
+ extends: EventTarget,
+ EventTarget: EventTarget,
+ constructor: function(state) {
+ this.EventTarget();
+ Object.defineProperties(this, {
+ state: {
+ enumerable: false,
+ writable: true,
+ configurable: true,
+ value: state
+ }
+ });
+
+ client.register(this);
+ },
+ get id() {
+ return this.state.actor;
+ },
+ get context() {
+ return this;
+ },
+ form: function(state, detail, context) {
+ if (this.state !== state) {
+ if (detail) {
+ this.state[detail] = state[detail];
+ } else {
+ pairs(state).forEach(function(pair) {
+ var key = pair[0], value = pair[1];
+ this.state[key] = value;
+ }, this);
+ }
+ }
+
+ if (context) {
+ client.supervise(context, this);
+ }
+ },
+ requestTypes: function() {
+ return client.request({
+ to: this.id,
+ type: "requestTypes"
+ }).then(function(packet) {
+ return packet.requestTypes;
+ });
+ }
+ });
+ types.primitive = new Primitve("primitive");
+ types.string = new Primitve("string");
+ types.number = new Primitve("number");
+ types.boolean = new Primitve("boolean");
+ types.json = new Primitve("json");
+ types.array = new Primitve("array");
+ },
+ registerTypes: function(descriptor) {
+ var specification = this.specification;
+ values(descriptor.types).forEach(function(descriptor) {
+ specification[descriptor.typeName] = descriptor;
+ });
+ }
+});
+exports.TypeSystem = TypeSystem;
+
+},{"./class":3,"./event":5,"./util":26}],26:[function(_dereq_,module,exports){
+"use strict";
+
+var keys = Object.keys;
+exports.keys = keys;
+
+// Returns array of values for the given object.
+var values = function(object) {
+ return keys(object).map(function(key) {
+ return object[key]
+ });
+};
+exports.values = values;
+
+// Returns [key, value] pairs for the given object.
+var pairs = function(object) {
+ return keys(object).map(function(key) {
+ return [key, object[key]]
+ });
+};
+exports.pairs = pairs;
+
+
+// Queries an object for the field nested with in it.
+var query = function(object, path) {
+ return path.reduce(function(object, entry) {
+ return object && object[entry]
+ }, object);
+};
+exports.query = query;
+
+var isObject = function(x) {
+ return x && typeof(x) === "object"
+}
+
+var findPath = function(object, key) {
+ var path = void(0);
+ if (object && typeof(object) === "object") {
+ var names = keys(object);
+ if (names.indexOf(key) >= 0) {
+ path = [];
+ } else {
+ var index = 0;
+ var count = names.length;
+ while (index < count && !path){
+ var head = names[index];
+ var tail = findPath(object[head], key);
+ path = tail ? [head].concat(tail) : tail;
+ index = index + 1
+ }
+ }
+ }
+ return path;
+};
+exports.findPath = findPath;
+
+},{}]},{},[1])
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlcyI6WyIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9ub2RlX21vZHVsZXMvYnJvd3NlcmlmeS9ub2RlX21vZHVsZXMvYnJvd3Nlci1wYWNrL19wcmVsdWRlLmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vYnJvd3Nlci9pbmRleC5qcyIsIi9Vc2Vycy9nb3phbGEvUHJvamVjdHMvdm9sY2FuL2Jyb3dzZXIvcHJvbWlzZS5qcyIsIi9Vc2Vycy9nb3phbGEvUHJvamVjdHMvdm9sY2FuL2NsYXNzLmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vY2xpZW50LmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vZXZlbnQuanMiLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9ub2RlX21vZHVsZXMvYnJvd3NlcmlmeS9ub2RlX21vZHVsZXMvZXZlbnRzL2V2ZW50cy5qcyIsIi9Vc2Vycy9nb3phbGEvUHJvamVjdHMvdm9sY2FuL25vZGVfbW9kdWxlcy9lczYtc3ltYm9sL2luZGV4LmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vbm9kZV9tb2R1bGVzL2VzNi1zeW1ib2wvaXMtaW1wbGVtZW50ZWQuanMiLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9ub2RlX21vZHVsZXMvZXM2LXN5bWJvbC9ub2RlX21vZHVsZXMvZC9pbmRleC5qcyIsIi9Vc2Vycy9nb3phbGEvUHJvamVjdHMvdm9sY2FuL25vZGVfbW9kdWxlcy9lczYtc3ltYm9sL25vZGVfbW9kdWxlcy9lczUtZXh0L29iamVjdC9hc3NpZ24vaW5kZXguanMiLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9ub2RlX21vZHVsZXMvZXM2LXN5bWJvbC9ub2RlX21vZHVsZXMvZXM1LWV4dC9vYmplY3QvYXNzaWduL2lzLWltcGxlbWVudGVkLmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vbm9kZV9tb2R1bGVzL2VzNi1zeW1ib2wvbm9kZV9tb2R1bGVzL2VzNS1leHQvb2JqZWN0L2Fzc2lnbi9zaGltLmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vbm9kZV9tb2R1bGVzL2VzNi1zeW1ib2wvbm9kZV9tb2R1bGVzL2VzNS1leHQvb2JqZWN0L2lzLWNhbGxhYmxlLmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vbm9kZV9tb2R1bGVzL2VzNi1zeW1ib2wvbm9kZV9tb2R1bGVzL2VzNS1leHQvb2JqZWN0L2tleXMvaW5kZXguanMiLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9ub2RlX21vZHVsZXMvZXM2LXN5bWJvbC9ub2RlX21vZHVsZXMvZXM1LWV4dC9vYmplY3Qva2V5cy9pcy1pbXBsZW1lbnRlZC5qcyIsIi9Vc2Vycy9nb3phbGEvUHJvamVjdHMvdm9sY2FuL25vZGVfbW9kdWxlcy9lczYtc3ltYm9sL25vZGVfbW9kdWxlcy9lczUtZXh0L29iamVjdC9rZXlzL3NoaW0uanMiLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9ub2RlX21vZHVsZXMvZXM2LXN5bWJvbC9ub2RlX21vZHVsZXMvZXM1LWV4dC9vYmplY3Qvbm9ybWFsaXplLW9wdGlvbnMuanMiLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9ub2RlX21vZHVsZXMvZXM2LXN5bWJvbC9ub2RlX21vZHVsZXMvZXM1LWV4dC9vYmplY3QvdmFsaWQtdmFsdWUuanMiLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9ub2RlX21vZHVsZXMvZXM2LXN5bWJvbC9ub2RlX21vZHVsZXMvZXM1LWV4dC9zdHJpbmcvIy9jb250YWlucy9pbmRleC5qcyIsIi9Vc2Vycy9nb3phbGEvUHJvamVjdHMvdm9sY2FuL25vZGVfbW9kdWxlcy9lczYtc3ltYm9sL25vZGVfbW9kdWxlcy9lczUtZXh0L3N0cmluZy8jL2NvbnRhaW5zL2lzLWltcGxlbWVudGVkLmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vbm9kZV9tb2R1bGVzL2VzNi1zeW1ib2wvbm9kZV9tb2R1bGVzL2VzNS1leHQvc3RyaW5nLyMvY29udGFpbnMvc2hpbS5qcyIsIi9Vc2Vycy9nb3phbGEvUHJvamVjdHMvdm9sY2FuL25vZGVfbW9kdWxlcy9lczYtc3ltYm9sL3BvbHlmaWxsLmpzIiwiL1VzZXJzL2dvemFsYS9Qcm9qZWN0cy92b2xjYW4vc3BlY2lmaWNhdGlvbi9jb3JlLmpzb24iLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi9zcGVjaWZpY2F0aW9uL3Byb3RvY29sLmpzb24iLCIvVXNlcnMvZ296YWxhL1Byb2plY3RzL3ZvbGNhbi90eXBlLXN5c3RlbS5qcyIsIi9Vc2Vycy9nb3phbGEvUHJvamVjdHMvdm9sY2FuL3V0aWwuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNUQTtBQUNBO0FBQ0E7QUFDQTs7QUNIQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQ3RCQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FDaExBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FDbkVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQy9TQTtBQUNBO0FBQ0E7QUFDQTs7QUNIQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNyQkE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FDL0RBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNMQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNUQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQ3RCQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FDTEE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQ0xBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNSQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQ1BBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FDdEJBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQ05BO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNMQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FDUkE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNQQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FDckRBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQ3pKQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUMzdUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FDcmRBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlc0NvbnRlbnQiOlsiKGZ1bmN0aW9uIGUodCxuLHIpe2Z1bmN0aW9uIHMobyx1KXtpZighbltvXSl7aWYoIXRbb10pe3ZhciBhPXR5cGVvZiByZXF1aXJlPT1cImZ1bmN0aW9uXCImJnJlcXVpcmU7aWYoIXUmJmEpcmV0dXJuIGEobywhMCk7aWYoaSlyZXR1cm4gaShvLCEwKTt0aHJvdyBuZXcgRXJyb3IoXCJDYW5ub3QgZmluZCBtb2R1bGUgJ1wiK28rXCInXCIpfXZhciBmPW5bb109e2V4cG9ydHM6e319O3Rbb11bMF0uY2FsbChmLmV4cG9ydHMsZnVuY3Rpb24oZSl7dmFyIG49dFtvXVsxXVtlXTtyZXR1cm4gcyhuP246ZSl9LGYsZi5leHBvcnRzLGUsdCxuLHIpfXJldHVybiBuW29dLmV4cG9ydHN9dmFyIGk9dHlwZW9mIHJlcXVpcmU9PVwiZnVuY3Rpb25cIiYmcmVxdWlyZTtmb3IodmFyIG89MDtvPHIubGVuZ3RoO28rKylzKHJbb10pO3JldHVybiBzfSkiLCJcInVzZSBzdHJpY3RcIjtcblxudmFyIENsaWVudCA9IHJlcXVpcmUoXCIuLi9jbGllbnRcIikuQ2xpZW50O1xuXG5mdW5jdGlvbiBjb25uZWN0KHBvcnQpIHtcbiAgdmFyIGNsaWVudCA9IG5ldyBDbGllbnQoKTtcbiAgcmV0dXJuIGNsaWVudC5jb25uZWN0KHBvcnQpO1xufVxuZXhwb3J0cy5jb25uZWN0ID0gY29ubmVjdDtcbiIsIlwidXNlIHN0cmljdFwiO1xuXG5leHBvcnRzLlByb21pc2UgPSBQcm9taXNlO1xuIiwiXCJ1c2Ugc3RyaWN0XCI7XG5cbnZhciBkZXNjcmliZSA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7XG52YXIgQ2xhc3MgPSBmdW5jdGlvbihmaWVsZHMpIHtcbiAgdmFyIG5hbWVzID0gT2JqZWN0LmtleXMoZmllbGRzKTtcbiAgdmFyIGNvbnN0cnVjdG9yID0gbmFtZXMuaW5kZXhPZihcImNvbnN0cnVjdG9yXCIpID49IDAgPyBmaWVsZHMuY29uc3RydWN0b3IgOlxuICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbigpIHt9O1xuICB2YXIgYW5jZXN0b3IgPSBmaWVsZHMuZXh0ZW5kcyB8fCBPYmplY3Q7XG5cbiAgdmFyIGRlc2NyaXB0b3IgPSBuYW1lcy5yZWR1Y2UoZnVuY3Rpb24oZGVzY3JpcHRvciwga2V5KSB7XG4gICAgZGVzY3JpcHRvcltrZXldID0gZGVzY3JpYmUoZmllbGRzLCBrZXkpO1xuICAgIHJldHVybiBkZXNjcmlwdG9yO1xuICB9LCB7fSk7XG5cbiAgdmFyIHByb3RvdHlwZSA9IE9iamVjdC5jcmVhdGUoYW5jZXN0b3IucHJvdG90eXBlLCBkZXNjcmlwdG9yKTtcblxuICBjb25zdHJ1Y3Rvci5wcm90b3R5cGUgPSBwcm90b3R5cGU7XG4gIHByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IGNvbnN0cnVjdG9yO1xuXG4gIHJldHVybiBjb25zdHJ1Y3Rvcjtcbn07XG5leHBvcnRzLkNsYXNzID0gQ2xhc3M7XG4iLCJcInVzZSBzdHJpY3RcIjtcblxudmFyIENsYXNzID0gcmVxdWlyZShcIi4vY2xhc3NcIikuQ2xhc3M7XG52YXIgVHlwZVN5c3RlbSA9IHJlcXVpcmUoXCIuL3R5cGUtc3lzdGVtXCIpLlR5cGVTeXN0ZW07XG52YXIgdmFsdWVzID0gcmVxdWlyZShcIi4vdXRpbFwiKS52YWx1ZXM7XG52YXIgUHJvbWlzZSA9IHJlcXVpcmUoXCJlczYtcHJvbWlzZVwiKS5Qcm9taXNlO1xudmFyIE1lc3NhZ2VFdmVudCA9IHJlcXVpcmUoXCIuL2V2ZW50XCIpLk1lc3NhZ2VFdmVudDtcblxudmFyIHNwZWNpZmljYXRpb24gPSByZXF1aXJlKFwiLi9zcGVjaWZpY2F0aW9uL2NvcmUuanNvblwiKTtcblxuZnVuY3Rpb24gcmVjb3ZlckFjdG9yRGVzY3JpcHRpb25zKGVycm9yKSB7XG4gIGNvbnNvbGUud2FybihcIkZhaWxlZCB0byBmZXRjaCBwcm90b2NvbCBzcGVjaWZpY2F0aW9uIChzZWUgcmVhc29uIGJlbG93KS4gXCIgK1xuICAgICAgICAgICAgICAgXCJVc2luZyBhIGZhbGxiYWNrIHByb3RvY2FsIHNwZWNpZmljYXRpb24hXCIsXG4gICAgICAgICAgICAgICBlcnJvcik7XG4gIHJldHVybiByZXF1aXJlKFwiLi9zcGVjaWZpY2F0aW9uL3Byb3RvY29sLmpzb25cIik7XG59XG5cbi8vIFR5cGUgdG8gcmVwcmVzZW50IHN1cGVydmlzZXIgYWN0b3IgcmVsYXRpb25zIHRvIGFjdG9ycyB0aGV5IHN1cGVydmlzZVxuLy8gaW4gdGVybXMgb2YgbGlmZXRpbWUgbWFuYWdlbWVudC5cbnZhciBTdXBlcnZpc29yID0gQ2xhc3Moe1xuICBjb25zdHJ1Y3RvcjogZnVuY3Rpb24oaWQpIHtcbiAgICB0aGlzLmlkID0gaWQ7XG4gICAgdGhpcy53b3JrZXJzID0gW107XG4gIH1cbn0pO1xuXG52YXIgVGVsZW1ldHJ5ID0gQ2xhc3Moe1xuICBhZGQ6IGZ1bmN0aW9uKGlkLCBtcykge1xuICAgIGNvbnNvbGUubG9nKFwidGVsZW1ldHJ5OjpcIiwgaWQsIG1zKVxuICB9XG59KTtcblxuLy8gQ29uc2lkZXIgbWFraW5nIGNsaWVudCBhIHJvb3QgYWN0b3IuXG5cbnZhciBDbGllbnQgPSBDbGFzcyh7XG4gIGNvbnN0cnVjdG9yOiBmdW5jdGlvbigpIHtcbiAgICB0aGlzLnJvb3QgPSBudWxsO1xuICAgIHRoaXMudGVsZW1ldHJ5ID0gbmV3IFRlbGVtZXRyeSgpO1xuXG4gICAgdGhpcy5zZXR1cENvbm5lY3Rpb24oKTtcbiAgICB0aGlzLnNldHVwTGlmZU1hbmFnZW1lbnQoKTtcbiAgICB0aGlzLnNldHVwVHlwZVN5c3RlbSgpO1xuICB9LFxuXG4gIHNldHVwQ29ubmVjdGlvbjogZnVuY3Rpb24oKSB7XG4gICAgdGhpcy5yZXF1ZXN0cyA9IFtdO1xuICB9LFxuICBzZXR1cExpZmVNYW5hZ2VtZW50OiBmdW5jdGlvbigpIHtcbiAgICB0aGlzLmNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICB0aGlzLmdyYXBoID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICB0aGlzLmdldCA9IHRoaXMuZ2V0LmJpbmQodGhpcyk7XG4gICAgdGhpcy5yZWxlYXNlID0gdGhpcy5yZWxlYXNlLmJpbmQodGhpcyk7XG4gIH0sXG4gIHNldHVwVHlwZVN5c3RlbTogZnVuY3Rpb24oKSB7XG4gICAgdGhpcy50eXBlU3lzdGVtID0gbmV3IFR5cGVTeXN0ZW0odGhpcyk7XG4gICAgdGhpcy50eXBlU3lzdGVtLnJlZ2lzdGVyVHlwZXMoc3BlY2lmaWNhdGlvbik7XG4gIH0sXG5cbiAgY29ubmVjdDogZnVuY3Rpb24ocG9ydCkge1xuICAgIHZhciBjbGllbnQgPSB0aGlzO1xuICAgIHJldHVybiBuZXcgUHJvbWlzZShmdW5jdGlvbihyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgIGNsaWVudC5wb3J0ID0gcG9ydDtcbiAgICAgIHBvcnQub25tZXNzYWdlID0gY2xpZW50LnJlY2VpdmUuYmluZChjbGllbnQpO1xuICAgICAgY2xpZW50Lm9uUmVhZHkgPSByZXNvbHZlO1xuICAgICAgY2xpZW50Lm9uRmFpbCA9IHJlamVjdDtcblxuICAgICAgcG9ydC5zdGFydCgpO1xuICAgIH0pO1xuICB9LFxuICBzZW5kOiBmdW5jdGlvbihwYWNrZXQpIHtcbiAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UocGFja2V0KTtcbiAgfSxcbiAgcmVxdWVzdDogZnVuY3Rpb24ocGFja2V0KSB7XG4gICAgdmFyIGNsaWVudCA9IHRoaXM7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgY2xpZW50LnJlcXVlc3RzLnB1c2gocGFja2V0LnRvLCB7IHJlc29sdmU6IHJlc29sdmUsIHJlamVjdDogcmVqZWN0IH0pO1xuICAgICAgY2xpZW50LnNlbmQocGFja2V0KTtcbiAgICB9KTtcbiAgfSxcblxuICByZWNlaXZlOiBmdW5jdGlvbihldmVudCkge1xuICAgIHZhciBwYWNrZXQgPSBldmVudC5kYXRhO1xuICAgIGlmICghdGhpcy5yb290KSB7XG4gICAgICBpZiAocGFja2V0LmZyb20gIT09IFwicm9vdFwiKVxuICAgICAgICB0aHJvdyBFcnJvcihcIkluaXRpYWwgcGFja2V0IG11c3QgYmUgZnJvbSByb290XCIpO1xuICAgICAgaWYgKCEoXCJhcHBsaWNhdGlvblR5cGVcIiBpbiBwYWNrZXQpKVxuICAgICAgICB0aHJvdyBFcnJvcihcIkluaXRpYWwgcGFja2V0IG11c3QgY29udGFpbiBhcHBsaWNhdGlvblR5cGUgZmllbGRcIik7XG5cbiAgICAgIHRoaXMucm9vdCA9IHRoaXMudHlwZVN5c3RlbS5yZWFkKFwicm9vdFwiLCBudWxsLCBcInJvb3RcIik7XG4gICAgICB0aGlzLnJvb3RcbiAgICAgICAgICAucHJvdG9jb2xEZXNjcmlwdGlvbigpXG4gICAgICAgICAgLmNhdGNoKHJlY292ZXJBY3RvckRlc2NyaXB0aW9ucylcbiAgICAgICAgICAudGhlbih0aGlzLnR5cGVTeXN0ZW0ucmVnaXN0ZXJUeXBlcy5iaW5kKHRoaXMudHlwZVN5c3RlbSkpXG4gICAgICAgICAgLnRoZW4odGhpcy5vblJlYWR5LmJpbmQodGhpcywgdGhpcy5yb290KSwgdGhpcy5vbkZhaWwpO1xuICAgIH0gZWxzZSB7XG4gICAgICB2YXIgYWN0b3IgPSB0aGlzLmdldChwYWNrZXQuZnJvbSkgfHwgdGhpcy5yb290O1xuICAgICAgdmFyIGV2ZW50ID0gYWN0b3IuZXZlbnRzW3BhY2tldC50eXBlXTtcbiAgICAgIGlmIChldmVudCkge1xuICAgICAgICB2YXIgbWVzc2FnZSA9IG5ldyBNZXNzYWdlRXZlbnQocGFja2V0LnR5cGUsIHtcbiAgICAgICAgICBkYXRhOiBldmVudC5yZWFkKHBhY2tldClcbiAgICAgICAgfSk7XG4gICAgICAgIGFjdG9yLmRpc3BhdGNoRXZlbnQobWVzc2FnZSk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB2YXIgaW5kZXggPSB0aGlzLnJlcXVlc3RzLmluZGV4T2YoYWN0b3IuaWQpO1xuICAgICAgICBpZiAoaW5kZXggPj0gMCkge1xuICAgICAgICAgIHZhciByZXF1ZXN0ID0gdGhpcy5yZXF1ZXN0cy5zcGxpY2UoaW5kZXgsIDIpLnBvcCgpO1xuICAgICAgICAgIGlmIChwYWNrZXQuZXJyb3IpXG4gICAgICAgICAgICByZXF1ZXN0LnJlamVjdChwYWNrZXQpO1xuICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgIHJlcXVlc3QucmVzb2x2ZShwYWNrZXQpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnNvbGUuZXJyb3IoRXJyb3IoXCJVbmV4cGVjdGVkIHBhY2tldCBcIiArIEpTT04uc3RyaW5naWZ5KHBhY2tldCwgMiwgMikpLFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFja2V0LFxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXF1ZXN0cy5zbGljZSgwKSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gIH0sXG5cbiAgZ2V0OiBmdW5jdGlvbihpZCkge1xuICAgIHJldHVybiB0aGlzLmNhY2hlW2lkXTtcbiAgfSxcbiAgc3VwZXJ2aXNvck9mOiBmdW5jdGlvbihhY3Rvcikge1xuICAgIGZvciAodmFyIGlkIGluIHRoaXMuZ3JhcGgpIHtcbiAgICAgIGlmICh0aGlzLmdyYXBoW2lkXS5pbmRleE9mKGFjdG9yLmlkKSA+PSAwKSB7XG4gICAgICAgIHJldHVybiBpZDtcbiAgICAgIH1cbiAgICB9XG4gIH0sXG4gIHdvcmtlcnNPZjogZnVuY3Rpb24oYWN0b3IpIHtcbiAgICByZXR1cm4gdGhpcy5ncmFwaFthY3Rvci5pZF07XG4gIH0sXG4gIHN1cGVydmlzZTogZnVuY3Rpb24oYWN0b3IsIHdvcmtlcikge1xuICAgIHZhciB3b3JrZXJzID0gdGhpcy53b3JrZXJzT2YoYWN0b3IpXG4gICAgaWYgKHdvcmtlcnMuaW5kZXhPZih3b3JrZXIuaWQpIDwgMCkge1xuICAgICAgd29ya2Vycy5wdXNoKHdvcmtlci5pZCk7XG4gICAgfVxuICB9LFxuICB1bnN1cGVydmlzZTogZnVuY3Rpb24oYWN0b3IsIHdvcmtlcikge1xuICAgIHZhciB3b3JrZXJzID0gdGhpcy53b3JrZXJzT2YoYWN0b3IpO1xuICAgIHZhciBpbmRleCA9IHdvcmtlcnMuaW5kZXhPZih3b3JrZXIuaWQpXG4gICAgaWYgKGluZGV4ID49IDApIHtcbiAgICAgIHdvcmtlcnMuc3BsaWNlKGluZGV4LCAxKVxuICAgIH1cbiAgfSxcblxuICByZWdpc3RlcjogZnVuY3Rpb24oYWN0b3IpIHtcbiAgICB2YXIgcmVnaXN0ZXJlZCA9IHRoaXMuZ2V0KGFjdG9yLmlkKTtcbiAgICBpZiAoIXJlZ2lzdGVyZWQpIHtcbiAgICAgIHRoaXMuY2FjaGVbYWN0b3IuaWRdID0gYWN0b3I7XG4gICAgICB0aGlzLmdyYXBoW2FjdG9yLmlkXSA9IFtdO1xuICAgIH0gZWxzZSBpZiAocmVnaXN0ZXJlZCAhPT0gYWN0b3IpIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcihcIkRpZmZlcmVudCBhY3RvciB3aXRoIHNhbWUgaWQgaXMgYWxyZWFkeSByZWdpc3RlcmVkXCIpO1xuICAgIH1cbiAgfSxcbiAgdW5yZWdpc3RlcjogZnVuY3Rpb24oYWN0b3IpIHtcbiAgICBpZiAodGhpcy5nZXQoYWN0b3IuaWQpKSB7XG4gICAgICBkZWxldGUgdGhpcy5jYWNoZVthY3Rvci5pZF07XG4gICAgICBkZWxldGUgdGhpcy5ncmFwaFthY3Rvci5pZF07XG4gICAgfVxuICB9LFxuXG4gIHJlbGVhc2U6IGZ1bmN0aW9uKGFjdG9yKSB7XG4gICAgdmFyIHN1cGVydmlzb3IgPSB0aGlzLnN1cGVydmlzb3JPZihhY3Rvcik7XG4gICAgaWYgKHN1cGVydmlzb3IpXG4gICAgICB0aGlzLnVuc3VwZXJ2aXNlKHN1cGVydmlzb3IsIGFjdG9yKTtcblxuICAgIHZhciB3b3JrZXJzID0gdGhpcy53b3JrZXJzT2YoYWN0b3IpXG5cbiAgICBpZiAod29ya2Vycykge1xuICAgICAgd29ya2Vycy5tYXAodGhpcy5nZXQpLmZvckVhY2godGhpcy5yZWxlYXNlKVxuICAgIH1cbiAgICB0aGlzLnVucmVnaXN0ZXIoYWN0b3IpO1xuICB9XG59KTtcbmV4cG9ydHMuQ2xpZW50ID0gQ2xpZW50O1xuIiwiXCJ1c2Ugc3RyaWN0XCI7XG5cbnZhciBTeW1ib2wgPSByZXF1aXJlKFwiZXM2LXN5bWJvbFwiKVxudmFyIEV2ZW50RW1pdHRlciA9IHJlcXVpcmUoXCJldmVudHNcIikuRXZlbnRFbWl0dGVyO1xudmFyIENsYXNzID0gcmVxdWlyZShcIi4vY2xhc3NcIikuQ2xhc3M7XG5cbnZhciAkYm91bmQgPSBTeW1ib2woXCJFdmVudFRhcmdldC9oYW5kbGVFdmVudFwiKTtcbnZhciAkZW1pdHRlciA9IFN5bWJvbChcIkV2ZW50VGFyZ2V0L2VtaXR0ZXJcIik7XG5cbmZ1bmN0aW9uIG1ha2VIYW5kbGVyKGhhbmRsZXIpIHtcbiAgcmV0dXJuIGZ1bmN0aW9uKGV2ZW50KSB7XG4gICAgaGFuZGxlci5oYW5kbGVFdmVudChldmVudCk7XG4gIH1cbn1cblxudmFyIEV2ZW50VGFyZ2V0ID0gQ2xhc3Moe1xuICBjb25zdHJ1Y3RvcjogZnVuY3Rpb24oKSB7XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICRlbWl0dGVyLCB7XG4gICAgICBlbnVtZXJhYmxlOiBmYWxzZSxcbiAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgIHdyaXRhYmxlOiB0cnVlLFxuICAgICAgdmFsdWU6IG5ldyBFdmVudEVtaXR0ZXIoKVxuICAgIH0pO1xuICB9LFxuICBhZGRFdmVudExpc3RlbmVyOiBmdW5jdGlvbih0eXBlLCBoYW5kbGVyKSB7XG4gICAgaWYgKHR5cGVvZihoYW5kbGVyKSA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICB0aGlzWyRlbWl0dGVyXS5vbih0eXBlLCBoYW5kbGVyKTtcbiAgICB9XG4gICAgZWxzZSBpZiAoaGFuZGxlciAmJiB0eXBlb2YoaGFuZGxlcikgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgIGlmICghaGFuZGxlclskYm91bmRdKSBoYW5kbGVyWyRib3VuZF0gPSBtYWtlSGFuZGxlcihoYW5kbGVyKTtcbiAgICAgIHRoaXNbJGVtaXR0ZXJdLm9uKHR5cGUsIGhhbmRsZXJbJGJvdW5kXSk7XG4gICAgfVxuICB9LFxuICByZW1vdmVFdmVudExpc3RlbmVyOiBmdW5jdGlvbih0eXBlLCBoYW5kbGVyKSB7XG4gICAgaWYgKHR5cGVvZihoYW5kbGVyKSA9PT0gXCJmdW5jdGlvblwiKVxuICAgICAgdGhpc1skZW1pdHRlcl0ucmVtb3ZlTGlzdGVuZXIodHlwZSwgaGFuZGxlcik7XG4gICAgZWxzZSBpZiAoaGFuZGxlciAmJiBoYW5kbGVyWyRib3VuZF0pXG4gICAgICB0aGlzWyRlbWl0dGVyXS5yZW1vdmVMaXN0ZW5lcih0eXBlLCBoYW5kbGVyWyRib3VuZF0pO1xuICB9LFxuICBkaXNwYXRjaEV2ZW50OiBmdW5jdGlvbihldmVudCkge1xuICAgIGV2ZW50LnRhcmdldCA9IHRoaXM7XG4gICAgdGhpc1skZW1pdHRlcl0uZW1pdChldmVudC50eXBlLCBldmVudCk7XG4gIH1cbn0pO1xuZXhwb3J0cy5FdmVudFRhcmdldCA9IEV2ZW50VGFyZ2V0O1xuXG52YXIgTWVzc2FnZUV2ZW50ID0gQ2xhc3Moe1xuICBjb25zdHJ1Y3RvcjogZnVuY3Rpb24odHlwZSwgb3B0aW9ucykge1xuICAgIG9wdGlvbnMgPSBvcHRpb25zIHx8IHt9O1xuICAgIHRoaXMudHlwZSA9IHR5cGU7XG4gICAgdGhpcy5kYXRhID0gb3B0aW9ucy5kYXRhID09PSB2b2lkKDApID8gbnVsbCA6IG9wdGlvbnMuZGF0YTtcblxuICAgIHRoaXMubGFzdEV2ZW50SWQgPSBvcHRpb25zLmxhc3RFdmVudElkIHx8IFwiXCI7XG4gICAgdGhpcy5vcmlnaW4gPSBvcHRpb25zLm9yaWdpbiB8fCBcIlwiO1xuICAgIHRoaXMuYnViYmxlcyA9IG9wdGlvbnMuYnViYmxlcyB8fCBmYWxzZTtcbiAgICB0aGlzLmNhbmNlbGFibGUgPSBvcHRpb25zLmNhbmNlbGFibGUgfHwgZmFsc2U7XG4gIH0sXG4gIHNvdXJjZTogbnVsbCxcbiAgcG9ydHM6IG51bGwsXG4gIHByZXZlbnREZWZhdWx0OiBmdW5jdGlvbigpIHtcbiAgfSxcbiAgc3RvcFByb3BhZ2F0aW9uOiBmdW5jdGlvbigpIHtcbiAgfSxcbiAgc3RvcEltbWVkaWF0ZVByb3BhZ2F0aW9uOiBmdW5jdGlvbigpIHtcbiAgfVxufSk7XG5leHBvcnRzLk1lc3NhZ2VFdmVudCA9IE1lc3NhZ2VFdmVudDtcbiIsIi8vIENvcHlyaWdodCBKb3llbnQsIEluYy4gYW5kIG90aGVyIE5vZGUgY29udHJpYnV0b3JzLlxuLy9cbi8vIFBlcm1pc3Npb24gaXMgaGVyZWJ5IGdyYW50ZWQsIGZyZWUgb2YgY2hhcmdlLCB0byBhbnkgcGVyc29uIG9idGFpbmluZyBhXG4vLyBjb3B5IG9mIHRoaXMgc29mdHdhcmUgYW5kIGFzc29jaWF0ZWQgZG9jdW1lbnRhdGlvbiBmaWxlcyAodGhlXG4vLyBcIlNvZnR3YXJlXCIpLCB0byBkZWFsIGluIHRoZSBTb2Z0d2FyZSB3aXRob3V0IHJlc3RyaWN0aW9uLCBpbmNsdWRpbmdcbi8vIHdpdGhvdXQgbGltaXRhdGlvbiB0aGUgcmlnaHRzIHRvIHVzZSwgY29weSwgbW9kaWZ5LCBtZXJnZSwgcHVibGlzaCxcbi8vIGRpc3RyaWJ1dGUsIHN1YmxpY2Vuc2UsIGFuZC9vciBzZWxsIGNvcGllcyBvZiB0aGUgU29mdHdhcmUsIGFuZCB0byBwZXJtaXRcbi8vIHBlcnNvbnMgdG8gd2hvbSB0aGUgU29mdHdhcmUgaXMgZnVybmlzaGVkIHRvIGRvIHNvLCBzdWJqZWN0IHRvIHRoZVxuLy8gZm9sbG93aW5nIGNvbmRpdGlvbnM6XG4vL1xuLy8gVGhlIGFib3ZlIGNvcHlyaWdodCBub3RpY2UgYW5kIHRoaXMgcGVybWlzc2lvbiBub3RpY2Ugc2hhbGwgYmUgaW5jbHVkZWRcbi8vIGluIGFsbCBjb3BpZXMgb3Igc3Vic3RhbnRpYWwgcG9ydGlvbnMgb2YgdGhlIFNvZnR3YXJlLlxuLy9cbi8vIFRIRSBTT0ZUV0FSRSBJUyBQUk9WSURFRCBcIkFTIElTXCIsIFdJVEhPVVQgV0FSUkFOVFkgT0YgQU5ZIEtJTkQsIEVYUFJFU1Ncbi8vIE9SIElNUExJRUQsIElOQ0xVRElORyBCVVQgTk9UIExJTUlURUQgVE8gVEhFIFdBUlJBTlRJRVMgT0Zcbi8vIE1FUkNIQU5UQUJJTElUWSwgRklUTkVTUyBGT1IgQSBQQVJUSUNVTEFSIFBVUlBPU0UgQU5EIE5PTklORlJJTkdFTUVOVC4gSU5cbi8vIE5PIEVWRU5UIFNIQUxMIFRIRSBBVVRIT1JTIE9SIENPUFlSSUdIVCBIT0xERVJTIEJFIExJQUJMRSBGT1IgQU5ZIENMQUlNLFxuLy8gREFNQUdFUyBPUiBPVEhFUiBMSUFCSUxJVFksIFdIRVRIRVIgSU4gQU4gQUNUSU9OIE9GIENPTlRSQUNULCBUT1JUIE9SXG4vLyBPVEhFUldJU0UsIEFSSVNJTkcgRlJPTSwgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgU09GVFdBUkUgT1IgVEhFXG4vLyBVU0UgT1IgT1RIRVIgREVBTElOR1MgSU4gVEhFIFNPRlRXQVJFLlxuXG5mdW5jdGlvbiBFdmVudEVtaXR0ZXIoKSB7XG4gIHRoaXMuX2V2ZW50cyA9IHRoaXMuX2V2ZW50cyB8fCB7fTtcbiAgdGhpcy5fbWF4TGlzdGVuZXJzID0gdGhpcy5fbWF4TGlzdGVuZXJzIHx8IHVuZGVmaW5lZDtcbn1cbm1vZHVsZS5leHBvcnRzID0gRXZlbnRFbWl0dGVyO1xuXG4vLyBCYWNrd2FyZHMtY29tcGF0IHdpdGggbm9kZSAwLjEwLnhcbkV2ZW50RW1pdHRlci5FdmVudEVtaXR0ZXIgPSBFdmVudEVtaXR0ZXI7XG5cbkV2ZW50RW1pdHRlci5wcm90b3R5cGUuX2V2ZW50cyA9IHVuZGVmaW5lZDtcbkV2ZW50RW1pdHRlci5wcm90b3R5cGUuX21heExpc3RlbmVycyA9IHVuZGVmaW5lZDtcblxuLy8gQnkgZGVmYXVsdCBFdmVudEVtaXR0ZXJzIHdpbGwgcHJpbnQgYSB3YXJuaW5nIGlmIG1vcmUgdGhhbiAxMCBsaXN0ZW5lcnMgYXJlXG4vLyBhZGRlZCB0byBpdC4gVGhpcyBpcyBhIHVzZWZ1bCBkZWZhdWx0IHdoaWNoIGhlbHBzIGZpbmRpbmcgbWVtb3J5IGxlYWtzLlxuRXZlbnRFbWl0dGVyLmRlZmF1bHRNYXhMaXN0ZW5lcnMgPSAxMDtcblxuLy8gT2J2aW91c2x5IG5vdCBhbGwgRW1pdHRlcnMgc2hvdWxkIGJlIGxpbWl0ZWQgdG8gMTAuIFRoaXMgZnVuY3Rpb24gYWxsb3dzXG4vLyB0aGF0IHRvIGJlIGluY3JlYXNlZC4gU2V0IHRvIHplcm8gZm9yIHVubGltaXRlZC5cbkV2ZW50RW1pdHRlci5wcm90b3R5cGUuc2V0TWF4TGlzdGVuZXJzID0gZnVuY3Rpb24obikge1xuICBpZiAoIWlzTnVtYmVyKG4pIHx8IG4gPCAwIHx8IGlzTmFOKG4pKVxuICAgIHRocm93IFR5cGVFcnJvcignbiBtdXN0IGJlIGEgcG9zaXRpdmUgbnVtYmVyJyk7XG4gIHRoaXMuX21heExpc3RlbmVycyA9IG47XG4gIHJldHVybiB0aGlzO1xufTtcblxuRXZlbnRFbWl0dGVyLnByb3RvdHlwZS5lbWl0ID0gZnVuY3Rpb24odHlwZSkge1xuICB2YXIgZXIsIGhhbmRsZXIsIGxlbiwgYXJncywgaSwgbGlzdGVuZXJzO1xuXG4gIGlmICghdGhpcy5fZXZlbnRzKVxuICAgIHRoaXMuX2V2ZW50cyA9IHt9O1xuXG4gIC8vIElmIHRoZXJlIGlzIG5vICdlcnJvcicgZXZlbnQgbGlzdGVuZXIgdGhlbiB0aHJvdy5cbiAgaWYgKHR5cGUgPT09ICdlcnJvcicpIHtcbiAgICBpZiAoIXRoaXMuX2V2ZW50cy5lcnJvciB8fFxuICAgICAgICAoaXNPYmplY3QodGhpcy5fZXZlbnRzLmVycm9yKSAmJiAhdGhpcy5fZXZlbnRzLmVycm9yLmxlbmd0aCkpIHtcbiAgICAgIGVyID0gYXJndW1lbnRzWzFdO1xuICAgICAgaWYgKGVyIGluc3RhbmNlb2YgRXJyb3IpIHtcbiAgICAgICAgdGhyb3cgZXI7IC8vIFVuaGFuZGxlZCAnZXJyb3InIGV2ZW50XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aHJvdyBUeXBlRXJyb3IoJ1VuY2F1Z2h0LCB1bnNwZWNpZmllZCBcImVycm9yXCIgZXZlbnQuJyk7XG4gICAgICB9XG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICB9XG5cbiAgaGFuZGxlciA9IHRoaXMuX2V2ZW50c1t0eXBlXTtcblxuICBpZiAoaXNVbmRlZmluZWQoaGFuZGxlcikpXG4gICAgcmV0dXJuIGZhbHNlO1xuXG4gIGlmIChpc0Z1bmN0aW9uKGhhbmRsZXIpKSB7XG4gICAgc3dpdGNoIChhcmd1bWVudHMubGVuZ3RoKSB7XG4gICAgICAvLyBmYXN0IGNhc2VzXG4gICAgICBjYXNlIDE6XG4gICAgICAgIGhhbmRsZXIuY2FsbCh0aGlzKTtcbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlIDI6XG4gICAgICAgIGhhbmRsZXIuY2FsbCh0aGlzLCBhcmd1bWVudHNbMV0pO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgMzpcbiAgICAgICAgaGFuZGxlci5jYWxsKHRoaXMsIGFyZ3VtZW50c1sxXSwgYXJndW1lbnRzWzJdKTtcbiAgICAgICAgYnJlYWs7XG4gICAgICAvLyBzbG93ZXJcbiAgICAgIGRlZmF1bHQ6XG4gICAgICAgIGxlbiA9IGFyZ3VtZW50cy5sZW5ndGg7XG4gICAgICAgIGFyZ3MgPSBuZXcgQXJyYXkobGVuIC0gMSk7XG4gICAgICAgIGZvciAoaSA9IDE7IGkgPCBsZW47IGkrKylcbiAgICAgICAgICBhcmdzW2kgLSAxXSA9IGFyZ3VtZW50c1tpXTtcbiAgICAgICAgaGFuZGxlci5hcHBseSh0aGlzLCBhcmdzKTtcbiAgICB9XG4gIH0gZWxzZSBpZiAoaXNPYmplY3QoaGFuZGxlcikpIHtcbiAgICBsZW4gPSBhcmd1bWVudHMubGVuZ3RoO1xuICAgIGFyZ3MgPSBuZXcgQXJyYXkobGVuIC0gMSk7XG4gICAgZm9yIChpID0gMTsgaSA8IGxlbjsgaSsrKVxuICAgICAgYXJnc1tpIC0gMV0gPSBhcmd1bWVudHNbaV07XG5cbiAgICBsaXN0ZW5lcnMgPSBoYW5kbGVyLnNsaWNlKCk7XG4gICAgbGVuID0gbGlzdGVuZXJzLmxlbmd0aDtcbiAgICBmb3IgKGkgPSAwOyBpIDwgbGVuOyBpKyspXG4gICAgICBsaXN0ZW5lcnNbaV0uYXBwbHkodGhpcywgYXJncyk7XG4gIH1cblxuICByZXR1cm4gdHJ1ZTtcbn07XG5cbkV2ZW50RW1pdHRlci5wcm90b3R5cGUuYWRkTGlzdGVuZXIgPSBmdW5jdGlvbih0eXBlLCBsaXN0ZW5lcikge1xuICB2YXIgbTtcblxuICBpZiAoIWlzRnVuY3Rpb24obGlzdGVuZXIpKVxuICAgIHRocm93IFR5cGVFcnJvcignbGlzdGVuZXIgbXVzdCBiZSBhIGZ1bmN0aW9uJyk7XG5cbiAgaWYgKCF0aGlzLl9ldmVudHMpXG4gICAgdGhpcy5fZXZlbnRzID0ge307XG5cbiAgLy8gVG8gYXZvaWQgcmVjdXJzaW9uIGluIHRoZSBjYXNlIHRoYXQgdHlwZSA9PT0gXCJuZXdMaXN0ZW5lclwiISBCZWZvcmVcbiAgLy8gYWRkaW5nIGl0IHRvIHRoZSBsaXN0ZW5lcnMsIGZpcnN0IGVtaXQgXCJuZXdMaXN0ZW5lclwiLlxuICBpZiAodGhpcy5fZXZlbnRzLm5ld0xpc3RlbmVyKVxuICAgIHRoaXMuZW1pdCgnbmV3TGlzdGVuZXInLCB0eXBlLFxuICAgICAgICAgICAgICBpc0Z1bmN0aW9uKGxpc3RlbmVyLmxpc3RlbmVyKSA/XG4gICAgICAgICAgICAgIGxpc3RlbmVyLmxpc3RlbmVyIDogbGlzdGVuZXIpO1xuXG4gIGlmICghdGhpcy5fZXZlbnRzW3R5cGVdKVxuICAgIC8vIE9wdGltaXplIHRoZSBjYXNlIG9mIG9uZSBsaXN0ZW5lci4gRG9uJ3QgbmVlZCB0aGUgZXh0cmEgYXJyYXkgb2JqZWN0LlxuICAgIHRoaXMuX2V2ZW50c1t0eXBlXSA9IGxpc3RlbmVyO1xuICBlbHNlIGlmIChpc09iamVjdCh0aGlzLl9ldmVudHNbdHlwZV0pKVxuICAgIC8vIElmIHdlJ3ZlIGFscmVhZHkgZ290IGFuIGFycmF5LCBqdXN0IGFwcGVuZC5cbiAgICB0aGlzLl9ldmVudHNbdHlwZV0ucHVzaChsaXN0ZW5lcik7XG4gIGVsc2VcbiAgICAvLyBBZGRpbmcgdGhlIHNlY29uZCBlbGVtZW50LCBuZWVkIHRvIGNoYW5nZSB0byBhcnJheS5cbiAgICB0aGlzLl9ldmVudHNbdHlwZV0gPSBbdGhpcy5fZXZlbnRzW3R5cGVdLCBsaXN0ZW5lcl07XG5cbiAgLy8gQ2hlY2sgZm9yIGxpc3RlbmVyIGxlYWtcbiAgaWYgKGlzT2JqZWN0KHRoaXMuX2V2ZW50c1t0eXBlXSkgJiYgIXRoaXMuX2V2ZW50c1t0eXBlXS53YXJuZWQpIHtcbiAgICB2YXIgbTtcbiAgICBpZiAoIWlzVW5kZWZpbmVkKHRoaXMuX21heExpc3RlbmVycykpIHtcbiAgICAgIG0gPSB0aGlzLl9tYXhMaXN0ZW5lcnM7XG4gICAgfSBlbHNlIHtcbiAgICAgIG0gPSBFdmVudEVtaXR0ZXIuZGVmYXVsdE1heExpc3RlbmVycztcbiAgICB9XG5cbiAgICBpZiAobSAmJiBtID4gMCAmJiB0aGlzLl9ldmVudHNbdHlwZV0ubGVuZ3RoID4gbSkge1xuICAgICAgdGhpcy5fZXZlbnRzW3R5cGVdLndhcm5lZCA9IHRydWU7XG4gICAgICBjb25zb2xlLmVycm9yKCcobm9kZSkgd2FybmluZzogcG9zc2libGUgRXZlbnRFbWl0dGVyIG1lbW9yeSAnICtcbiAgICAgICAgICAgICAgICAgICAgJ2xlYWsgZGV0ZWN0ZWQuICVkIGxpc3RlbmVycyBhZGRlZC4gJyArXG4gICAgICAgICAgICAgICAgICAgICdVc2UgZW1pdHRlci5zZXRNYXhMaXN0ZW5lcnMoKSB0byBpbmNyZWFzZSBsaW1pdC4nLFxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9ldmVudHNbdHlwZV0ubGVuZ3RoKTtcbiAgICAgIGlmICh0eXBlb2YgY29uc29sZS50cmFjZSA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAvLyBub3Qgc3VwcG9ydGVkIGluIElFIDEwXG4gICAgICAgIGNvbnNvbGUudHJhY2UoKTtcbiAgICAgIH1cbiAgICB9XG4gIH1cblxuICByZXR1cm4gdGhpcztcbn07XG5cbkV2ZW50RW1pdHRlci5wcm90b3R5cGUub24gPSBFdmVudEVtaXR0ZXIucHJvdG90eXBlLmFkZExpc3RlbmVyO1xuXG5FdmVudEVtaXR0ZXIucHJvdG90eXBlLm9uY2UgPSBmdW5jdGlvbih0eXBlLCBsaXN0ZW5lcikge1xuICBpZiAoIWlzRnVuY3Rpb24obGlzdGVuZXIpKVxuICAgIHRocm93IFR5cGVFcnJvcignbGlzdGVuZXIgbXVzdCBiZSBhIGZ1bmN0aW9uJyk7XG5cbiAgdmFyIGZpcmVkID0gZmFsc2U7XG5cbiAgZnVuY3Rpb24gZygpIHtcbiAgICB0aGlzLnJlbW92ZUxpc3RlbmVyKHR5cGUsIGcpO1xuXG4gICAgaWYgKCFmaXJlZCkge1xuICAgICAgZmlyZWQgPSB0cnVlO1xuICAgICAgbGlzdGVuZXIuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcbiAgICB9XG4gIH1cblxuICBnLmxpc3RlbmVyID0gbGlzdGVuZXI7XG4gIHRoaXMub24odHlwZSwgZyk7XG5cbiAgcmV0dXJuIHRoaXM7XG59O1xuXG4vLyBlbWl0cyBhICdyZW1vdmVMaXN0ZW5lcicgZXZlbnQgaWZmIHRoZSBsaXN0ZW5lciB3YXMgcmVtb3ZlZFxuRXZlbnRFbWl0dGVyLnByb3RvdHlwZS5yZW1vdmVMaXN0ZW5lciA9IGZ1bmN0aW9uKHR5cGUsIGxpc3RlbmVyKSB7XG4gIHZhciBsaXN0LCBwb3NpdGlvbiwgbGVuZ3RoLCBpO1xuXG4gIGlmICghaXNGdW5jdGlvbihsaXN0ZW5lcikpXG4gICAgdGhyb3cgVHlwZUVycm9yKCdsaXN0ZW5lciBtdXN0IGJlIGEgZnVuY3Rpb24nKTtcblxuICBpZiAoIXRoaXMuX2V2ZW50cyB8fCAhdGhpcy5fZXZlbnRzW3R5cGVdKVxuICAgIHJldHVybiB0aGlzO1xuXG4gIGxpc3QgPSB0aGlzLl9ldmVudHNbdHlwZV07XG4gIGxlbmd0aCA9IGxpc3QubGVuZ3RoO1xuICBwb3NpdGlvbiA9IC0xO1xuXG4gIGlmIChsaXN0ID09PSBsaXN0ZW5lciB8fFxuICAgICAgKGlzRnVuY3Rpb24obGlzdC5saXN0ZW5lcikgJiYgbGlzdC5saXN0ZW5lciA9PT0gbGlzdGVuZXIpKSB7XG4gICAgZGVsZXRlIHRoaXMuX2V2ZW50c1t0eXBlXTtcbiAgICBpZiAodGhpcy5fZXZlbnRzLnJlbW92ZUxpc3RlbmVyKVxuICAgICAgdGhpcy5lbWl0KCdyZW1vdmVMaXN0ZW5lcicsIHR5cGUsIGxpc3RlbmVyKTtcblxuICB9IGVsc2UgaWYgKGlzT2JqZWN0KGxpc3QpKSB7XG4gICAgZm9yIChpID0gbGVuZ3RoOyBpLS0gPiAwOykge1xuICAgICAgaWYgKGxpc3RbaV0gPT09IGxpc3RlbmVyIHx8XG4gICAgICAgICAgKGxpc3RbaV0ubGlzdGVuZXIgJiYgbGlzdFtpXS5saXN0ZW5lciA9PT0gbGlzdGVuZXIpKSB7XG4gICAgICAgIHBvc2l0aW9uID0gaTtcbiAgICAgICAgYnJlYWs7XG4gICAgICB9XG4gICAgfVxuXG4gICAgaWYgKHBvc2l0aW9uIDwgMClcbiAgICAgIHJldHVybiB0aGlzO1xuXG4gICAgaWYgKGxpc3QubGVuZ3RoID09PSAxKSB7XG4gICAgICBsaXN0Lmxlbmd0aCA9IDA7XG4gICAgICBkZWxldGUgdGhpcy5fZXZlbnRzW3R5cGVdO1xuICAgIH0gZWxzZSB7XG4gICAgICBsaXN0LnNwbGljZShwb3NpdGlvbiwgMSk7XG4gICAgfVxuXG4gICAgaWYgKHRoaXMuX2V2ZW50cy5yZW1vdmVMaXN0ZW5lcilcbiAgICAgIHRoaXMuZW1pdCgncmVtb3ZlTGlzdGVuZXInLCB0eXBlLCBsaXN0ZW5lcik7XG4gIH1cblxuICByZXR1cm4gdGhpcztcbn07XG5cbkV2ZW50RW1pdHRlci5wcm90b3R5cGUucmVtb3ZlQWxsTGlzdGVuZXJzID0gZnVuY3Rpb24odHlwZSkge1xuICB2YXIga2V5LCBsaXN0ZW5lcnM7XG5cbiAgaWYgKCF0aGlzLl9ldmVudHMpXG4gICAgcmV0dXJuIHRoaXM7XG5cbiAgLy8gbm90IGxpc3RlbmluZyBmb3IgcmVtb3ZlTGlzdGVuZXIsIG5vIG5lZWQgdG8gZW1pdFxuICBpZiAoIXRoaXMuX2V2ZW50cy5yZW1vdmVMaXN0ZW5lcikge1xuICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID09PSAwKVxuICAgICAgdGhpcy5fZXZlbnRzID0ge307XG4gICAgZWxzZSBpZiAodGhpcy5fZXZlbnRzW3R5cGVdKVxuICAgICAgZGVsZXRlIHRoaXMuX2V2ZW50c1t0eXBlXTtcbiAgICByZXR1cm4gdGhpcztcbiAgfVxuXG4gIC8vIGVtaXQgcmVtb3ZlTGlzdGVuZXIgZm9yIGFsbCBsaXN0ZW5lcnMgb24gYWxsIGV2ZW50c1xuICBpZiAoYXJndW1lbnRzLmxlbmd0aCA9PT0gMCkge1xuICAgIGZvciAoa2V5IGluIHRoaXMuX2V2ZW50cykge1xuICAgICAgaWYgKGtleSA9PT0gJ3JlbW92ZUxpc3RlbmVyJykgY29udGludWU7XG4gICAgICB0aGlzLnJlbW92ZUFsbExpc3RlbmVycyhrZXkpO1xuICAgIH1cbiAgICB0aGlzLnJlbW92ZUFsbExpc3RlbmVycygncmVtb3ZlTGlzdGVuZXInKTtcbiAgICB0aGlzLl9ldmVudHMgPSB7fTtcbiAgICByZXR1cm4gdGhpcztcbiAgfVxuXG4gIGxpc3RlbmVycyA9IHRoaXMuX2V2ZW50c1t0eXBlXTtcblxuICBpZiAoaXNGdW5jdGlvbihsaXN0ZW5lcnMpKSB7XG4gICAgdGhpcy5yZW1vdmVMaXN0ZW5lcih0eXBlLCBsaXN0ZW5lcnMpO1xuICB9IGVsc2Uge1xuICAgIC8vIExJRk8gb3JkZXJcbiAgICB3aGlsZSAobGlzdGVuZXJzLmxlbmd0aClcbiAgICAgIHRoaXMucmVtb3ZlTGlzdGVuZXIodHlwZSwgbGlzdGVuZXJzW2xpc3RlbmVycy5sZW5ndGggLSAxXSk7XG4gIH1cbiAgZGVsZXRlIHRoaXMuX2V2ZW50c1t0eXBlXTtcblxuICByZXR1cm4gdGhpcztcbn07XG5cbkV2ZW50RW1pdHRlci5wcm90b3R5cGUubGlzdGVuZXJzID0gZnVuY3Rpb24odHlwZSkge1xuICB2YXIgcmV0O1xuICBpZiAoIXRoaXMuX2V2ZW50cyB8fCAhdGhpcy5fZXZlbnRzW3R5cGVdKVxuICAgIHJldCA9IFtdO1xuICBlbHNlIGlmIChpc0Z1bmN0aW9uKHRoaXMuX2V2ZW50c1t0eXBlXSkpXG4gICAgcmV0ID0gW3RoaXMuX2V2ZW50c1t0eXBlXV07XG4gIGVsc2VcbiAgICByZXQgPSB0aGlzLl9ldmVudHNbdHlwZV0uc2xpY2UoKTtcbiAgcmV0dXJuIHJldDtcbn07XG5cbkV2ZW50RW1pdHRlci5saXN0ZW5lckNvdW50ID0gZnVuY3Rpb24oZW1pdHRlciwgdHlwZSkge1xuICB2YXIgcmV0O1xuICBpZiAoIWVtaXR0ZXIuX2V2ZW50cyB8fCAhZW1pdHRlci5fZXZlbnRzW3R5cGVdKVxuICAgIHJldCA9IDA7XG4gIGVsc2UgaWYgKGlzRnVuY3Rpb24oZW1pdHRlci5fZXZlbnRzW3R5cGVdKSlcbiAgICByZXQgPSAxO1xuICBlbHNlXG4gICAgcmV0ID0gZW1pdHRlci5fZXZlbnRzW3R5cGVdLmxlbmd0aDtcbiAgcmV0dXJuIHJldDtcbn07XG5cbmZ1bmN0aW9uIGlzRnVuY3Rpb24oYXJnKSB7XG4gIHJldHVybiB0eXBlb2YgYXJnID09PSAnZnVuY3Rpb24nO1xufVxuXG5mdW5jdGlvbiBpc051bWJlcihhcmcpIHtcbiAgcmV0dXJuIHR5cGVvZiBhcmcgPT09ICdudW1iZXInO1xufVxuXG5mdW5jdGlvbiBpc09iamVjdChhcmcpIHtcbiAgcmV0dXJuIHR5cGVvZiBhcmcgPT09ICdvYmplY3QnICYmIGFyZyAhPT0gbnVsbDtcbn1cblxuZnVuY3Rpb24gaXNVbmRlZmluZWQoYXJnKSB7XG4gIHJldHVybiBhcmcgPT09IHZvaWQgMDtcbn1cbiIsIid1c2Ugc3RyaWN0JztcblxubW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKCcuL2lzLWltcGxlbWVudGVkJykoKSA/IFN5bWJvbCA6IHJlcXVpcmUoJy4vcG9seWZpbGwnKTtcbiIsIid1c2Ugc3RyaWN0JztcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7XG5cdHZhciBzeW1ib2w7XG5cdGlmICh0eXBlb2YgU3ltYm9sICE9PSAnZnVuY3Rpb24nKSByZXR1cm4gZmFsc2U7XG5cdHN5bWJvbCA9IFN5bWJvbCgndGVzdCBzeW1ib2wnKTtcblx0dHJ5IHtcblx0XHRpZiAoU3RyaW5nKHN5bWJvbCkgIT09ICdTeW1ib2wgKHRlc3Qgc3ltYm9sKScpIHJldHVybiBmYWxzZTtcblx0fSBjYXRjaCAoZSkgeyByZXR1cm4gZmFsc2U7IH1cblx0aWYgKHR5cGVvZiBTeW1ib2wuaXRlcmF0b3IgPT09ICdzeW1ib2wnKSByZXR1cm4gdHJ1ZTtcblxuXHQvLyBSZXR1cm4gJ3RydWUnIGZvciBwb2x5ZmlsbHNcblx0aWYgKHR5cGVvZiBTeW1ib2wuaXNDb25jYXRTcHJlYWRhYmxlICE9PSAnb2JqZWN0JykgcmV0dXJuIGZhbHNlO1xuXHRpZiAodHlwZW9mIFN5bWJvbC5pc1JlZ0V4cCAhPT0gJ29iamVjdCcpIHJldHVybiBmYWxzZTtcblx0aWYgKHR5cGVvZiBTeW1ib2wuaXRlcmF0b3IgIT09ICdvYmplY3QnKSByZXR1cm4gZmFsc2U7XG5cdGlmICh0eXBlb2YgU3ltYm9sLnRvUHJpbWl0aXZlICE9PSAnb2JqZWN0JykgcmV0dXJuIGZhbHNlO1xuXHRpZiAodHlwZW9mIFN5bWJvbC50b1N0cmluZ1RhZyAhPT0gJ29iamVjdCcpIHJldHVybiBmYWxzZTtcblx0aWYgKHR5cGVvZiBTeW1ib2wudW5zY29wYWJsZXMgIT09ICdvYmplY3QnKSByZXR1cm4gZmFsc2U7XG5cblx0cmV0dXJuIHRydWU7XG59O1xuIiwiJ3VzZSBzdHJpY3QnO1xuXG52YXIgYXNzaWduICAgICAgICA9IHJlcXVpcmUoJ2VzNS1leHQvb2JqZWN0L2Fzc2lnbicpXG4gICwgbm9ybWFsaXplT3B0cyA9IHJlcXVpcmUoJ2VzNS1leHQvb2JqZWN0L25vcm1hbGl6ZS1vcHRpb25zJylcbiAgLCBpc0NhbGxhYmxlICAgID0gcmVxdWlyZSgnZXM1LWV4dC9vYmplY3QvaXMtY2FsbGFibGUnKVxuICAsIGNvbnRhaW5zICAgICAgPSByZXF1aXJlKCdlczUtZXh0L3N0cmluZy8jL2NvbnRhaW5zJylcblxuICAsIGQ7XG5cbmQgPSBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChkc2NyLCB2YWx1ZS8qLCBvcHRpb25zKi8pIHtcblx0dmFyIGMsIGUsIHcsIG9wdGlvbnMsIGRlc2M7XG5cdGlmICgoYXJndW1lbnRzLmxlbmd0aCA8IDIpIHx8ICh0eXBlb2YgZHNjciAhPT0gJ3N0cmluZycpKSB7XG5cdFx0b3B0aW9ucyA9IHZhbHVlO1xuXHRcdHZhbHVlID0gZHNjcjtcblx0XHRkc2NyID0gbnVsbDtcblx0fSBlbHNlIHtcblx0XHRvcHRpb25zID0gYXJndW1lbnRzWzJdO1xuXHR9XG5cdGlmIChkc2NyID09IG51bGwpIHtcblx0XHRjID0gdyA9IHRydWU7XG5cdFx0ZSA9IGZhbHNlO1xuXHR9IGVsc2Uge1xuXHRcdGMgPSBjb250YWlucy5jYWxsKGRzY3IsICdjJyk7XG5cdFx0ZSA9IGNvbnRhaW5zLmNhbGwoZHNjciwgJ2UnKTtcblx0XHR3ID0gY29udGFpbnMuY2FsbChkc2NyLCAndycpO1xuXHR9XG5cblx0ZGVzYyA9IHsgdmFsdWU6IHZhbHVlLCBjb25maWd1cmFibGU6IGMsIGVudW1lcmFibGU6IGUsIHdyaXRhYmxlOiB3IH07XG5cdHJldHVybiAhb3B0aW9ucyA/IGRlc2MgOiBhc3NpZ24obm9ybWFsaXplT3B0cyhvcHRpb25zKSwgZGVzYyk7XG59O1xuXG5kLmdzID0gZnVuY3Rpb24gKGRzY3IsIGdldCwgc2V0LyosIG9wdGlvbnMqLykge1xuXHR2YXIgYywgZSwgb3B0aW9ucywgZGVzYztcblx0aWYgKHR5cGVvZiBkc2NyICE9PSAnc3RyaW5nJykge1xuXHRcdG9wdGlvbnMgPSBzZXQ7XG5cdFx0c2V0ID0gZ2V0O1xuXHRcdGdldCA9IGRzY3I7XG5cdFx0ZHNjciA9IG51bGw7XG5cdH0gZWxzZSB7XG5cdFx0b3B0aW9ucyA9IGFyZ3VtZW50c1szXTtcblx0fVxuXHRpZiAoZ2V0ID09IG51bGwpIHtcblx0XHRnZXQgPSB1bmRlZmluZWQ7XG5cdH0gZWxzZSBpZiAoIWlzQ2FsbGFibGUoZ2V0KSkge1xuXHRcdG9wdGlvbnMgPSBnZXQ7XG5cdFx0Z2V0ID0gc2V0ID0gdW5kZWZpbmVkO1xuXHR9IGVsc2UgaWYgKHNldCA9PSBudWxsKSB7XG5cdFx0c2V0ID0gdW5kZWZpbmVkO1xuXHR9IGVsc2UgaWYgKCFpc0NhbGxhYmxlKHNldCkpIHtcblx0XHRvcHRpb25zID0gc2V0O1xuXHRcdHNldCA9IHVuZGVmaW5lZDtcblx0fVxuXHRpZiAoZHNjciA9PSBudWxsKSB7XG5cdFx0YyA9IHRydWU7XG5cdFx0ZSA9IGZhbHNlO1xuXHR9IGVsc2Uge1xuXHRcdGMgPSBjb250YWlucy5jYWxsKGRzY3IsICdjJyk7XG5cdFx0ZSA9IGNvbnRhaW5zLmNhbGwoZHNjciwgJ2UnKTtcblx0fVxuXG5cdGRlc2MgPSB7IGdldDogZ2V0LCBzZXQ6IHNldCwgY29uZmlndXJhYmxlOiBjLCBlbnVtZXJhYmxlOiBlIH07XG5cdHJldHVybiAhb3B0aW9ucyA/IGRlc2MgOiBhc3NpZ24obm9ybWFsaXplT3B0cyhvcHRpb25zKSwgZGVzYyk7XG59O1xuIiwiJ3VzZSBzdHJpY3QnO1xuXG5tb2R1bGUuZXhwb3J0cyA9IHJlcXVpcmUoJy4vaXMtaW1wbGVtZW50ZWQnKSgpXG5cdD8gT2JqZWN0LmFzc2lnblxuXHQ6IHJlcXVpcmUoJy4vc2hpbScpO1xuIiwiJ3VzZSBzdHJpY3QnO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICgpIHtcblx0dmFyIGFzc2lnbiA9IE9iamVjdC5hc3NpZ24sIG9iajtcblx0aWYgKHR5cGVvZiBhc3NpZ24gIT09ICdmdW5jdGlvbicpIHJldHVybiBmYWxzZTtcblx0b2JqID0geyBmb286ICdyYXonIH07XG5cdGFzc2lnbihvYmosIHsgYmFyOiAnZHdhJyB9LCB7IHRyenk6ICd0cnp5JyB9KTtcblx0cmV0dXJuIChvYmouZm9vICsgb2JqLmJhciArIG9iai50cnp5KSA9PT0gJ3JhemR3YXRyenknO1xufTtcbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIGtleXMgID0gcmVxdWlyZSgnLi4va2V5cycpXG4gICwgdmFsdWUgPSByZXF1aXJlKCcuLi92YWxpZC12YWx1ZScpXG5cbiAgLCBtYXggPSBNYXRoLm1heDtcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZGVzdCwgc3JjLyosIOKApnNyY24qLykge1xuXHR2YXIgZXJyb3IsIGksIGwgPSBtYXgoYXJndW1lbnRzLmxlbmd0aCwgMiksIGFzc2lnbjtcblx0ZGVzdCA9IE9iamVjdCh2YWx1ZShkZXN0KSk7XG5cdGFzc2lnbiA9IGZ1bmN0aW9uIChrZXkpIHtcblx0XHR0cnkgeyBkZXN0W2tleV0gPSBzcmNba2V5XTsgfSBjYXRjaCAoZSkge1xuXHRcdFx0aWYgKCFlcnJvcikgZXJyb3IgPSBlO1xuXHRcdH1cblx0fTtcblx0Zm9yIChpID0gMTsgaSA8IGw7ICsraSkge1xuXHRcdHNyYyA9IGFyZ3VtZW50c1tpXTtcblx0XHRrZXlzKHNyYykuZm9yRWFjaChhc3NpZ24pO1xuXHR9XG5cdGlmIChlcnJvciAhPT0gdW5kZWZpbmVkKSB0aHJvdyBlcnJvcjtcblx0cmV0dXJuIGRlc3Q7XG59O1xuIiwiLy8gRGVwcmVjYXRlZFxuXG4ndXNlIHN0cmljdCc7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKG9iaikgeyByZXR1cm4gdHlwZW9mIG9iaiA9PT0gJ2Z1bmN0aW9uJzsgfTtcbiIsIid1c2Ugc3RyaWN0JztcblxubW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKCcuL2lzLWltcGxlbWVudGVkJykoKVxuXHQ/IE9iamVjdC5rZXlzXG5cdDogcmVxdWlyZSgnLi9zaGltJyk7XG4iLCIndXNlIHN0cmljdCc7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKCkge1xuXHR0cnkge1xuXHRcdE9iamVjdC5rZXlzKCdwcmltaXRpdmUnKTtcblx0XHRyZXR1cm4gdHJ1ZTtcblx0fSBjYXRjaCAoZSkgeyByZXR1cm4gZmFsc2U7IH1cbn07XG4iLCIndXNlIHN0cmljdCc7XG5cbnZhciBrZXlzID0gT2JqZWN0LmtleXM7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKG9iamVjdCkge1xuXHRyZXR1cm4ga2V5cyhvYmplY3QgPT0gbnVsbCA/IG9iamVjdCA6IE9iamVjdChvYmplY3QpKTtcbn07XG4iLCIndXNlIHN0cmljdCc7XG5cbnZhciBhc3NpZ24gPSByZXF1aXJlKCcuL2Fzc2lnbicpXG5cbiAgLCBmb3JFYWNoID0gQXJyYXkucHJvdG90eXBlLmZvckVhY2hcbiAgLCBjcmVhdGUgPSBPYmplY3QuY3JlYXRlLCBnZXRQcm90b3R5cGVPZiA9IE9iamVjdC5nZXRQcm90b3R5cGVPZlxuXG4gICwgcHJvY2VzcztcblxucHJvY2VzcyA9IGZ1bmN0aW9uIChzcmMsIG9iaikge1xuXHR2YXIgcHJvdG8gPSBnZXRQcm90b3R5cGVPZihzcmMpO1xuXHRyZXR1cm4gYXNzaWduKHByb3RvID8gcHJvY2Vzcyhwcm90bywgb2JqKSA6IG9iaiwgc3JjKTtcbn07XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKG9wdGlvbnMvKiwg4oCmb3B0aW9ucyovKSB7XG5cdHZhciByZXN1bHQgPSBjcmVhdGUobnVsbCk7XG5cdGZvckVhY2guY2FsbChhcmd1bWVudHMsIGZ1bmN0aW9uIChvcHRpb25zKSB7XG5cdFx0aWYgKG9wdGlvbnMgPT0gbnVsbCkgcmV0dXJuO1xuXHRcdHByb2Nlc3MoT2JqZWN0KG9wdGlvbnMpLCByZXN1bHQpO1xuXHR9KTtcblx0cmV0dXJuIHJlc3VsdDtcbn07XG4iLCIndXNlIHN0cmljdCc7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHZhbHVlKSB7XG5cdGlmICh2YWx1ZSA9PSBudWxsKSB0aHJvdyBuZXcgVHlwZUVycm9yKFwiQ2Fubm90IHVzZSBudWxsIG9yIHVuZGVmaW5lZFwiKTtcblx0cmV0dXJuIHZhbHVlO1xufTtcbiIsIid1c2Ugc3RyaWN0JztcblxubW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKCcuL2lzLWltcGxlbWVudGVkJykoKVxuXHQ/IFN0cmluZy5wcm90b3R5cGUuY29udGFpbnNcblx0OiByZXF1aXJlKCcuL3NoaW0nKTtcbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIHN0ciA9ICdyYXpkd2F0cnp5JztcblxubW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7XG5cdGlmICh0eXBlb2Ygc3RyLmNvbnRhaW5zICE9PSAnZnVuY3Rpb24nKSByZXR1cm4gZmFsc2U7XG5cdHJldHVybiAoKHN0ci5jb250YWlucygnZHdhJykgPT09IHRydWUpICYmIChzdHIuY29udGFpbnMoJ2ZvbycpID09PSBmYWxzZSkpO1xufTtcbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIGluZGV4T2YgPSBTdHJpbmcucHJvdG90eXBlLmluZGV4T2Y7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHNlYXJjaFN0cmluZy8qLCBwb3NpdGlvbiovKSB7XG5cdHJldHVybiBpbmRleE9mLmNhbGwodGhpcywgc2VhcmNoU3RyaW5nLCBhcmd1bWVudHNbMV0pID4gLTE7XG59O1xuIiwiJ3VzZSBzdHJpY3QnO1xuXG52YXIgZCA9IHJlcXVpcmUoJ2QnKVxuXG4gICwgY3JlYXRlID0gT2JqZWN0LmNyZWF0ZSwgZGVmaW5lUHJvcGVydGllcyA9IE9iamVjdC5kZWZpbmVQcm9wZXJ0aWVzXG4gICwgZ2VuZXJhdGVOYW1lLCBTeW1ib2w7XG5cbmdlbmVyYXRlTmFtZSA9IChmdW5jdGlvbiAoKSB7XG5cdHZhciBjcmVhdGVkID0gY3JlYXRlKG51bGwpO1xuXHRyZXR1cm4gZnVuY3Rpb24gKGRlc2MpIHtcblx0XHR2YXIgcG9zdGZpeCA9IDA7XG5cdFx0d2hpbGUgKGNyZWF0ZWRbZGVzYyArIChwb3N0Zml4IHx8ICcnKV0pICsrcG9zdGZpeDtcblx0XHRkZXNjICs9IChwb3N0Zml4IHx8ICcnKTtcblx0XHRjcmVhdGVkW2Rlc2NdID0gdHJ1ZTtcblx0XHRyZXR1cm4gJ0BAJyArIGRlc2M7XG5cdH07XG59KCkpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IFN5bWJvbCA9IGZ1bmN0aW9uIChkZXNjcmlwdGlvbikge1xuXHR2YXIgc3ltYm9sO1xuXHRpZiAodGhpcyBpbnN0YW5jZW9mIFN5bWJvbCkge1xuXHRcdHRocm93IG5ldyBUeXBlRXJyb3IoJ1R5cGVFcnJvcjogU3ltYm9sIGlzIG5vdCBhIGNvbnN0cnVjdG9yJyk7XG5cdH1cblx0c3ltYm9sID0gY3JlYXRlKFN5bWJvbC5wcm90b3R5cGUpO1xuXHRkZXNjcmlwdGlvbiA9IChkZXNjcmlwdGlvbiA9PT0gdW5kZWZpbmVkID8gJycgOiBTdHJpbmcoZGVzY3JpcHRpb24pKTtcblx0cmV0dXJuIGRlZmluZVByb3BlcnRpZXMoc3ltYm9sLCB7XG5cdFx0X19kZXNjcmlwdGlvbl9fOiBkKCcnLCBkZXNjcmlwdGlvbiksXG5cdFx0X19uYW1lX186IGQoJycsIGdlbmVyYXRlTmFtZShkZXNjcmlwdGlvbikpXG5cdH0pO1xufTtcblxuT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoU3ltYm9sLCB7XG5cdGNyZWF0ZTogZCgnJywgU3ltYm9sKCdjcmVhdGUnKSksXG5cdGhhc0luc3RhbmNlOiBkKCcnLCBTeW1ib2woJ2hhc0luc3RhbmNlJykpLFxuXHRpc0NvbmNhdFNwcmVhZGFibGU6IGQoJycsIFN5bWJvbCgnaXNDb25jYXRTcHJlYWRhYmxlJykpLFxuXHRpc1JlZ0V4cDogZCgnJywgU3ltYm9sKCdpc1JlZ0V4cCcpKSxcblx0aXRlcmF0b3I6IGQoJycsIFN5bWJvbCgnaXRlcmF0b3InKSksXG5cdHRvUHJpbWl0aXZlOiBkKCcnLCBTeW1ib2woJ3RvUHJpbWl0aXZlJykpLFxuXHR0b1N0cmluZ1RhZzogZCgnJywgU3ltYm9sKCd0b1N0cmluZ1RhZycpKSxcblx0dW5zY29wYWJsZXM6IGQoJycsIFN5bWJvbCgndW5zY29wYWJsZXMnKSlcbn0pO1xuXG5kZWZpbmVQcm9wZXJ0aWVzKFN5bWJvbC5wcm90b3R5cGUsIHtcblx0cHJvcGVyVG9TdHJpbmc6IGQoZnVuY3Rpb24gKCkge1xuXHRcdHJldHVybiAnU3ltYm9sICgnICsgdGhpcy5fX2Rlc2NyaXB0aW9uX18gKyAnKSc7XG5cdH0pLFxuXHR0b1N0cmluZzogZCgnJywgZnVuY3Rpb24gKCkgeyByZXR1cm4gdGhpcy5fX25hbWVfXzsgfSlcbn0pO1xuT2JqZWN0LmRlZmluZVByb3BlcnR5KFN5bWJvbC5wcm90b3R5cGUsIFN5bWJvbC50b1ByaW1pdGl2ZSwgZCgnJyxcblx0ZnVuY3Rpb24gKGhpbnQpIHtcblx0XHR0aHJvdyBuZXcgVHlwZUVycm9yKFwiQ29udmVyc2lvbiBvZiBzeW1ib2wgb2JqZWN0cyBpcyBub3QgYWxsb3dlZFwiKTtcblx0fSkpO1xuT2JqZWN0LmRlZmluZVByb3BlcnR5KFN5bWJvbC5wcm90b3R5cGUsIFN5bWJvbC50b1N0cmluZ1RhZywgZCgnYycsICdTeW1ib2wnKSk7XG4iLCJtb2R1bGUuZXhwb3J0cz17XG4gIFwidHlwZXNcIjoge1xuICAgIFwicm9vdFwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJyb290XCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZWNob1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInN0cmluZ1wiOiB7IFwiX2FyZ1wiOiAwLCBcInR5cGVcIjogXCJzdHJpbmdcIiB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwic3RyaW5nXCI6IHsgXCJfcmV0dmFsXCI6IFwic3RyaW5nXCIgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImxpc3RUYWJzXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHt9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjogeyBcIl9yZXR2YWxcIjogXCJ0YWJsaXN0XCIgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwicHJvdG9jb2xEZXNjcmlwdGlvblwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7fSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHsgXCJfcmV0dmFsXCI6IFwianNvblwiIH1cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHtcbiAgICAgICAgXCJ0YWJMaXN0Q2hhbmdlZFwiOiB7fVxuICAgICAgfVxuICAgIH0sXG4gICAgXCJ0YWJsaXN0XCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJkaWN0XCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwidGFibGlzdFwiLFxuICAgICAgXCJzcGVjaWFsaXphdGlvbnNcIjoge1xuICAgICAgICBcInNlbGVjdGVkXCI6IFwibnVtYmVyXCIsXG4gICAgICAgIFwidGFic1wiOiBcImFycmF5OnRhYlwiLFxuICAgICAgICBcInVybFwiOiBcInN0cmluZ1wiLFxuICAgICAgICBcImNvbnNvbGVBY3RvclwiOiBcImNvbnNvbGVcIixcbiAgICAgICAgXCJpbnNwZWN0b3JBY3RvclwiOiBcImluc3BlY3RvclwiLFxuICAgICAgICBcInN0eWxlU2hlZXRzQWN0b3JcIjogXCJzdHlsZXNoZWV0c1wiLFxuICAgICAgICBcInN0eWxlRWRpdG9yQWN0b3JcIjogXCJzdHlsZWVkaXRvclwiLFxuICAgICAgICBcIm1lbW9yeUFjdG9yXCI6IFwibWVtb3J5XCIsXG4gICAgICAgIFwiZXZlbnRMb29wTGFnQWN0b3JcIjogXCJldmVudExvb3BMYWdcIixcbiAgICAgICAgXCJwcmVmZXJlbmNlQWN0b3JcIjogXCJwcmVmZXJlbmNlXCIsXG4gICAgICAgIFwiZGV2aWNlQWN0b3JcIjogXCJkZXZpY2VcIixcblxuICAgICAgICBcInByb2ZpbGVyQWN0b3JcIjogXCJwcm9maWxlclwiLFxuICAgICAgICBcImNocm9tZURlYnVnZ2VyXCI6IFwiY2hyb21lRGVidWdnZXJcIixcbiAgICAgICAgXCJ3ZWJhcHBzQWN0b3JcIjogXCJ3ZWJhcHBzXCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwidGFiXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcInRhYlwiLFxuICAgICAgXCJmaWVsZHNcIjoge1xuICAgICAgICBcInRpdGxlXCI6IFwic3RyaW5nXCIsXG4gICAgICAgIFwidXJsXCI6IFwic3RyaW5nXCIsXG4gICAgICAgIFwib3V0ZXJXaW5kb3dJRFwiOiBcIm51bWJlclwiLFxuICAgICAgICBcImluc3BlY3RvckFjdG9yXCI6IFwiaW5zcGVjdG9yXCIsXG4gICAgICAgIFwiY2FsbFdhdGNoZXJBY3RvclwiOiBcImNhbGwtd2F0Y2hlclwiLFxuICAgICAgICBcImNhbnZhc0FjdG9yXCI6IFwiY2FudmFzXCIsXG4gICAgICAgIFwid2ViZ2xBY3RvclwiOiBcIndlYmdsXCIsXG4gICAgICAgIFwid2ViYXVkaW9BY3RvclwiOiBcIndlYmF1ZGlvXCIsXG4gICAgICAgIFwic3RvcmFnZUFjdG9yXCI6IFwic3RvcmFnZVwiLFxuICAgICAgICBcImdjbGlBY3RvclwiOiBcImdjbGlcIixcbiAgICAgICAgXCJtZW1vcnlBY3RvclwiOiBcIm1lbW9yeVwiLFxuICAgICAgICBcImV2ZW50TG9vcExhZ1wiOiBcImV2ZW50TG9vcExhZ1wiLFxuICAgICAgICBcInN0eWxlU2hlZXRzQWN0b3JcIjogXCJzdHlsZXNoZWV0c1wiLFxuICAgICAgICBcInN0eWxlRWRpdG9yQWN0b3JcIjogXCJzdHlsZWVkaXRvclwiLFxuXG4gICAgICAgIFwiY29uc29sZUFjdG9yXCI6IFwiY29uc29sZVwiLFxuICAgICAgICBcInRyYWNlQWN0b3JcIjogXCJ0cmFjZVwiXG4gICAgICB9LFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJhdHRhY2hcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge30sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7IFwiX3JldHZhbFwiOiBcImpzb25cIiB9XG4gICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge1xuICAgICAgICBcInRhYk5hdmlnYXRlZFwiOiB7XG4gICAgICAgICAgIFwidHlwZU5hbWVcIjogXCJ0YWJOYXZpZ2F0ZWRcIlxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgICBcImNvbnNvbGVcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiY29uc29sZVwiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImV2YWx1YXRlSlNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0ZXh0XCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJ1cmxcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3RyaW5nXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcImJpbmRPYmplY3RBY3RvclwiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAyLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJudWxsYWJsZTpzdHJpbmdcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwiZnJhbWVBY3RvclwiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAyLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJudWxsYWJsZTpzdHJpbmdcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwic2VsZWN0ZWROb2RlQWN0b3JcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMixcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6c3RyaW5nXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiZXZhbHVhdGVqc3Jlc3BvbnNlXCJcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJldmFsdWF0ZWpzcmVzcG9uc2VcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJldmFsdWF0ZWpzcmVzcG9uc2VcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJyZXN1bHRcIjogXCJvYmplY3RcIixcbiAgICAgICAgXCJleGNlcHRpb25cIjogXCJvYmplY3RcIixcbiAgICAgICAgXCJleGNlcHRpb25NZXNzYWdlXCI6IFwic3RyaW5nXCIsXG4gICAgICAgIFwiaW5wdXRcIjogXCJzdHJpbmdcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJvYmplY3RcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwib2JqZWN0XCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICAge1xuICAgICAgICAgICBcIm5hbWVcIjogXCJwcm9wZXJ0eVwiLFxuICAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgICBcIm5hbWVcIjoge1xuICAgICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgfSxcbiAgICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICAgIFwiZGVzY3JpcHRvclwiOiB7XG4gICAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwianNvblwiXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgfVxuICAgICAgICAgfVxuICAgICAgXVxuICAgIH1cbiAgfVxufVxuIiwibW9kdWxlLmV4cG9ydHM9e1xuICBcInR5cGVzXCI6IHtcbiAgICBcImxvbmdzdHJhY3RvclwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJsb25nc3RyYWN0b3JcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJzdWJzdHJpbmdcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3Vic3RyaW5nXCIsXG4gICAgICAgICAgICBcInN0YXJ0XCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJlbmRcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJzdWJzdHJpbmdcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInJlbGVhc2VcIixcbiAgICAgICAgICBcInJlbGVhc2VcIjogdHJ1ZSxcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwicmVsZWFzZVwiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJzdHlsZXNoZWV0XCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcInN0eWxlc2hlZXRcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJ0b2dnbGVEaXNhYmxlZFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJ0b2dnbGVEaXNhYmxlZFwiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiZGlzYWJsZWRcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJib29sZWFuXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRUZXh0XCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldFRleHRcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInRleHRcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJsb25nc3RyaW5nXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRPcmlnaW5hbFNvdXJjZXNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0T3JpZ2luYWxTb3VyY2VzXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJvcmlnaW5hbFNvdXJjZXNcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJudWxsYWJsZTphcnJheTpvcmlnaW5hbHNvdXJjZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0T3JpZ2luYWxMb2NhdGlvblwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRPcmlnaW5hbExvY2F0aW9uXCIsXG4gICAgICAgICAgICBcImxpbmVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcImNvbHVtblwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJudW1iZXJcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJvcmlnaW5hbGxvY2F0aW9ucmVzcG9uc2VcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInVwZGF0ZVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJ1cGRhdGVcIixcbiAgICAgICAgICAgIFwidGV4dFwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwidHJhbnNpdGlvblwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJib29sZWFuXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHtcbiAgICAgICAgXCJwcm9wZXJ0eS1jaGFuZ2VcIjoge1xuICAgICAgICAgIFwidHlwZVwiOiBcInByb3BlcnR5Q2hhbmdlXCIsXG4gICAgICAgICAgXCJwcm9wZXJ0eVwiOiB7XG4gICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgXCJ0eXBlXCI6IFwianNvblwiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBcInN0eWxlLWFwcGxpZWRcIjoge1xuICAgICAgICAgIFwidHlwZVwiOiBcInN0eWxlQXBwbGllZFwiXG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9LFxuICAgIFwib3JpZ2luYWxzb3VyY2VcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwib3JpZ2luYWxzb3VyY2VcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRUZXh0XCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldFRleHRcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInRleHRcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJsb25nc3RyaW5nXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJzdHlsZXNoZWV0c1wiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJzdHlsZXNoZWV0c1wiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldFN0eWxlU2hlZXRzXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldFN0eWxlU2hlZXRzXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJzdHlsZVNoZWV0c1wiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImFycmF5OnN0eWxlc2hlZXRcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImFkZFN0eWxlU2hlZXRcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYWRkU3R5bGVTaGVldFwiLFxuICAgICAgICAgICAgXCJ0ZXh0XCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwic3R5bGVTaGVldFwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcInN0eWxlc2hlZXRcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHt9XG4gICAgfSxcbiAgICBcIm9yaWdpbmFsbG9jYXRpb25yZXNwb25zZVwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiZGljdFwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcIm9yaWdpbmFsbG9jYXRpb25yZXNwb25zZVwiLFxuICAgICAgXCJzcGVjaWFsaXphdGlvbnNcIjoge1xuICAgICAgICBcInNvdXJjZVwiOiBcInN0cmluZ1wiLFxuICAgICAgICBcImxpbmVcIjogXCJudW1iZXJcIixcbiAgICAgICAgXCJjb2x1bW5cIjogXCJudW1iZXJcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJkb21ub2RlXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImRvbW5vZGVcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXROb2RlVmFsdWVcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0Tm9kZVZhbHVlXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJ2YWx1ZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImxvbmdzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInNldE5vZGVWYWx1ZVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJzZXROb2RlVmFsdWVcIixcbiAgICAgICAgICAgIFwidmFsdWVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldEltYWdlRGF0YVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRJbWFnZURhdGFcIixcbiAgICAgICAgICAgIFwibWF4RGltXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOm51bWJlclwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImltYWdlRGF0YVwiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwibW9kaWZ5QXR0cmlidXRlc1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJtb2RpZnlBdHRyaWJ1dGVzXCIsXG4gICAgICAgICAgICBcIm1vZGlmaWNhdGlvbnNcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYXJyYXk6anNvblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJhcHBsaWVkc3R5bGVcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJhcHBsaWVkc3R5bGVcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJydWxlXCI6IFwiZG9tc3R5bGVydWxlI2FjdG9yaWRcIixcbiAgICAgICAgXCJpbmhlcml0ZWRcIjogXCJudWxsYWJsZTpkb21ub2RlI2FjdG9yaWRcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJtYXRjaGVkc2VsZWN0b3JcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJtYXRjaGVkc2VsZWN0b3JcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJydWxlXCI6IFwiZG9tc3R5bGVydWxlI2FjdG9yaWRcIixcbiAgICAgICAgXCJzZWxlY3RvclwiOiBcInN0cmluZ1wiLFxuICAgICAgICBcInZhbHVlXCI6IFwic3RyaW5nXCIsXG4gICAgICAgIFwic3RhdHVzXCI6IFwibnVtYmVyXCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwibWF0Y2hlZHNlbGVjdG9ycmVzcG9uc2VcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJtYXRjaGVkc2VsZWN0b3JyZXNwb25zZVwiLFxuICAgICAgXCJzcGVjaWFsaXphdGlvbnNcIjoge1xuICAgICAgICBcInJ1bGVzXCI6IFwiYXJyYXk6ZG9tc3R5bGVydWxlXCIsXG4gICAgICAgIFwic2hlZXRzXCI6IFwiYXJyYXk6c3R5bGVzaGVldFwiLFxuICAgICAgICBcIm1hdGNoZWRcIjogXCJhcnJheTptYXRjaGVkc2VsZWN0b3JcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJhcHBsaWVkU3R5bGVzUmV0dXJuXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJkaWN0XCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiYXBwbGllZFN0eWxlc1JldHVyblwiLFxuICAgICAgXCJzcGVjaWFsaXphdGlvbnNcIjoge1xuICAgICAgICBcImVudHJpZXNcIjogXCJhcnJheTphcHBsaWVkc3R5bGVcIixcbiAgICAgICAgXCJydWxlc1wiOiBcImFycmF5OmRvbXN0eWxlcnVsZVwiLFxuICAgICAgICBcInNoZWV0c1wiOiBcImFycmF5OnN0eWxlc2hlZXRcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJwYWdlc3R5bGVcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwicGFnZXN0eWxlXCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0Q29tcHV0ZWRcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0Q29tcHV0ZWRcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcIm1hcmtNYXRjaGVkXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImJvb2xlYW5cIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwib25seU1hdGNoZWRcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYm9vbGVhblwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJmaWx0ZXJcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3RyaW5nXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJjb21wdXRlZFwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImpzb25cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldE1hdGNoZWRTZWxlY3RvcnNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0TWF0Y2hlZFNlbGVjdG9yc1wiLFxuICAgICAgICAgICAgXCJub2RlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImRvbW5vZGVcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwicHJvcGVydHlcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3RyaW5nXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcImZpbHRlclwiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAyLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJtYXRjaGVkc2VsZWN0b3JyZXNwb25zZVwiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0QXBwbGllZFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRBcHBsaWVkXCIsXG4gICAgICAgICAgICBcIm5vZGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZG9tbm9kZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJpbmhlcml0ZWRcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYm9vbGVhblwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJtYXRjaGVkU2VsZWN0b3JzXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImJvb2xlYW5cIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwiZmlsdGVyXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImFwcGxpZWRTdHlsZXNSZXR1cm5cIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldExheW91dFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRMYXlvdXRcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcImF1dG9NYXJnaW5zXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImJvb2xlYW5cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJqc29uXCJcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJkb21zdHlsZXJ1bGVcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiZG9tc3R5bGVydWxlXCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwibW9kaWZ5UHJvcGVydGllc1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJtb2RpZnlQcm9wZXJ0aWVzXCIsXG4gICAgICAgICAgICBcIm1vZGlmaWNhdGlvbnNcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYXJyYXk6anNvblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwicnVsZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImRvbXN0eWxlcnVsZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge31cbiAgICB9LFxuICAgIFwiaGlnaGxpZ2h0ZXJcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiaGlnaGxpZ2h0ZXJcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJzaG93Qm94TW9kZWxcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwic2hvd0JveE1vZGVsXCIsXG4gICAgICAgICAgICBcIm5vZGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZG9tbm9kZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJyZWdpb25cIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImhpZGVCb3hNb2RlbFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJoaWRlQm94TW9kZWxcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwicGlja1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJwaWNrXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImNhbmNlbFBpY2tcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiY2FuY2VsUGlja1wiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJpbWFnZURhdGFcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJpbWFnZURhdGFcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJkYXRhXCI6IFwibnVsbGFibGU6bG9uZ3N0cmluZ1wiLFxuICAgICAgICBcInNpemVcIjogXCJqc29uXCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwiZGlzY29ubmVjdGVkTm9kZVwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiZGljdFwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImRpc2Nvbm5lY3RlZE5vZGVcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJub2RlXCI6IFwiZG9tbm9kZVwiLFxuICAgICAgICBcIm5ld1BhcmVudHNcIjogXCJhcnJheTpkb21ub2RlXCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwiZGlzY29ubmVjdGVkTm9kZUFycmF5XCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJkaWN0XCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiZGlzY29ubmVjdGVkTm9kZUFycmF5XCIsXG4gICAgICBcInNwZWNpYWxpemF0aW9uc1wiOiB7XG4gICAgICAgIFwibm9kZXNcIjogXCJhcnJheTpkb21ub2RlXCIsXG4gICAgICAgIFwibmV3UGFyZW50c1wiOiBcImFycmF5OmRvbW5vZGVcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJkb21tdXRhdGlvblwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiZGljdFwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImRvbW11dGF0aW9uXCIsXG4gICAgICBcInNwZWNpYWxpemF0aW9uc1wiOiB7fVxuICAgIH0sXG4gICAgXCJkb21ub2RlbGlzdFwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJkb21ub2RlbGlzdFwiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcIml0ZW1cIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiaXRlbVwiLFxuICAgICAgICAgICAgXCJpdGVtXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImRpc2Nvbm5lY3RlZE5vZGVcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcIml0ZW1zXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcIml0ZW1zXCIsXG4gICAgICAgICAgICBcInN0YXJ0XCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOm51bWJlclwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJlbmRcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6bnVtYmVyXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiZGlzY29ubmVjdGVkTm9kZUFycmF5XCJcbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJyZWxlYXNlXCIsXG4gICAgICAgICAgXCJyZWxlYXNlXCI6IHRydWUsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInJlbGVhc2VcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge31cbiAgICB9LFxuICAgIFwiZG9tdHJhdmVyc2FsYXJyYXlcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJkb210cmF2ZXJzYWxhcnJheVwiLFxuICAgICAgXCJzcGVjaWFsaXphdGlvbnNcIjoge1xuICAgICAgICBcIm5vZGVzXCI6IFwiYXJyYXk6ZG9tbm9kZVwiXG4gICAgICB9XG4gICAgfSxcbiAgICBcImRvbXdhbGtlclwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJkb213YWxrZXJcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJyZWxlYXNlXCIsXG4gICAgICAgICAgXCJyZWxlYXNlXCI6IHRydWUsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInJlbGVhc2VcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwicGlja1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJwaWNrXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiZGlzY29ubmVjdGVkTm9kZVwiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiY2FuY2VsUGlja1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJjYW5jZWxQaWNrXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImhpZ2hsaWdodFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJoaWdobGlnaHRcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJudWxsYWJsZTpkb21ub2RlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImRvY3VtZW50XCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImRvY3VtZW50XCIsXG4gICAgICAgICAgICBcIm5vZGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6ZG9tbm9kZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImRvbW5vZGVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImRvY3VtZW50RWxlbWVudFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJkb2N1bWVudEVsZW1lbnRcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJudWxsYWJsZTpkb21ub2RlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJub2RlXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiZG9tbm9kZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwicGFyZW50c1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJwYXJlbnRzXCIsXG4gICAgICAgICAgICBcIm5vZGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZG9tbm9kZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJzYW1lRG9jdW1lbnRcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJub2Rlc1wiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImFycmF5OmRvbW5vZGVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInJldGFpbk5vZGVcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwicmV0YWluTm9kZVwiLFxuICAgICAgICAgICAgXCJub2RlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImRvbW5vZGVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwidW5yZXRhaW5Ob2RlXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInVucmV0YWluTm9kZVwiLFxuICAgICAgICAgICAgXCJub2RlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImRvbW5vZGVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwicmVsZWFzZU5vZGVcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwicmVsZWFzZU5vZGVcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcImZvcmNlXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJjaGlsZHJlblwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJjaGlsZHJlblwiLFxuICAgICAgICAgICAgXCJub2RlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImRvbW5vZGVcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwibWF4Tm9kZXNcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcImNlbnRlclwiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInN0YXJ0XCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImRvbW5vZGVcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwid2hhdFRvU2hvd1wiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJkb210cmF2ZXJzYWxhcnJheVwiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwic2libGluZ3NcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwic2libGluZ3NcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcIm1heE5vZGVzXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJjZW50ZXJcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZG9tbm9kZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJzdGFydFwiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcIndoYXRUb1Nob3dcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiZG9tdHJhdmVyc2FsYXJyYXlcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcIm5leHRTaWJsaW5nXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcIm5leHRTaWJsaW5nXCIsXG4gICAgICAgICAgICBcIm5vZGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZG9tbm9kZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJ3aGF0VG9TaG93XCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcIm51bGxhYmxlOmRvbW5vZGVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInByZXZpb3VzU2libGluZ1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJwcmV2aW91c1NpYmxpbmdcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcIndoYXRUb1Nob3dcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJub2RlXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwibnVsbGFibGU6ZG9tbm9kZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwicXVlcnlTZWxlY3RvclwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJxdWVyeVNlbGVjdG9yXCIsXG4gICAgICAgICAgICBcIm5vZGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZG9tbm9kZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJzZWxlY3RvclwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJkaXNjb25uZWN0ZWROb2RlXCJcbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJxdWVyeVNlbGVjdG9yQWxsXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInF1ZXJ5U2VsZWN0b3JBbGxcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInNlbGVjdG9yXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwibGlzdFwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImRvbW5vZGVsaXN0XCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRTdWdnZXN0aW9uc0ZvclF1ZXJ5XCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldFN1Z2dlc3Rpb25zRm9yUXVlcnlcIixcbiAgICAgICAgICAgIFwicXVlcnlcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcImNvbXBsZXRpbmdcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInNlbGVjdG9yU3RhdGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMixcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJsaXN0XCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiYXJyYXk6YXJyYXk6c3RyaW5nXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJhZGRQc2V1ZG9DbGFzc0xvY2tcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYWRkUHNldWRvQ2xhc3NMb2NrXCIsXG4gICAgICAgICAgICBcIm5vZGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZG9tbm9kZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJwc2V1ZG9DbGFzc1wiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwicGFyZW50c1wiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAyLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiaGlkZU5vZGVcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiaGlkZU5vZGVcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInVuaGlkZU5vZGVcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwidW5oaWRlTm9kZVwiLFxuICAgICAgICAgICAgXCJub2RlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImRvbW5vZGVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwicmVtb3ZlUHNldWRvQ2xhc3NMb2NrXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInJlbW92ZVBzZXVkb0NsYXNzTG9ja1wiLFxuICAgICAgICAgICAgXCJub2RlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImRvbW5vZGVcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwicHNldWRvQ2xhc3NcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInBhcmVudHNcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMixcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImNsZWFyUHNldWRvQ2xhc3NMb2Nrc1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJjbGVhclBzZXVkb0NsYXNzTG9ja3NcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJudWxsYWJsZTpkb21ub2RlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImlubmVySFRNTFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJpbm5lckhUTUxcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJ2YWx1ZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImxvbmdzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcIm91dGVySFRNTFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJvdXRlckhUTUxcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJ2YWx1ZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImxvbmdzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInNldE91dGVySFRNTFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJzZXRPdXRlckhUTUxcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJyZW1vdmVOb2RlXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInJlbW92ZU5vZGVcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJuZXh0U2libGluZ1wiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcIm51bGxhYmxlOmRvbW5vZGVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImluc2VydEJlZm9yZVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJpbnNlcnRCZWZvcmVcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInBhcmVudFwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInNpYmxpbmdcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMixcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6ZG9tbm9kZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRNdXRhdGlvbnNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0TXV0YXRpb25zXCIsXG4gICAgICAgICAgICBcImNsZWFudXBcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJtdXRhdGlvbnNcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJhcnJheTpkb21tdXRhdGlvblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiaXNJbkRPTVRyZWVcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiaXNJbkRPTVRyZWVcIixcbiAgICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJkb21ub2RlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJhdHRhY2hlZFwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImJvb2xlYW5cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldE5vZGVBY3RvckZyb21PYmplY3RBY3RvclwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXROb2RlQWN0b3JGcm9tT2JqZWN0QWN0b3JcIixcbiAgICAgICAgICAgIFwib2JqZWN0QWN0b3JJRFwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIm5vZGVGcm9udFwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcIm51bGxhYmxlOmRpc2Nvbm5lY3RlZE5vZGVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHtcbiAgICAgICAgXCJuZXctbXV0YXRpb25zXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJuZXdNdXRhdGlvbnNcIlxuICAgICAgICB9LFxuICAgICAgICBcInBpY2tlci1ub2RlLXBpY2tlZFwiOiB7XG4gICAgICAgICAgXCJ0eXBlXCI6IFwicGlja2VyTm9kZVBpY2tlZFwiLFxuICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImRpc2Nvbm5lY3RlZE5vZGVcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgXCJwaWNrZXItbm9kZS1ob3ZlcmVkXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJwaWNrZXJOb2RlSG92ZXJlZFwiLFxuICAgICAgICAgIFwibm9kZVwiOiB7XG4gICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImRpc2Nvbm5lY3RlZE5vZGVcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgXCJoaWdobGlnaHRlci1yZWFkeVwiOiB7XG4gICAgICAgICAgXCJ0eXBlXCI6IFwiaGlnaGxpZ2h0ZXItcmVhZHlcIlxuICAgICAgICB9LFxuICAgICAgICBcImhpZ2hsaWdodGVyLWhpZGVcIjoge1xuICAgICAgICAgIFwidHlwZVwiOiBcImhpZ2hsaWdodGVyLWhpZGVcIlxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgICBcImluc3BlY3RvclwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJpbnNwZWN0b3JcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRXYWxrZXJcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0V2Fsa2VyXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJ3YWxrZXJcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJkb213YWxrZXJcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldFBhZ2VTdHlsZVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRQYWdlU3R5bGVcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInBhZ2VTdHlsZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcInBhZ2VzdHlsZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0SGlnaGxpZ2h0ZXJcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0SGlnaGxpZ2h0ZXJcIixcbiAgICAgICAgICAgIFwiYXV0b2hpZGVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYm9vbGVhblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiaGlnaGxpZ3RlclwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImhpZ2hsaWdodGVyXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRJbWFnZURhdGFGcm9tVVJMXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldEltYWdlRGF0YUZyb21VUkxcIixcbiAgICAgICAgICAgIFwidXJsXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJtYXhEaW1cIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6bnVtYmVyXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiaW1hZ2VEYXRhXCJcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJjYWxsLXN0YWNrLWl0ZW1cIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJjYWxsLXN0YWNrLWl0ZW1cIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJuYW1lXCI6IFwic3RyaW5nXCIsXG4gICAgICAgIFwiZmlsZVwiOiBcInN0cmluZ1wiLFxuICAgICAgICBcImxpbmVcIjogXCJudW1iZXJcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJjYWxsLWRldGFpbHNcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJjYWxsLWRldGFpbHNcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJ0eXBlXCI6IFwibnVtYmVyXCIsXG4gICAgICAgIFwibmFtZVwiOiBcInN0cmluZ1wiLFxuICAgICAgICBcInN0YWNrXCI6IFwiYXJyYXk6Y2FsbC1zdGFjay1pdGVtXCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwiZnVuY3Rpb24tY2FsbFwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJmdW5jdGlvbi1jYWxsXCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0RGV0YWlsc1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXREZXRhaWxzXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJpbmZvXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiY2FsbC1kZXRhaWxzXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJjYWxsLXdhdGNoZXJcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiY2FsbC13YXRjaGVyXCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwic2V0dXBcIixcbiAgICAgICAgICBcIm9uZXdheVwiOiB0cnVlLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJzZXR1cFwiLFxuICAgICAgICAgICAgXCJ0cmFjZWRHbG9iYWxzXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOmFycmF5OnN0cmluZ1wiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJ0cmFjZWRGdW5jdGlvbnNcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6YXJyYXk6c3RyaW5nXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInN0YXJ0UmVjb3JkaW5nXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImJvb2xlYW5cIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwicGVyZm9ybVJlbG9hZFwiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJib29sZWFuXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImZpbmFsaXplXCIsXG4gICAgICAgICAgXCJvbmV3YXlcIjogdHJ1ZSxcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZmluYWxpemVcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiaXNSZWNvcmRpbmdcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiaXNSZWNvcmRpbmdcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJib29sZWFuXCJcbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJyZXN1bWVSZWNvcmRpbmdcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwicmVzdW1lUmVjb3JkaW5nXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInBhdXNlUmVjb3JkaW5nXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInBhdXNlUmVjb3JkaW5nXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJjYWxsc1wiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImFycmF5OmZ1bmN0aW9uLWNhbGxcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImVyYXNlUmVjb3JkaW5nXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImVyYXNlUmVjb3JkaW5nXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHt9XG4gICAgfSxcbiAgICBcInNuYXBzaG90LWltYWdlXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJkaWN0XCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwic25hcHNob3QtaW1hZ2VcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJpbmRleFwiOiBcIm51bWJlclwiLFxuICAgICAgICBcIndpZHRoXCI6IFwibnVtYmVyXCIsXG4gICAgICAgIFwiaGVpZ2h0XCI6IFwibnVtYmVyXCIsXG4gICAgICAgIFwiZmxpcHBlZFwiOiBcImJvb2xlYW5cIixcbiAgICAgICAgXCJwaXhlbHNcIjogXCJ1aW50MzItYXJyYXlcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJzbmFwc2hvdC1vdmVydmlld1wiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiZGljdFwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcInNuYXBzaG90LW92ZXJ2aWV3XCIsXG4gICAgICBcInNwZWNpYWxpemF0aW9uc1wiOiB7XG4gICAgICAgIFwiY2FsbHNcIjogXCJhcnJheTpmdW5jdGlvbi1jYWxsXCIsXG4gICAgICAgIFwidGh1bWJuYWlsc1wiOiBcImFycmF5OnNuYXBzaG90LWltYWdlXCIsXG4gICAgICAgIFwic2NyZWVuc2hvdFwiOiBcInNuYXBzaG90LWltYWdlXCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwiZnJhbWUtc25hcHNob3RcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiZnJhbWUtc25hcHNob3RcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRPdmVydmlld1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRPdmVydmlld1wiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwib3ZlcnZpZXdcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJzbmFwc2hvdC1vdmVydmlld1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2VuZXJhdGVTY3JlZW5zaG90Rm9yXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdlbmVyYXRlU2NyZWVuc2hvdEZvclwiLFxuICAgICAgICAgICAgXCJjYWxsXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImZ1bmN0aW9uLWNhbGxcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInNjcmVlbnNob3RcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJzbmFwc2hvdC1pbWFnZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge31cbiAgICB9LFxuICAgIFwiY2FudmFzXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImNhbnZhc1wiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInNldHVwXCIsXG4gICAgICAgICAgXCJvbmV3YXlcIjogdHJ1ZSxcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwic2V0dXBcIixcbiAgICAgICAgICAgIFwicmVsb2FkXCI6IHtcbiAgICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImJvb2xlYW5cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZmluYWxpemVcIixcbiAgICAgICAgICBcIm9uZXdheVwiOiB0cnVlLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJmaW5hbGl6ZVwiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJpc0luaXRpYWxpemVkXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImlzSW5pdGlhbGl6ZWRcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcImluaXRpYWxpemVkXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiYm9vbGVhblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwicmVjb3JkQW5pbWF0aW9uRnJhbWVcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwicmVjb3JkQW5pbWF0aW9uRnJhbWVcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInNuYXBzaG90XCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiZnJhbWUtc25hcHNob3RcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHt9XG4gICAgfSxcbiAgICBcImdsLXNoYWRlclwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJnbC1zaGFkZXJcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRUZXh0XCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldFRleHRcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInRleHRcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImNvbXBpbGVcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiY29tcGlsZVwiLFxuICAgICAgICAgICAgXCJ0ZXh0XCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiZXJyb3JcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJudWxsYWJsZTpqc29uXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJnbC1wcm9ncmFtXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImdsLXByb2dyYW1cIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRWZXJ0ZXhTaGFkZXJcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0VmVydGV4U2hhZGVyXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJzaGFkZXJcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJnbC1zaGFkZXJcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldEZyYWdtZW50U2hhZGVyXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldEZyYWdtZW50U2hhZGVyXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJzaGFkZXJcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJnbC1zaGFkZXJcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImhpZ2hsaWdodFwiLFxuICAgICAgICAgIFwib25ld2F5XCI6IHRydWUsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImhpZ2hsaWdodFwiLFxuICAgICAgICAgICAgXCJ0aW50XCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcImFycmF5Om51bWJlclwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJ1bmhpZ2hsaWdodFwiLFxuICAgICAgICAgIFwib25ld2F5XCI6IHRydWUsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInVuaGlnaGxpZ2h0XCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImJsYWNrYm94XCIsXG4gICAgICAgICAgXCJvbmV3YXlcIjogdHJ1ZSxcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYmxhY2tib3hcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwidW5ibGFja2JveFwiLFxuICAgICAgICAgIFwib25ld2F5XCI6IHRydWUsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInVuYmxhY2tib3hcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge31cbiAgICB9LFxuICAgIFwid2ViZ2xcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwid2ViZ2xcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJzZXR1cFwiLFxuICAgICAgICAgIFwib25ld2F5XCI6IHRydWUsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInNldHVwXCIsXG4gICAgICAgICAgICBcInJlbG9hZFwiOiB7XG4gICAgICAgICAgICAgIFwiX29wdGlvblwiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJib29sZWFuXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImZpbmFsaXplXCIsXG4gICAgICAgICAgXCJvbmV3YXlcIjogdHJ1ZSxcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZmluYWxpemVcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0UHJvZ3JhbXNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0UHJvZ3JhbXNcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInByb2dyYW1zXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwiYXJyYXk6Z2wtcHJvZ3JhbVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge1xuICAgICAgICBcInByb2dyYW0tbGlua2VkXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJwcm9ncmFtTGlua2VkXCIsXG4gICAgICAgICAgXCJwcm9ncmFtXCI6IHtcbiAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2wtcHJvZ3JhbVwiXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgICBcImF1ZGlvbm9kZVwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJhdWRpb25vZGVcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRUeXBlXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldFR5cGVcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImlzU291cmNlXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImlzU291cmNlXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJzb3VyY2VcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJib29sZWFuXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJzZXRQYXJhbVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJzZXRQYXJhbVwiLFxuICAgICAgICAgICAgXCJwYXJhbVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwidmFsdWVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6cHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJlcnJvclwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcIm51bGxhYmxlOmpzb25cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldFBhcmFtXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldFBhcmFtXCIsXG4gICAgICAgICAgICBcInBhcmFtXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwidGV4dFwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcIm51bGxhYmxlOnByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0UGFyYW1GbGFnc1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRQYXJhbUZsYWdzXCIsXG4gICAgICAgICAgICBcInBhcmFtXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiZmxhZ3NcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJudWxsYWJsZTpwcmltaXRpdmVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldFBhcmFtc1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRQYXJhbXNcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInBhcmFtc1wiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImpzb25cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHt9XG4gICAgfSxcbiAgICBcIndlYmF1ZGlvXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcIndlYmF1ZGlvXCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwic2V0dXBcIixcbiAgICAgICAgICBcIm9uZXdheVwiOiB0cnVlLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJzZXR1cFwiLFxuICAgICAgICAgICAgXCJyZWxvYWRcIjoge1xuICAgICAgICAgICAgICBcIl9vcHRpb25cIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYm9vbGVhblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJmaW5hbGl6ZVwiLFxuICAgICAgICAgIFwib25ld2F5XCI6IHRydWUsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImZpbmFsaXplXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHtcbiAgICAgICAgXCJzdGFydC1jb250ZXh0XCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJzdGFydENvbnRleHRcIlxuICAgICAgICB9LFxuICAgICAgICBcImNvbm5lY3Qtbm9kZVwiOiB7XG4gICAgICAgICAgXCJ0eXBlXCI6IFwiY29ubmVjdE5vZGVcIixcbiAgICAgICAgICBcInNvdXJjZVwiOiB7XG4gICAgICAgICAgICBcIl9vcHRpb25cIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImF1ZGlvbm9kZVwiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcImRlc3RcIjoge1xuICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDAsXG4gICAgICAgICAgICBcInR5cGVcIjogXCJhdWRpb25vZGVcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgXCJkaXNjb25uZWN0LW5vZGVcIjoge1xuICAgICAgICAgIFwidHlwZVwiOiBcImRpc2Nvbm5lY3ROb2RlXCIsXG4gICAgICAgICAgXCJzb3VyY2VcIjoge1xuICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICBcInR5cGVcIjogXCJhdWRpb25vZGVcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgXCJjb25uZWN0LXBhcmFtXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJjb25uZWN0UGFyYW1cIixcbiAgICAgICAgICBcInNvdXJjZVwiOiB7XG4gICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImF1ZGlvbm9kZVwiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInBhcmFtXCI6IHtcbiAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3RyaW5nXCJcbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIFwiY2hhbmdlLXBhcmFtXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJjaGFuZ2VQYXJhbVwiLFxuICAgICAgICAgIFwic291cmNlXCI6IHtcbiAgICAgICAgICAgIFwiX29wdGlvblwiOiAwLFxuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYXVkaW9ub2RlXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicGFyYW1cIjoge1xuICAgICAgICAgICAgXCJfb3B0aW9uXCI6IDAsXG4gICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJ2YWx1ZVwiOiB7XG4gICAgICAgICAgICBcIl9vcHRpb25cIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBcImNyZWF0ZS1ub2RlXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJjcmVhdGVOb2RlXCIsXG4gICAgICAgICAgXCJzb3VyY2VcIjoge1xuICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICBcInR5cGVcIjogXCJhdWRpb25vZGVcIlxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0sXG4gICAgXCJvbGQtc3R5bGVzaGVldFwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJvbGQtc3R5bGVzaGVldFwiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInRvZ2dsZURpc2FibGVkXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInRvZ2dsZURpc2FibGVkXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJkaXNhYmxlZFwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImJvb2xlYW5cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImZldGNoU291cmNlXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImZldGNoU291cmNlXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInVwZGF0ZVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJ1cGRhdGVcIixcbiAgICAgICAgICAgIFwidGV4dFwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwidHJhbnNpdGlvblwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJib29sZWFuXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHtcbiAgICAgICAgXCJwcm9wZXJ0eS1jaGFuZ2VcIjoge1xuICAgICAgICAgIFwidHlwZVwiOiBcInByb3BlcnR5Q2hhbmdlXCIsXG4gICAgICAgICAgXCJwcm9wZXJ0eVwiOiB7XG4gICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgXCJ0eXBlXCI6IFwianNvblwiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBcInNvdXJjZS1sb2FkXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJzb3VyY2VMb2FkXCIsXG4gICAgICAgICAgXCJzb3VyY2VcIjoge1xuICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgXCJzdHlsZS1hcHBsaWVkXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJzdHlsZUFwcGxpZWRcIlxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgICBcInN0eWxlZWRpdG9yXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcInN0eWxlZWRpdG9yXCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwibmV3RG9jdW1lbnRcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwibmV3RG9jdW1lbnRcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwibmV3U3R5bGVTaGVldFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJuZXdTdHlsZVNoZWV0XCIsXG4gICAgICAgICAgICBcInRleHRcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3RyaW5nXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJzdHlsZVNoZWV0XCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwib2xkLXN0eWxlc2hlZXRcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHtcbiAgICAgICAgXCJkb2N1bWVudC1sb2FkXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJkb2N1bWVudExvYWRcIixcbiAgICAgICAgICBcInN0eWxlU2hlZXRzXCI6IHtcbiAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiYXJyYXk6b2xkLXN0eWxlc2hlZXRcIlxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0sXG4gICAgXCJjb29raWVvYmplY3RcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJjb29raWVvYmplY3RcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJuYW1lXCI6IFwic3RyaW5nXCIsXG4gICAgICAgIFwidmFsdWVcIjogXCJsb25nc3RyaW5nXCIsXG4gICAgICAgIFwicGF0aFwiOiBcIm51bGxhYmxlOnN0cmluZ1wiLFxuICAgICAgICBcImhvc3RcIjogXCJzdHJpbmdcIixcbiAgICAgICAgXCJpc0RvbWFpblwiOiBcImJvb2xlYW5cIixcbiAgICAgICAgXCJpc1NlY3VyZVwiOiBcImJvb2xlYW5cIixcbiAgICAgICAgXCJpc0h0dHBPbmx5XCI6IFwiYm9vbGVhblwiLFxuICAgICAgICBcImNyZWF0aW9uVGltZVwiOiBcIm51bWJlclwiLFxuICAgICAgICBcImxhc3RBY2Nlc3NlZFwiOiBcIm51bWJlclwiLFxuICAgICAgICBcImV4cGlyZXNcIjogXCJudW1iZXJcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJjb29raWVzdG9yZW9iamVjdFwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiZGljdFwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImNvb2tpZXN0b3Jlb2JqZWN0XCIsXG4gICAgICBcInNwZWNpYWxpemF0aW9uc1wiOiB7XG4gICAgICAgIFwidG90YWxcIjogXCJudW1iZXJcIixcbiAgICAgICAgXCJvZmZzZXRcIjogXCJudW1iZXJcIixcbiAgICAgICAgXCJkYXRhXCI6IFwiYXJyYXk6bnVsbGFibGU6Y29va2llb2JqZWN0XCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwic3RvcmFnZW9iamVjdFwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiZGljdFwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcInN0b3JhZ2VvYmplY3RcIixcbiAgICAgIFwic3BlY2lhbGl6YXRpb25zXCI6IHtcbiAgICAgICAgXCJuYW1lXCI6IFwic3RyaW5nXCIsXG4gICAgICAgIFwidmFsdWVcIjogXCJsb25nc3RyaW5nXCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwic3RvcmFnZXN0b3Jlb2JqZWN0XCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJkaWN0XCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwic3RvcmFnZXN0b3Jlb2JqZWN0XCIsXG4gICAgICBcInNwZWNpYWxpemF0aW9uc1wiOiB7XG4gICAgICAgIFwidG90YWxcIjogXCJudW1iZXJcIixcbiAgICAgICAgXCJvZmZzZXRcIjogXCJudW1iZXJcIixcbiAgICAgICAgXCJkYXRhXCI6IFwiYXJyYXk6bnVsbGFibGU6c3RvcmFnZW9iamVjdFwiXG4gICAgICB9XG4gICAgfSxcbiAgICBcImlkYm9iamVjdFwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiZGljdFwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImlkYm9iamVjdFwiLFxuICAgICAgXCJzcGVjaWFsaXphdGlvbnNcIjoge1xuICAgICAgICBcIm5hbWVcIjogXCJudWxsYWJsZTpzdHJpbmdcIixcbiAgICAgICAgXCJkYlwiOiBcIm51bGxhYmxlOnN0cmluZ1wiLFxuICAgICAgICBcIm9iamVjdFN0b3JlXCI6IFwibnVsbGFibGU6c3RyaW5nXCIsXG4gICAgICAgIFwib3JpZ2luXCI6IFwibnVsbGFibGU6c3RyaW5nXCIsXG4gICAgICAgIFwidmVyc2lvblwiOiBcIm51bGxhYmxlOm51bWJlclwiLFxuICAgICAgICBcIm9iamVjdFN0b3Jlc1wiOiBcIm51bGxhYmxlOm51bWJlclwiLFxuICAgICAgICBcImtleVBhdGhcIjogXCJudWxsYWJsZTpzdHJpbmdcIixcbiAgICAgICAgXCJhdXRvSW5jcmVtZW50XCI6IFwibnVsbGFibGU6Ym9vbGVhblwiLFxuICAgICAgICBcImluZGV4ZXNcIjogXCJudWxsYWJsZTpzdHJpbmdcIixcbiAgICAgICAgXCJ2YWx1ZVwiOiBcIm51bGxhYmxlOmxvbmdzdHJpbmdcIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJpZGJzdG9yZW9iamVjdFwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiZGljdFwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImlkYnN0b3Jlb2JqZWN0XCIsXG4gICAgICBcInNwZWNpYWxpemF0aW9uc1wiOiB7XG4gICAgICAgIFwidG90YWxcIjogXCJudW1iZXJcIixcbiAgICAgICAgXCJvZmZzZXRcIjogXCJudW1iZXJcIixcbiAgICAgICAgXCJkYXRhXCI6IFwiYXJyYXk6bnVsbGFibGU6aWRib2JqZWN0XCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwic3RvcmVVcGRhdGVPYmplY3RcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImRpY3RcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJzdG9yZVVwZGF0ZU9iamVjdFwiLFxuICAgICAgXCJzcGVjaWFsaXphdGlvbnNcIjoge1xuICAgICAgICBcImNoYW5nZWRcIjogXCJudWxsYWJsZTpqc29uXCIsXG4gICAgICAgIFwiZGVsZXRlZFwiOiBcIm51bGxhYmxlOmpzb25cIixcbiAgICAgICAgXCJhZGRlZFwiOiBcIm51bGxhYmxlOmpzb25cIlxuICAgICAgfVxuICAgIH0sXG4gICAgXCJjb29raWVzXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImNvb2tpZXNcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRTdG9yZU9iamVjdHNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0U3RvcmVPYmplY3RzXCIsXG4gICAgICAgICAgICBcImhvc3RcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcIm5hbWVzXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOmFycmF5OnN0cmluZ1wiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJvcHRpb25zXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDIsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOmpzb25cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJjb29raWVzdG9yZW9iamVjdFwiXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge31cbiAgICB9LFxuICAgIFwibG9jYWxTdG9yYWdlXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImxvY2FsU3RvcmFnZVwiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldFN0b3JlT2JqZWN0c1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRTdG9yZU9iamVjdHNcIixcbiAgICAgICAgICAgIFwiaG9zdFwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwibmFtZXNcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6YXJyYXk6c3RyaW5nXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcIm9wdGlvbnNcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMixcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwibnVsbGFibGU6anNvblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcInN0b3JhZ2VzdG9yZW9iamVjdFwiXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge31cbiAgICB9LFxuICAgIFwic2Vzc2lvblN0b3JhZ2VcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwic2Vzc2lvblN0b3JhZ2VcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRTdG9yZU9iamVjdHNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0U3RvcmVPYmplY3RzXCIsXG4gICAgICAgICAgICBcImhvc3RcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcIm5hbWVzXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOmFycmF5OnN0cmluZ1wiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJvcHRpb25zXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDIsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOmpzb25cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJzdG9yYWdlc3RvcmVvYmplY3RcIlxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHt9XG4gICAgfSxcbiAgICBcImluZGV4ZWREQlwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJpbmRleGVkREJcIixcbiAgICAgIFwibWV0aG9kc1wiOiBbXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRTdG9yZU9iamVjdHNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0U3RvcmVPYmplY3RzXCIsXG4gICAgICAgICAgICBcImhvc3RcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcIm5hbWVzXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOmFycmF5OnN0cmluZ1wiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJvcHRpb25zXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDIsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bGxhYmxlOmpzb25cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJpZGJzdG9yZW9iamVjdFwiXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge31cbiAgICB9LFxuICAgIFwic3RvcmVsaXN0XCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJkaWN0XCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwic3RvcmVsaXN0XCIsXG4gICAgICBcInNwZWNpYWxpemF0aW9uc1wiOiB7XG4gICAgICAgIFwiY29va2llc1wiOiBcImNvb2tpZXNcIixcbiAgICAgICAgXCJsb2NhbFN0b3JhZ2VcIjogXCJsb2NhbFN0b3JhZ2VcIixcbiAgICAgICAgXCJzZXNzaW9uU3RvcmFnZVwiOiBcInNlc3Npb25TdG9yYWdlXCIsXG4gICAgICAgIFwiaW5kZXhlZERCXCI6IFwiaW5kZXhlZERCXCJcbiAgICAgIH1cbiAgICB9LFxuICAgIFwic3RvcmFnZVwiOiB7XG4gICAgICBcImNhdGVnb3J5XCI6IFwiYWN0b3JcIixcbiAgICAgIFwidHlwZU5hbWVcIjogXCJzdG9yYWdlXCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwibGlzdFN0b3Jlc1wiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJsaXN0U3RvcmVzXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwic3RvcmVsaXN0XCJcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7XG4gICAgICAgIFwic3RvcmVzLXVwZGF0ZVwiOiB7XG4gICAgICAgICAgXCJ0eXBlXCI6IFwic3RvcmVzVXBkYXRlXCIsXG4gICAgICAgICAgXCJkYXRhXCI6IHtcbiAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3RvcmVVcGRhdGVPYmplY3RcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgXCJzdG9yZXMtY2xlYXJlZFwiOiB7XG4gICAgICAgICAgXCJ0eXBlXCI6IFwic3RvcmVzQ2xlYXJlZFwiLFxuICAgICAgICAgIFwiZGF0YVwiOiB7XG4gICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImpzb25cIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgXCJzdG9yZXMtcmVsb2FkZWRcIjoge1xuICAgICAgICAgIFwidHlwZVwiOiBcInN0b3Jlc1JlbGFvZGVkXCIsXG4gICAgICAgICAgXCJkYXRhXCI6IHtcbiAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgXCJ0eXBlXCI6IFwianNvblwiXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgICBcImdjbGlcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiZ2NsaVwiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInNwZWNzXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInNwZWNzXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwianNvblwiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZXhlY3V0ZVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJleGVjdXRlXCIsXG4gICAgICAgICAgICBcInR5cGVkXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImpzb25cIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInN0YXRlXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInN0YXRlXCIsXG4gICAgICAgICAgICBcInR5cGVkXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJzdGFydFwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwicmFua1wiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAyLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJudW1iZXJcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJqc29uXCJcbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJ0eXBlcGFyc2VcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwidHlwZXBhcnNlXCIsXG4gICAgICAgICAgICBcInR5cGVkXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJwYXJhbVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJqc29uXCJcbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJ0eXBlaW5jcmVtZW50XCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInR5cGVpbmNyZW1lbnRcIixcbiAgICAgICAgICAgIFwidHlwZWRcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3RyaW5nXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInBhcmFtXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwidHlwZWRlY3JlbWVudFwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJ0eXBlZGVjcmVtZW50XCIsXG4gICAgICAgICAgICBcInR5cGVkXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInN0cmluZ1wiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgXCJwYXJhbVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJzdHJpbmdcIlxuICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInNlbGVjdGlvbmluZm9cIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwic2VsZWN0aW9uaW5mb1wiLFxuICAgICAgICAgICAgXCJ0eXBlZFwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwicGFyYW1cIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwic3RyaW5nXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcImFjdGlvblwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAxLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJzdHJpbmdcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJqc29uXCJcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJtZW1vcnlcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwibWVtb3J5XCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwibWVhc3VyZVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJtZWFzdXJlXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwianNvblwiXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge31cbiAgICB9LFxuICAgIFwiZXZlbnRMb29wTGFnXCI6IHtcbiAgICAgIFwiY2F0ZWdvcnlcIjogXCJhY3RvclwiLFxuICAgICAgXCJ0eXBlTmFtZVwiOiBcImV2ZW50TG9vcExhZ1wiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInN0YXJ0XCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInN0YXJ0XCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJzdWNjZXNzXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJzdG9wXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInN0b3BcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7fVxuICAgICAgICB9XG4gICAgICBdLFxuICAgICAgXCJldmVudHNcIjoge1xuICAgICAgICBcImV2ZW50LWxvb3AtbGFnXCI6IHtcbiAgICAgICAgICBcInR5cGVcIjogXCJldmVudC1sb29wLWxhZ1wiLFxuICAgICAgICAgIFwidGltZVwiOiB7XG4gICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgIFwidHlwZVwiOiBcIm51bWJlclwiXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgICBcInByZWZlcmVuY2VcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwicHJlZmVyZW5jZVwiLFxuICAgICAgXCJtZXRob2RzXCI6IFtcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImdldEJvb2xQcmVmXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldEJvb2xQcmVmXCIsXG4gICAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwidmFsdWVcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJib29sZWFuXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRDaGFyUHJlZlwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRDaGFyUHJlZlwiLFxuICAgICAgICAgICAgXCJ2YWx1ZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwic3RyaW5nXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJnZXRJbnRQcmVmXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldEludFByZWZcIixcbiAgICAgICAgICAgIFwidmFsdWVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJ2YWx1ZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcIm51bWJlclwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0QWxsUHJlZnNcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0QWxsUHJlZnNcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwianNvblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwic2V0Qm9vbFByZWZcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwic2V0Qm9vbFByZWZcIixcbiAgICAgICAgICAgIFwibmFtZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwidmFsdWVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcInNldENoYXJQcmVmXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInNldENoYXJQcmVmXCIsXG4gICAgICAgICAgICBcIm5hbWVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMCxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDEsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJzZXRJbnRQcmVmXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInNldEludFByZWZcIixcbiAgICAgICAgICAgIFwibmFtZVwiOiB7XG4gICAgICAgICAgICAgIFwiX2FyZ1wiOiAwLFxuICAgICAgICAgICAgICBcInR5cGVcIjogXCJwcmltaXRpdmVcIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFwidmFsdWVcIjoge1xuICAgICAgICAgICAgICBcIl9hcmdcIjogMSxcbiAgICAgICAgICAgICAgXCJ0eXBlXCI6IFwicHJpbWl0aXZlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge31cbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIFwibmFtZVwiOiBcImNsZWFyVXNlclByZWZcIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiY2xlYXJVc2VyUHJlZlwiLFxuICAgICAgICAgICAgXCJuYW1lXCI6IHtcbiAgICAgICAgICAgICAgXCJfYXJnXCI6IDAsXG4gICAgICAgICAgICAgIFwidHlwZVwiOiBcInByaW1pdGl2ZVwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHt9XG4gICAgICAgIH1cbiAgICAgIF0sXG4gICAgICBcImV2ZW50c1wiOiB7fVxuICAgIH0sXG4gICAgXCJkZXZpY2VcIjoge1xuICAgICAgXCJjYXRlZ29yeVwiOiBcImFjdG9yXCIsXG4gICAgICBcInR5cGVOYW1lXCI6IFwiZGV2aWNlXCIsXG4gICAgICBcIm1ldGhvZHNcIjogW1xuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0RGVzY3JpcHRpb25cIixcbiAgICAgICAgICBcInJlcXVlc3RcIjoge1xuICAgICAgICAgICAgXCJ0eXBlXCI6IFwiZ2V0RGVzY3JpcHRpb25cIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwianNvblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0V2FsbHBhcGVyXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcImdldFdhbGxwYXBlclwiXG4gICAgICAgICAgfSxcbiAgICAgICAgICBcInJlc3BvbnNlXCI6IHtcbiAgICAgICAgICAgIFwidmFsdWVcIjoge1xuICAgICAgICAgICAgICBcIl9yZXR2YWxcIjogXCJsb25nc3RyaW5nXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBcIm5hbWVcIjogXCJzY3JlZW5zaG90VG9EYXRhVVJMXCIsXG4gICAgICAgICAgXCJyZXF1ZXN0XCI6IHtcbiAgICAgICAgICAgIFwidHlwZVwiOiBcInNjcmVlbnNob3RUb0RhdGFVUkxcIlxuICAgICAgICAgIH0sXG4gICAgICAgICAgXCJyZXNwb25zZVwiOiB7XG4gICAgICAgICAgICBcInZhbHVlXCI6IHtcbiAgICAgICAgICAgICAgXCJfcmV0dmFsXCI6IFwibG9uZ3N0cmluZ1wiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgXCJuYW1lXCI6IFwiZ2V0UmF3UGVybWlzc2lvbnNUYWJsZVwiLFxuICAgICAgICAgIFwicmVxdWVzdFwiOiB7XG4gICAgICAgICAgICBcInR5cGVcIjogXCJnZXRSYXdQZXJtaXNzaW9uc1RhYmxlXCJcbiAgICAgICAgICB9LFxuICAgICAgICAgIFwicmVzcG9uc2VcIjoge1xuICAgICAgICAgICAgXCJ2YWx1ZVwiOiB7XG4gICAgICAgICAgICAgIFwiX3JldHZhbFwiOiBcImpzb25cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgXSxcbiAgICAgIFwiZXZlbnRzXCI6IHt9XG4gICAgfVxuICB9LFxuICBcImZyb21cIjogXCJyb290XCJcbn1cbiIsIlwidXNlIHN0cmljdFwiO1xuXG52YXIgQ2xhc3MgPSByZXF1aXJlKFwiLi9jbGFzc1wiKS5DbGFzcztcbnZhciB1dGlsID0gcmVxdWlyZShcIi4vdXRpbFwiKTtcbnZhciBrZXlzID0gdXRpbC5rZXlzO1xudmFyIHZhbHVlcyA9IHV0aWwudmFsdWVzO1xudmFyIHBhaXJzID0gdXRpbC5wYWlycztcbnZhciBxdWVyeSA9IHV0aWwucXVlcnk7XG52YXIgZmluZFBhdGggPSB1dGlsLmZpbmRQYXRoO1xudmFyIEV2ZW50VGFyZ2V0ID0gcmVxdWlyZShcIi4vZXZlbnRcIikuRXZlbnRUYXJnZXQ7XG5cbnZhciBUeXBlU3lzdGVtID0gQ2xhc3Moe1xuICBjb25zdHJ1Y3RvcjogZnVuY3Rpb24oY2xpZW50KSB7XG4gICAgdmFyIHR5cGVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICB2YXIgc3BlY2lmaWNhdGlvbiA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG5cbiAgICB0aGlzLnNwZWNpZmljYXRpb24gPSBzcGVjaWZpY2F0aW9uO1xuICAgIHRoaXMudHlwZXMgPSB0eXBlcztcblxuICAgIHZhciB0eXBlRm9yID0gZnVuY3Rpb24gdHlwZUZvcih0eXBlTmFtZSkge1xuICAgICAgdHlwZU5hbWUgPSB0eXBlTmFtZSB8fCBcInByaW1pdGl2ZVwiO1xuICAgICAgaWYgKCF0eXBlc1t0eXBlTmFtZV0pIHtcbiAgICAgICAgZGVmaW5lVHlwZSh0eXBlTmFtZSk7XG4gICAgICB9XG5cbiAgICAgIHJldHVybiB0eXBlc1t0eXBlTmFtZV07XG4gICAgfTtcbiAgICB0aGlzLnR5cGVGb3IgPSB0eXBlRm9yO1xuXG4gICAgdmFyIGRlZmluZVR5cGUgPSBmdW5jdGlvbihkZXNjcmlwdG9yKSB7XG4gICAgICB2YXIgdHlwZSA9IHZvaWQoMCk7XG4gICAgICBpZiAodHlwZW9mKGRlc2NyaXB0b3IpID09PSBcInN0cmluZ1wiKSB7XG4gICAgICAgIGlmIChkZXNjcmlwdG9yLmluZGV4T2YoXCI6XCIpID4gMClcbiAgICAgICAgICB0eXBlID0gbWFrZUNvbXBvdW5kVHlwZShkZXNjcmlwdG9yKTtcbiAgICAgICAgZWxzZSBpZiAoZGVzY3JpcHRvci5pbmRleE9mKFwiI1wiKSA+IDApXG4gICAgICAgICAgdHlwZSA9IG5ldyBBY3RvckRldGFpbChkZXNjcmlwdG9yKTtcbiAgICAgICAgICBlbHNlIGlmIChzcGVjaWZpY2F0aW9uW2Rlc2NyaXB0b3JdKVxuICAgICAgICAgICAgdHlwZSA9IG1ha2VDYXRlZ29yeVR5cGUoc3BlY2lmaWNhdGlvbltkZXNjcmlwdG9yXSk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0eXBlID0gbWFrZUNhdGVnb3J5VHlwZShkZXNjcmlwdG9yKTtcbiAgICAgIH1cblxuICAgICAgaWYgKHR5cGUpXG4gICAgICAgIHR5cGVzW3R5cGUubmFtZV0gPSB0eXBlO1xuICAgICAgZWxzZVxuICAgICAgICB0aHJvdyBUeXBlRXJyb3IoXCJJbnZhbGlkIHR5cGU6IFwiICsgZGVzY3JpcHRvcik7XG4gICAgfTtcbiAgICB0aGlzLmRlZmluZVR5cGUgPSBkZWZpbmVUeXBlO1xuXG5cbiAgICB2YXIgbWFrZUNvbXBvdW5kVHlwZSA9IGZ1bmN0aW9uKG5hbWUpIHtcbiAgICAgIHZhciBpbmRleCA9IG5hbWUuaW5kZXhPZihcIjpcIik7XG4gICAgICB2YXIgYmFzZVR5cGUgPSBuYW1lLnNsaWNlKDAsIGluZGV4KTtcbiAgICAgIHZhciBzdWJUeXBlID0gbmFtZS5zbGljZShpbmRleCArIDEpO1xuXG4gICAgICByZXR1cm4gYmFzZVR5cGUgPT09IFwiYXJyYXlcIiA/IG5ldyBBcnJheU9mKHN1YlR5cGUpIDpcbiAgICAgIGJhc2VUeXBlID09PSBcIm51bGxhYmxlXCIgPyBuZXcgTWF5YmUoc3ViVHlwZSkgOlxuICAgICAgbnVsbDtcbiAgICB9O1xuXG4gICAgdmFyIG1ha2VDYXRlZ29yeVR5cGUgPSBmdW5jdGlvbihkZXNjcmlwdG9yKSB7XG4gICAgICB2YXIgY2F0ZWdvcnkgPSBkZXNjcmlwdG9yLmNhdGVnb3J5O1xuICAgICAgcmV0dXJuIGNhdGVnb3J5ID09PSBcImRpY3RcIiA/IG5ldyBEaWN0aW9uYXJ5KGRlc2NyaXB0b3IpIDpcbiAgICAgIGNhdGVnb3J5ID09PSBcImFjdG9yXCIgPyBuZXcgQWN0b3IoZGVzY3JpcHRvcikgOlxuICAgICAgbnVsbDtcbiAgICB9O1xuXG4gICAgdmFyIHJlYWQgPSBmdW5jdGlvbihpbnB1dCwgY29udGV4dCwgdHlwZU5hbWUpIHtcbiAgICAgIHJldHVybiB0eXBlRm9yKHR5cGVOYW1lKS5yZWFkKGlucHV0LCBjb250ZXh0KTtcbiAgICB9XG4gICAgdGhpcy5yZWFkID0gcmVhZDtcblxuICAgIHZhciB3cml0ZSA9IGZ1bmN0aW9uKGlucHV0LCBjb250ZXh0LCB0eXBlTmFtZSkge1xuICAgICAgcmV0dXJuIHR5cGVGb3IodHlwZU5hbWUpLndyaXRlKGlucHV0KTtcbiAgICB9O1xuICAgIHRoaXMud3JpdGUgPSB3cml0ZTtcblxuXG4gICAgdmFyIFR5cGUgPSBDbGFzcyh7XG4gICAgICBjb25zdHJ1Y3RvcjogZnVuY3Rpb24oKSB7XG4gICAgICB9LFxuICAgICAgZ2V0IG5hbWUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNhdGVnb3J5ID8gdGhpcy5jYXRlZ29yeSArIFwiOlwiICsgdGhpcy50eXBlIDpcbiAgICAgICAgdGhpcy50eXBlO1xuICAgICAgfSxcbiAgICAgIHJlYWQ6IGZ1bmN0aW9uKGlucHV0LCBjb250ZXh0KSB7XG4gICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoXCJgVHlwZWAgc3ViY2xhc3MgbXVzdCBpbXBsZW1lbnQgYHJlYWRgXCIpO1xuICAgICAgfSxcbiAgICAgIHdyaXRlOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCkge1xuICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKFwiYFR5cGVgIHN1YmNsYXNzIG11c3QgaW1wbGVtZW50IGB3cml0ZWBcIik7XG4gICAgICB9XG4gICAgfSk7XG5cbiAgICB2YXIgUHJpbWl0dmUgPSBDbGFzcyh7XG4gICAgICBleHRlbmRzOiBUeXBlLFxuICAgICAgY29uc3R1Y3RvcjogZnVuY3Rpb24odHlwZSkge1xuICAgICAgICB0aGlzLnR5cGUgPSB0eXBlO1xuICAgICAgfSxcbiAgICAgIHJlYWQ6IGZ1bmN0aW9uKGlucHV0LCBjb250ZXh0KSB7XG4gICAgICAgIHJldHVybiBpbnB1dDtcbiAgICAgIH0sXG4gICAgICB3cml0ZTogZnVuY3Rpb24oaW5wdXQsIGNvbnRleHQpIHtcbiAgICAgICAgcmV0dXJuIGlucHV0O1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgdmFyIE1heWJlID0gQ2xhc3Moe1xuICAgICAgZXh0ZW5kczogVHlwZSxcbiAgICAgIGNhdGVnb3J5OiBcIm51bGxhYmxlXCIsXG4gICAgICBjb25zdHJ1Y3RvcjogZnVuY3Rpb24odHlwZSkge1xuICAgICAgICB0aGlzLnR5cGUgPSB0eXBlO1xuICAgICAgfSxcbiAgICAgIHJlYWQ6IGZ1bmN0aW9uKGlucHV0LCBjb250ZXh0KSB7XG4gICAgICAgIHJldHVybiBpbnB1dCA9PT0gbnVsbCA/IG51bGwgOlxuICAgICAgICBpbnB1dCA9PT0gdm9pZCgwKSA/IHZvaWQoMCkgOlxuICAgICAgICByZWFkKGlucHV0LCBjb250ZXh0LCB0aGlzLnR5cGUpO1xuICAgICAgfSxcbiAgICAgIHdyaXRlOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCkge1xuICAgICAgICByZXR1cm4gaW5wdXQgPT09IG51bGwgPyBudWxsIDpcbiAgICAgICAgaW5wdXQgPT09IHZvaWQoMCkgPyB2b2lkKDApIDpcbiAgICAgICAgd3JpdGUoaW5wdXQsIGNvbnRleHQsIHRoaXMudHlwZSk7XG4gICAgICB9XG4gICAgfSk7XG5cbiAgICB2YXIgQXJyYXlPZiA9IENsYXNzKHtcbiAgICAgIGV4dGVuZHM6IFR5cGUsXG4gICAgICBjYXRlZ29yeTogXCJhcnJheVwiLFxuICAgICAgY29uc3RydWN0b3I6IGZ1bmN0aW9uKHR5cGUpIHtcbiAgICAgICAgdGhpcy50eXBlID0gdHlwZTtcbiAgICAgIH0sXG4gICAgICByZWFkOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCkge1xuICAgICAgICB2YXIgdHlwZSA9IHRoaXMudHlwZTtcbiAgICAgICAgcmV0dXJuIGlucHV0Lm1hcChmdW5jdGlvbigkKSB7IHJldHVybiByZWFkKCQsIGNvbnRleHQsIHR5cGUpIH0pO1xuICAgICAgfSxcbiAgICAgIHdyaXRlOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCkge1xuICAgICAgICB2YXIgdHlwZSA9IHRoaXMudHlwZTtcbiAgICAgICAgcmV0dXJuIGlucHV0Lm1hcChmdW5jdGlvbigkKSB7IHJldHVybiB3cml0ZSgkLCBjb250ZXh0LCB0eXBlKSB9KTtcbiAgICAgIH1cbiAgICB9KTtcblxuICAgIHZhciBtYWtlRmllbGQgPSBmdW5jdGlvbiBtYWtlRmllbGQobmFtZSwgdHlwZSkge1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSxcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCBuYW1lLCB7XG4gICAgICAgICAgICBjb25maWd1cmFibGU6IGZhbHNlLFxuICAgICAgICAgICAgdmFsdWU6IHJlYWQodGhpcy5zdGF0ZVtuYW1lXSwgdGhpcy5jb250ZXh0LCB0eXBlKVxuICAgICAgICAgIH0pO1xuICAgICAgICAgIHJldHVybiB0aGlzW25hbWVdO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfTtcblxuICAgIHZhciBtYWtlRmllbGRzID0gZnVuY3Rpb24oZGVzY3JpcHRvcikge1xuICAgICAgcmV0dXJuIHBhaXJzKGRlc2NyaXB0b3IpLnJlZHVjZShmdW5jdGlvbihmaWVsZHMsIHBhaXIpIHtcbiAgICAgICAgdmFyIG5hbWUgPSBwYWlyWzBdLCB0eXBlID0gcGFpclsxXTtcbiAgICAgICAgZmllbGRzW25hbWVdID0gbWFrZUZpZWxkKG5hbWUsIHR5cGUpO1xuICAgICAgICByZXR1cm4gZmllbGRzO1xuICAgICAgfSwge30pO1xuICAgIH1cblxuICAgIHZhciBEaWN0aW9uYXJ5VHlwZSA9IENsYXNzKHt9KTtcblxuICAgIHZhciBEaWN0aW9uYXJ5ID0gQ2xhc3Moe1xuICAgICAgZXh0ZW5kczogVHlwZSxcbiAgICAgIGNhdGVnb3J5OiBcImRpY3RcIixcbiAgICAgIGdldCBuYW1lKCkgeyByZXR1cm4gdGhpcy50eXBlOyB9LFxuICAgICAgY29uc3RydWN0b3I6IGZ1bmN0aW9uKGRlc2NyaXB0b3IpIHtcbiAgICAgICAgdGhpcy50eXBlID0gZGVzY3JpcHRvci50eXBlTmFtZTtcbiAgICAgICAgdGhpcy50eXBlcyA9IGRlc2NyaXB0b3Iuc3BlY2lhbGl6YXRpb25zO1xuXG4gICAgICAgIHZhciBwcm90byA9IE9iamVjdC5kZWZpbmVQcm9wZXJ0aWVzKHtcbiAgICAgICAgICBleHRlbmRzOiBEaWN0aW9uYXJ5VHlwZSxcbiAgICAgICAgICBjb25zdHJ1Y3RvcjogZnVuY3Rpb24oc3RhdGUsIGNvbnRleHQpIHtcbiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0aWVzKHRoaXMsIHtcbiAgICAgICAgICAgICAgc3RhdGU6IHtcbiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgdmFsdWU6IHN0YXRlXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgIGNvbnRleHQ6IHtcbiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICB3cml0YWJsZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBjb250ZXh0XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH1cbiAgICAgICAgfSwgbWFrZUZpZWxkcyh0aGlzLnR5cGVzKSk7XG5cbiAgICAgICAgdGhpcy5jbGFzcyA9IG5ldyBDbGFzcyhwcm90byk7XG4gICAgICB9LFxuICAgICAgcmVhZDogZnVuY3Rpb24oaW5wdXQsIGNvbnRleHQpIHtcbiAgICAgICAgcmV0dXJuIG5ldyB0aGlzLmNsYXNzKGlucHV0LCBjb250ZXh0KTtcbiAgICAgIH0sXG4gICAgICB3cml0ZTogZnVuY3Rpb24oaW5wdXQsIGNvbnRleHQpIHtcbiAgICAgICAgdmFyIG91dHB1dCA9IHt9O1xuICAgICAgICBmb3IgKHZhciBrZXkgaW4gaW5wdXQpIHtcbiAgICAgICAgICBvdXRwdXRba2V5XSA9IHdyaXRlKHZhbHVlLCBjb250ZXh0LCB0eXBlc1trZXldKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gb3V0cHV0O1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgdmFyIG1ha2VNZXRob2RzID0gZnVuY3Rpb24oZGVzY3JpcHRvcnMpIHtcbiAgICAgIHJldHVybiBkZXNjcmlwdG9ycy5yZWR1Y2UoZnVuY3Rpb24obWV0aG9kcywgZGVzY3JpcHRvcikge1xuICAgICAgICBtZXRob2RzW2Rlc2NyaXB0b3IubmFtZV0gPSB7XG4gICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSxcbiAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgd3JpdGFibGU6IGZhbHNlLFxuICAgICAgICAgIHZhbHVlOiBtYWtlTWV0aG9kKGRlc2NyaXB0b3IpXG4gICAgICAgIH07XG4gICAgICAgIHJldHVybiBtZXRob2RzO1xuICAgICAgfSwge30pO1xuICAgIH07XG5cbiAgICB2YXIgbWFrZUV2ZW50cyA9IGZ1bmN0aW9uKGRlc2NyaXB0b3JzKSB7XG4gICAgICByZXR1cm4gcGFpcnMoZGVzY3JpcHRvcnMpLnJlZHVjZShmdW5jdGlvbihldmVudHMsIHBhaXIpIHtcbiAgICAgICAgdmFyIG5hbWUgPSBwYWlyWzBdLCBkZXNjcmlwdG9yID0gcGFpclsxXTtcbiAgICAgICAgdmFyIGV2ZW50ID0gbmV3IEV2ZW50KG5hbWUsIGRlc2NyaXB0b3IpO1xuICAgICAgICBldmVudHNbZXZlbnQuZXZlbnRUeXBlXSA9IGV2ZW50O1xuICAgICAgICByZXR1cm4gZXZlbnRzO1xuICAgICAgfSwgT2JqZWN0LmNyZWF0ZShudWxsKSk7XG4gICAgfTtcblxuICAgIHZhciBBY3RvciA9IENsYXNzKHtcbiAgICAgIGV4dGVuZHM6IFR5cGUsXG4gICAgICBjYXRlZ29yeTogXCJhY3RvclwiLFxuICAgICAgZ2V0IG5hbWUoKSB7IHJldHVybiB0aGlzLnR5cGU7IH0sXG4gICAgICBjb25zdHJ1Y3RvcjogZnVuY3Rpb24oZGVzY3JpcHRvcikge1xuICAgICAgICB0aGlzLnR5cGUgPSBkZXNjcmlwdG9yLnR5cGVOYW1lO1xuXG4gICAgICAgIHZhciBldmVudHMgPSBtYWtlRXZlbnRzKGRlc2NyaXB0b3IuZXZlbnRzIHx8IHt9KTtcbiAgICAgICAgdmFyIGZpZWxkcyA9IG1ha2VGaWVsZHMoZGVzY3JpcHRvci5maWVsZHMgfHwge30pO1xuICAgICAgICB2YXIgbWV0aG9kcyA9IG1ha2VNZXRob2RzKGRlc2NyaXB0b3IubWV0aG9kcyB8fCBbXSk7XG5cblxuICAgICAgICB2YXIgcHJvdG8gPSB7XG4gICAgICAgICAgZXh0ZW5kczogRnJvbnQsXG4gICAgICAgICAgY29uc3RydWN0b3I6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgRnJvbnQuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcbiAgICAgICAgICB9LFxuICAgICAgICAgIGV2ZW50czogZXZlbnRzXG4gICAgICAgIH07XG4gICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0aWVzKHByb3RvLCBmaWVsZHMpO1xuICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydGllcyhwcm90bywgbWV0aG9kcyk7XG5cbiAgICAgICAgdGhpcy5jbGFzcyA9IENsYXNzKHByb3RvKTtcbiAgICAgIH0sXG4gICAgICByZWFkOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCwgZGV0YWlsKSB7XG4gICAgICAgIHZhciBzdGF0ZSA9IHR5cGVvZihpbnB1dCkgPT09IFwic3RyaW5nXCIgPyB7IGFjdG9yOiBpbnB1dCB9IDogaW5wdXQ7XG5cbiAgICAgICAgdmFyIGFjdG9yID0gY2xpZW50LmdldChzdGF0ZS5hY3RvcikgfHwgbmV3IHRoaXMuY2xhc3Moc3RhdGUsIGNvbnRleHQpO1xuICAgICAgICBhY3Rvci5mb3JtKHN0YXRlLCBkZXRhaWwsIGNvbnRleHQpO1xuXG4gICAgICAgIHJldHVybiBhY3RvcjtcbiAgICAgIH0sXG4gICAgICB3cml0ZTogZnVuY3Rpb24oaW5wdXQsIGNvbnRleHQsIGRldGFpbCkge1xuICAgICAgICByZXR1cm4gaW5wdXQuaWQ7XG4gICAgICB9XG4gICAgfSk7XG4gICAgZXhwb3J0cy5BY3RvciA9IEFjdG9yO1xuXG5cbiAgICB2YXIgQWN0b3JEZXRhaWwgPSBDbGFzcyh7XG4gICAgICBleHRlbmRzOiBBY3RvcixcbiAgICAgIGNvbnN0cnVjdG9yOiBmdW5jdGlvbihuYW1lKSB7XG4gICAgICAgIHZhciBwYXJ0cyA9IG5hbWUuc3BsaXQoXCIjXCIpXG4gICAgICAgIHRoaXMuYWN0b3JUeXBlID0gcGFydHNbMF1cbiAgICAgICAgdGhpcy5kZXRhaWwgPSBwYXJ0c1sxXTtcbiAgICAgIH0sXG4gICAgICByZWFkOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCkge1xuICAgICAgICByZXR1cm4gdHlwZUZvcih0aGlzLmFjdG9yVHlwZSkucmVhZChpbnB1dCwgY29udGV4dCwgdGhpcy5kZXRhaWwpO1xuICAgICAgfSxcbiAgICAgIHdyaXRlOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCkge1xuICAgICAgICByZXR1cm4gdHlwZUZvcih0aGlzLmFjdG9yVHlwZSkud3JpdGUoaW5wdXQsIGNvbnRleHQsIHRoaXMuZGV0YWlsKTtcbiAgICAgIH1cbiAgICB9KTtcbiAgICBleHBvcnRzLkFjdG9yRGV0YWlsID0gQWN0b3JEZXRhaWw7XG5cbiAgICB2YXIgTWV0aG9kID0gQ2xhc3Moe1xuICAgICAgZXh0ZW5kczogVHlwZSxcbiAgICAgIGNvbnN0cnVjdG9yOiBmdW5jdGlvbihkZXNjcmlwdG9yKSB7XG4gICAgICAgIHRoaXMudHlwZSA9IGRlc2NyaXB0b3IubmFtZTtcbiAgICAgICAgdGhpcy5wYXRoID0gZmluZFBhdGgoZGVzY3JpcHRvci5yZXNwb25zZSwgXCJfcmV0dmFsXCIpO1xuICAgICAgICB0aGlzLnJlc3BvbnNlVHlwZSA9IHRoaXMucGF0aCAmJiBxdWVyeShkZXNjcmlwdG9yLnJlc3BvbnNlLCB0aGlzLnBhdGgpLl9yZXR2YWw7XG4gICAgICAgIHRoaXMucmVxdWVzdFR5cGUgPSBkZXNjcmlwdG9yLnJlcXVlc3QudHlwZTtcblxuICAgICAgICB2YXIgcGFyYW1zID0gW107XG4gICAgICAgIGZvciAodmFyIGtleSBpbiBkZXNjcmlwdG9yLnJlcXVlc3QpIHtcbiAgICAgICAgICBpZiAoa2V5ICE9PSBcInR5cGVcIikge1xuICAgICAgICAgICAgdmFyIHBhcmFtID0gZGVzY3JpcHRvci5yZXF1ZXN0W2tleV07XG4gICAgICAgICAgICB2YXIgaW5kZXggPSBcIl9hcmdcIiBpbiBwYXJhbSA/IHBhcmFtLl9hcmcgOiBwYXJhbS5fb3B0aW9uO1xuICAgICAgICAgICAgdmFyIGlzUGFyYW0gPSBwYXJhbS5fb3B0aW9uID09PSBpbmRleDtcbiAgICAgICAgICAgIHZhciBpc0FyZ3VtZW50ID0gcGFyYW0uX2FyZyA9PT0gaW5kZXg7XG4gICAgICAgICAgICBwYXJhbXNbaW5kZXhdID0ge1xuICAgICAgICAgICAgICB0eXBlOiBwYXJhbS50eXBlLFxuICAgICAgICAgICAgICBrZXk6IGtleSxcbiAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxuICAgICAgICAgICAgICBpc1BhcmFtOiBpc1BhcmFtLFxuICAgICAgICAgICAgICBpc0FyZ3VtZW50OiBpc0FyZ3VtZW50XG4gICAgICAgICAgICB9O1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcmFtcztcbiAgICAgIH0sXG4gICAgICByZWFkOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCkge1xuICAgICAgICByZXR1cm4gcmVhZChxdWVyeShpbnB1dCwgdGhpcy5wYXRoKSwgY29udGV4dCwgdGhpcy5yZXNwb25zZVR5cGUpO1xuICAgICAgfSxcbiAgICAgIHdyaXRlOiBmdW5jdGlvbihpbnB1dCwgY29udGV4dCkge1xuICAgICAgICByZXR1cm4gdGhpcy5wYXJhbXMucmVkdWNlKGZ1bmN0aW9uKHJlc3VsdCwgcGFyYW0pIHtcbiAgICAgICAgICByZXN1bHRbcGFyYW0ua2V5XSA9IHdyaXRlKGlucHV0W3BhcmFtLmluZGV4XSwgY29udGV4dCwgcGFyYW0udHlwZSk7XG4gICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgfSwge3R5cGU6IHRoaXMudHlwZX0pO1xuICAgICAgfVxuICAgIH0pO1xuICAgIGV4cG9ydHMuTWV0aG9kID0gTWV0aG9kO1xuXG4gICAgdmFyIHByb2ZpbGVyID0gZnVuY3Rpb24obWV0aG9kLCBpZCkge1xuICAgICAgcmV0dXJuIGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgc3RhcnQgPSBuZXcgRGF0ZSgpO1xuICAgICAgICByZXR1cm4gbWV0aG9kLmFwcGx5KHRoaXMsIGFyZ3VtZW50cykudGhlbihmdW5jdGlvbihyZXN1bHQpIHtcbiAgICAgICAgICB2YXIgZW5kID0gbmV3IERhdGUoKTtcbiAgICAgICAgICBjbGllbnQudGVsZW1ldHJ5LmFkZChpZCwgK2VuZCAtIHN0YXJ0KTtcbiAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICB9KTtcbiAgICAgIH07XG4gICAgfTtcblxuICAgIHZhciBkZXN0cnVjdG9yID0gZnVuY3Rpb24obWV0aG9kKSB7XG4gICAgICByZXR1cm4gZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiBtZXRob2QuYXBwbHkodGhpcywgYXJndW1lbnRzKS50aGVuKGZ1bmN0aW9uKHJlc3VsdCkge1xuICAgICAgICAgIGNsaWVudC5yZWxlYXNlKHRoaXMpO1xuICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgIH0pO1xuICAgICAgfTtcbiAgICB9O1xuXG4gICAgZnVuY3Rpb24gbWFrZU1ldGhvZChkZXNjcmlwdG9yKSB7XG4gICAgICB2YXIgdHlwZSA9IG5ldyBNZXRob2QoZGVzY3JpcHRvcik7XG4gICAgICB2YXIgbWV0aG9kID0gZGVzY3JpcHRvci5vbmV3YXkgPyBtYWtlVW5pZGlyZWNhdGlvbmFsTWV0aG9kKGRlc2NyaXB0b3IsIHR5cGUpIDpcbiAgICAgICAgICAgICAgICAgICBtYWtlQmlkaXJlY3Rpb25hbE1ldGhvZChkZXNjcmlwdG9yLCB0eXBlKTtcblxuICAgICAgaWYgKGRlc2NyaXB0b3IudGVsZW1ldHJ5KVxuICAgICAgICBtZXRob2QgPSBwcm9maWxlcihtZXRob2QpO1xuICAgICAgaWYgKGRlc2NyaXB0b3IucmVsZWFzZSlcbiAgICAgICAgbWV0aG9kID0gZGVzdHJ1Y3RvcihtZXRob2QpO1xuXG4gICAgICByZXR1cm4gbWV0aG9kO1xuICAgIH1cblxuICAgIHZhciBtYWtlVW5pZGlyZWNhdGlvbmFsTWV0aG9kID0gZnVuY3Rpb24oZGVzY3JpcHRvciwgdHlwZSkge1xuICAgICAgcmV0dXJuIGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgcGFja2V0ID0gdHlwZS53cml0ZShhcmd1bWVudHMsIHRoaXMpO1xuICAgICAgICBwYWNrZXQudG8gPSB0aGlzLmlkO1xuICAgICAgICBjbGllbnQuc2VuZChwYWNrZXQpO1xuICAgICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKHZvaWQoMCkpO1xuICAgICAgfTtcbiAgICB9O1xuXG4gICAgdmFyIG1ha2VCaWRpcmVjdGlvbmFsTWV0aG9kID0gZnVuY3Rpb24oZGVzY3JpcHRvciwgdHlwZSkge1xuICAgICAgcmV0dXJuIGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgY29udGV4dCA9IHRoaXMuY29udGV4dDtcbiAgICAgICAgdmFyIHBhY2tldCA9IHR5cGUud3JpdGUoYXJndW1lbnRzLCBjb250ZXh0KTtcbiAgICAgICAgdmFyIGNvbnRleHQgPSB0aGlzLmNvbnRleHQ7XG4gICAgICAgIHBhY2tldC50byA9IHRoaXMuaWQ7XG4gICAgICAgIHJldHVybiBjbGllbnQucmVxdWVzdChwYWNrZXQpLnRoZW4oZnVuY3Rpb24ocGFja2V0KSB7XG4gICAgICAgICAgcmV0dXJuIHR5cGUucmVhZChwYWNrZXQsIGNvbnRleHQpO1xuICAgICAgICB9KTtcbiAgICAgIH07XG4gICAgfTtcblxuICAgIHZhciBFdmVudCA9IENsYXNzKHtcbiAgICAgIGNvbnN0cnVjdG9yOiBmdW5jdGlvbihuYW1lLCBkZXNjcmlwdG9yKSB7XG4gICAgICAgIHRoaXMubmFtZSA9IGRlc2NyaXB0b3IudHlwZSB8fCBuYW1lO1xuICAgICAgICB0aGlzLmV2ZW50VHlwZSA9IGRlc2NyaXB0b3IudHlwZSB8fCBuYW1lO1xuICAgICAgICB0aGlzLnR5cGVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcblxuICAgICAgICB2YXIgdHlwZXMgPSB0aGlzLnR5cGVzO1xuICAgICAgICBmb3IgKHZhciBrZXkgaW4gZGVzY3JpcHRvcikge1xuICAgICAgICAgIGlmIChrZXkgPT09IFwidHlwZVwiKSB7XG4gICAgICAgICAgICB0eXBlc1trZXldID0gXCJzdHJpbmdcIjtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdHlwZXNba2V5XSA9IGRlc2NyaXB0b3Jba2V5XS50eXBlO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSxcbiAgICAgIHJlYWQ6IGZ1bmN0aW9uKGlucHV0LCBjb250ZXh0KSB7XG4gICAgICAgIHZhciBvdXRwdXQgPSB7fTtcbiAgICAgICAgdmFyIHR5cGVzID0gdGhpcy50eXBlcztcbiAgICAgICAgZm9yICh2YXIga2V5IGluIGlucHV0KSB7XG4gICAgICAgICAgb3V0cHV0W2tleV0gPSByZWFkKGlucHV0W2tleV0sIGNvbnRleHQsIHR5cGVzW2tleV0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBvdXRwdXQ7XG4gICAgICB9LFxuICAgICAgd3JpdGU6IGZ1bmN0aW9uKGlucHV0LCBjb250ZXh0KSB7XG4gICAgICAgIHZhciBvdXRwdXQgPSB7fTtcbiAgICAgICAgdmFyIHR5cGVzID0gdGhpcy50eXBlcztcbiAgICAgICAgZm9yICh2YXIga2V5IGluIHRoaXMudHlwZXMpIHtcbiAgICAgICAgICBvdXRwdXRba2V5XSA9IHdyaXRlKGlucHV0W2tleV0sIGNvbnRleHQsIHR5cGVzW2tleV0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBvdXRwdXQ7XG4gICAgICB9XG4gICAgfSk7XG5cbiAgICB2YXIgRnJvbnQgPSBDbGFzcyh7XG4gICAgICBleHRlbmRzOiBFdmVudFRhcmdldCxcbiAgICAgIEV2ZW50VGFyZ2V0OiBFdmVudFRhcmdldCxcbiAgICAgIGNvbnN0cnVjdG9yOiBmdW5jdGlvbihzdGF0ZSkge1xuICAgICAgICB0aGlzLkV2ZW50VGFyZ2V0KCk7XG4gICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0aWVzKHRoaXMsICB7XG4gICAgICAgICAgc3RhdGU6IHtcbiAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLFxuICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsXG4gICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICB2YWx1ZTogc3RhdGVcbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGNsaWVudC5yZWdpc3Rlcih0aGlzKTtcbiAgICAgIH0sXG4gICAgICBnZXQgaWQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnN0YXRlLmFjdG9yO1xuICAgICAgfSxcbiAgICAgIGdldCBjb250ZXh0KCkge1xuICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgIH0sXG4gICAgICBmb3JtOiBmdW5jdGlvbihzdGF0ZSwgZGV0YWlsLCBjb250ZXh0KSB7XG4gICAgICAgIGlmICh0aGlzLnN0YXRlICE9PSBzdGF0ZSkge1xuICAgICAgICAgIGlmIChkZXRhaWwpIHtcbiAgICAgICAgICAgIHRoaXMuc3RhdGVbZGV0YWlsXSA9IHN0YXRlW2RldGFpbF07XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhaXJzKHN0YXRlKS5mb3JFYWNoKGZ1bmN0aW9uKHBhaXIpIHtcbiAgICAgICAgICAgICAgdmFyIGtleSA9IHBhaXJbMF0sIHZhbHVlID0gcGFpclsxXTtcbiAgICAgICAgICAgICAgdGhpcy5zdGF0ZVtrZXldID0gdmFsdWU7XG4gICAgICAgICAgICB9LCB0aGlzKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY29udGV4dCkge1xuICAgICAgICAgIGNsaWVudC5zdXBlcnZpc2UoY29udGV4dCwgdGhpcyk7XG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgICByZXF1ZXN0VHlwZXM6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gY2xpZW50LnJlcXVlc3Qoe1xuICAgICAgICAgIHRvOiB0aGlzLmlkLFxuICAgICAgICAgIHR5cGU6IFwicmVxdWVzdFR5cGVzXCJcbiAgICAgICAgfSkudGhlbihmdW5jdGlvbihwYWNrZXQpIHtcbiAgICAgICAgICByZXR1cm4gcGFja2V0LnJlcXVlc3RUeXBlcztcbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgfSk7XG4gICAgdHlwZXMucHJpbWl0aXZlID0gbmV3IFByaW1pdHZlKFwicHJpbWl0aXZlXCIpO1xuICAgIHR5cGVzLnN0cmluZyA9IG5ldyBQcmltaXR2ZShcInN0cmluZ1wiKTtcbiAgICB0eXBlcy5udW1iZXIgPSBuZXcgUHJpbWl0dmUoXCJudW1iZXJcIik7XG4gICAgdHlwZXMuYm9vbGVhbiA9IG5ldyBQcmltaXR2ZShcImJvb2xlYW5cIik7XG4gICAgdHlwZXMuanNvbiA9IG5ldyBQcmltaXR2ZShcImpzb25cIik7XG4gICAgdHlwZXMuYXJyYXkgPSBuZXcgUHJpbWl0dmUoXCJhcnJheVwiKTtcbiAgfSxcbiAgcmVnaXN0ZXJUeXBlczogZnVuY3Rpb24oZGVzY3JpcHRvcikge1xuICAgIHZhciBzcGVjaWZpY2F0aW9uID0gdGhpcy5zcGVjaWZpY2F0aW9uO1xuICAgIHZhbHVlcyhkZXNjcmlwdG9yLnR5cGVzKS5mb3JFYWNoKGZ1bmN0aW9uKGRlc2NyaXB0b3IpIHtcbiAgICAgIHNwZWNpZmljYXRpb25bZGVzY3JpcHRvci50eXBlTmFtZV0gPSBkZXNjcmlwdG9yO1xuICAgIH0pO1xuICB9XG59KTtcbmV4cG9ydHMuVHlwZVN5c3RlbSA9IFR5cGVTeXN0ZW07XG4iLCJcInVzZSBzdHJpY3RcIjtcblxudmFyIGtleXMgPSBPYmplY3Qua2V5cztcbmV4cG9ydHMua2V5cyA9IGtleXM7XG5cbi8vIFJldHVybnMgYXJyYXkgb2YgdmFsdWVzIGZvciB0aGUgZ2l2ZW4gb2JqZWN0LlxudmFyIHZhbHVlcyA9IGZ1bmN0aW9uKG9iamVjdCkge1xuICByZXR1cm4ga2V5cyhvYmplY3QpLm1hcChmdW5jdGlvbihrZXkpIHtcbiAgICByZXR1cm4gb2JqZWN0W2tleV1cbiAgfSk7XG59O1xuZXhwb3J0cy52YWx1ZXMgPSB2YWx1ZXM7XG5cbi8vIFJldHVybnMgW2tleSwgdmFsdWVdIHBhaXJzIGZvciB0aGUgZ2l2ZW4gb2JqZWN0LlxudmFyIHBhaXJzID0gZnVuY3Rpb24ob2JqZWN0KSB7XG4gIHJldHVybiBrZXlzKG9iamVjdCkubWFwKGZ1bmN0aW9uKGtleSkge1xuICAgIHJldHVybiBba2V5LCBvYmplY3Rba2V5XV1cbiAgfSk7XG59O1xuZXhwb3J0cy5wYWlycyA9IHBhaXJzO1xuXG5cbi8vIFF1ZXJpZXMgYW4gb2JqZWN0IGZvciB0aGUgZmllbGQgbmVzdGVkIHdpdGggaW4gaXQuXG52YXIgcXVlcnkgPSBmdW5jdGlvbihvYmplY3QsIHBhdGgpIHtcbiAgcmV0dXJuIHBhdGgucmVkdWNlKGZ1bmN0aW9uKG9iamVjdCwgZW50cnkpIHtcbiAgICByZXR1cm4gb2JqZWN0ICYmIG9iamVjdFtlbnRyeV1cbiAgfSwgb2JqZWN0KTtcbn07XG5leHBvcnRzLnF1ZXJ5ID0gcXVlcnk7XG5cbnZhciBpc09iamVjdCA9IGZ1bmN0aW9uKHgpIHtcbiAgcmV0dXJuIHggJiYgdHlwZW9mKHgpID09PSBcIm9iamVjdFwiXG59XG5cbnZhciBmaW5kUGF0aCA9IGZ1bmN0aW9uKG9iamVjdCwga2V5KSB7XG4gIHZhciBwYXRoID0gdm9pZCgwKTtcbiAgaWYgKG9iamVjdCAmJiB0eXBlb2Yob2JqZWN0KSA9PT0gXCJvYmplY3RcIikge1xuICAgIHZhciBuYW1lcyA9IGtleXMob2JqZWN0KTtcbiAgICBpZiAobmFtZXMuaW5kZXhPZihrZXkpID49IDApIHtcbiAgICAgIHBhdGggPSBbXTtcbiAgICB9IGVsc2Uge1xuICAgICAgdmFyIGluZGV4ID0gMDtcbiAgICAgIHZhciBjb3VudCA9IG5hbWVzLmxlbmd0aDtcbiAgICAgIHdoaWxlIChpbmRleCA8IGNvdW50ICYmICFwYXRoKXtcbiAgICAgICAgdmFyIGhlYWQgPSBuYW1lc1tpbmRleF07XG4gICAgICAgIHZhciB0YWlsID0gZmluZFBhdGgob2JqZWN0W2hlYWRdLCBrZXkpO1xuICAgICAgICBwYXRoID0gdGFpbCA/IFtoZWFkXS5jb25jYXQodGFpbCkgOiB0YWlsO1xuICAgICAgICBpbmRleCA9IGluZGV4ICsgMVxuICAgICAgfVxuICAgIH1cbiAgfVxuICByZXR1cm4gcGF0aDtcbn07XG5leHBvcnRzLmZpbmRQYXRoID0gZmluZFBhdGg7XG4iXX0=
+(1)
+});
diff --git a/toolkit/jetpack/diffpatcher/.travis.yml b/toolkit/jetpack/diffpatcher/.travis.yml
new file mode 100644
index 000000000..780731a47
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - 0.4
+ - 0.5
+ - 0.6
diff --git a/toolkit/jetpack/diffpatcher/History.md b/toolkit/jetpack/diffpatcher/History.md
new file mode 100644
index 000000000..d38978805
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/History.md
@@ -0,0 +1,14 @@
+# Changes
+
+## 1.0.1 / 2013-05-01
+
+ - Update method library version.
+
+## 1.0.0 / 2012-11-09
+
+ - Test integration for browsers.
+ - New method library.
+
+## 0.0.1 / 2012-10-22
+
+ - Initial release
diff --git a/toolkit/jetpack/diffpatcher/License.md b/toolkit/jetpack/diffpatcher/License.md
new file mode 100644
index 000000000..ed76489a3
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/License.md
@@ -0,0 +1,18 @@
+Copyright 2012 Irakli Gozalishvili. All rights reserved.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
diff --git a/toolkit/jetpack/diffpatcher/Readme.md b/toolkit/jetpack/diffpatcher/Readme.md
new file mode 100644
index 000000000..1520b1c37
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/Readme.md
@@ -0,0 +1,70 @@
+# diffpatcher
+
+[![Build Status](https://secure.travis-ci.org/Gozala/diffpatcher.png)](http://travis-ci.org/Gozala/diffpatcher)
+
+[![Browser support](https://ci.testling.com/Gozala/diffpatcher.png)](http://ci.testling.com/Gozala/diffpatcher)
+
+Diffpatcher is a small library that lets you treat hashes as if they were
+git repositories.
+
+## diff
+
+Diff function that takes two hashes and returns delta hash.
+
+```js
+var diff = require("diffpatcher/diff")
+
+diff({ a: { b: 1 }, c: { d: 2 } }, // hash#1
+ { a: { e: 3 }, c: { d: 4 } }) // hash#2
+
+// => { // delta
+// a: {
+// b: null, // -
+// e: 3 // +
+// },
+// c: {
+// d: 4 // ±
+// }
+// }
+```
+
+As you can see from the example above `delta` makes no real distinction between
+proprety upadate and property addition. Try to think of additions as an update
+from `undefined` to whatever it's being updated to.
+
+## patch
+
+Patch fuction takes a `hash` and a `delta` and returns a new `hash` which is
+just like orginial but with delta applied to it. Let's apply delta from the
+previous example to the first hash from the same example
+
+
+```js
+var patch = require("diffpatcher/patch")
+
+patch({ a: { b: 1 }, c: { d: 2 } }, // hash#1
+ { // delta
+ a: {
+ b: null, // -
+ e: 3 // +
+ },
+ c: {
+ d: 4 // ±
+ }
+ })
+
+// => { a: { e: 3 }, c: { d: 4 } } // hash#2
+```
+
+That's about it really, just diffing hashes and applying thes diffs on them.
+
+
+### rebase
+
+And as Linus mentioned everything in git can be expressed with `rebase`, that
+also pretty much the case for `diffpatcher`. `rebase` takes `target` hash,
+and rebases `parent` onto it with `diff` applied.
+
+## Install
+
+ npm install diffpatcher
diff --git a/toolkit/jetpack/diffpatcher/diff.js b/toolkit/jetpack/diffpatcher/diff.js
new file mode 100644
index 000000000..967c137e6
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/diff.js
@@ -0,0 +1,45 @@
+"use strict";
+
+var method = require("../method/core")
+
+// Method is designed to work with data structures representing application
+// state. Calling it with a state should return object representing `delta`
+// that has being applied to a previous state to get to a current state.
+//
+// Example
+//
+// diff(state) // => { "item-id-1": { title: "some title" } "item-id-2": null }
+var diff = method("diff@diffpatcher")
+
+// diff between `null` / `undefined` to any hash is a hash itself.
+diff.define(null, function(from, to) { return to })
+diff.define(undefined, function(from, to) { return to })
+diff.define(Object, function(from, to) {
+ return calculate(from, to || {}) || {}
+})
+
+function calculate(from, to) {
+ var diff = {}
+ var changes = 0
+ Object.keys(from).forEach(function(key) {
+ changes = changes + 1
+ if (!(key in to) && from[key] != null) diff[key] = null
+ else changes = changes - 1
+ })
+ Object.keys(to).forEach(function(key) {
+ changes = changes + 1
+ var previous = from[key]
+ var current = to[key]
+ if (previous === current) return (changes = changes - 1)
+ if (typeof(current) !== "object") return diff[key] = current
+ if (typeof(previous) !== "object") return diff[key] = current
+ var delta = calculate(previous, current)
+ if (delta) diff[key] = delta
+ else changes = changes - 1
+ })
+ return changes ? diff : null
+}
+
+diff.calculate = calculate
+
+module.exports = diff
diff --git a/toolkit/jetpack/diffpatcher/index.js b/toolkit/jetpack/diffpatcher/index.js
new file mode 100644
index 000000000..91ddba425
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/index.js
@@ -0,0 +1,5 @@
+"use strict";
+
+exports.diff = require("./diff")
+exports.patch = require("./patch")
+exports.rebase = require("./rebase")
diff --git a/toolkit/jetpack/diffpatcher/package.json b/toolkit/jetpack/diffpatcher/package.json
new file mode 100644
index 000000000..54e085d2e
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/package.json
@@ -0,0 +1,54 @@
+{
+ "name": "diffpatcher",
+ "id": "diffpatcher",
+ "version": "1.2.0",
+ "description": "Utilities for diff-ing & patch-ing hashes",
+ "keywords": [
+ "diff", "patch", "rebase", "hash", "changes", "versions"
+ ],
+ "author": "Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)",
+ "homepage": "https://github.com/Gozala/diffpatcher",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/Gozala/diffpatcher.git",
+ "web": "https://github.com/Gozala/diffpatcher"
+ },
+ "bugs": {
+ "url": "http://github.com/Gozala/diffpatcher/issues/"
+ },
+ "dependencies": {
+ "method": "~2.0.0"
+ },
+ "devDependencies": {
+ "test": "~0.x.0",
+ "phantomify": "~0.x.0",
+ "retape": "~0.x.0",
+ "tape": "~0.1.5"
+ },
+ "main": "./index.js",
+ "scripts": {
+ "test": "npm run test-node && npm run test-browser",
+ "test-browser": "node ./node_modules/phantomify/bin/cmd.js ./test/common.js",
+ "test-node": "node ./test/common.js",
+ "test-tap": "node ./test/tap.js"
+ },
+ "testling": {
+ "files": "test/tap.js",
+ "browsers": [
+ "ie/9..latest",
+ "chrome/25..latest",
+ "firefox/20..latest",
+ "safari/6..latest",
+ "opera/11.0..latest",
+ "iphone/6..latest",
+ "ipad/6..latest",
+ "android-browser/4.2..latest"
+ ]
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/Gozala/diffpatcher/License.md"
+ }
+ ]
+}
diff --git a/toolkit/jetpack/diffpatcher/patch.js b/toolkit/jetpack/diffpatcher/patch.js
new file mode 100644
index 000000000..9271e8893
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/patch.js
@@ -0,0 +1,21 @@
+"use strict";
+
+var method = require("../method/core")
+var rebase = require("./rebase")
+
+// Method is designed to work with data structures representing application
+// state. Calling it with a state and delta should return object representing
+// new state, with changes in `delta` being applied to previous.
+//
+// ## Example
+//
+// patch(state, {
+// "item-id-1": { completed: false }, // update
+// "item-id-2": null // delete
+// })
+var patch = method("patch@diffpatcher")
+patch.define(Object, function patch(hash, delta) {
+ return rebase({}, hash, delta)
+})
+
+module.exports = patch
diff --git a/toolkit/jetpack/diffpatcher/rebase.js b/toolkit/jetpack/diffpatcher/rebase.js
new file mode 100644
index 000000000..03c756fee
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/rebase.js
@@ -0,0 +1,36 @@
+"use strict";
+
+var nil = {}
+var owns = ({}).hasOwnProperty
+
+function rebase(result, parent, delta) {
+ var key, current, previous, update
+ for (key in parent) {
+ if (owns.call(parent, key)) {
+ previous = parent[key]
+ update = owns.call(delta, key) ? delta[key] : nil
+ if (previous === null) continue
+ else if (previous === void(0)) continue
+ else if (update === null) continue
+ else if (update === void(0)) continue
+ else result[key] = previous
+ }
+ }
+ for (key in delta) {
+ if (owns.call(delta, key)) {
+ update = delta[key]
+ current = owns.call(result, key) ? result[key] : nil
+ if (current === update) continue
+ else if (update === null) continue
+ else if (update === void(0)) continue
+ else if (current === nil) result[key] = update
+ else if (typeof(update) !== "object") result[key] = update
+ else if (typeof(current) !== "object") result[key] = update
+ else result[key]= rebase({}, current, update)
+ }
+ }
+
+ return result
+}
+
+module.exports = rebase
diff --git a/toolkit/jetpack/diffpatcher/test/common.js b/toolkit/jetpack/diffpatcher/test/common.js
new file mode 100644
index 000000000..dbc79013c
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/test/common.js
@@ -0,0 +1,3 @@
+"use strict";
+
+require("test").run(require("./index"))
diff --git a/toolkit/jetpack/diffpatcher/test/diff.js b/toolkit/jetpack/diffpatcher/test/diff.js
new file mode 100644
index 000000000..d1d674005
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/test/diff.js
@@ -0,0 +1,59 @@
+"use strict";
+
+var diff = require("../diff")
+
+exports["test diff from null"] = function(assert) {
+ var to = { a: 1, b: 2 }
+ assert.equal(diff(null, to), to, "diff null to x returns x")
+ assert.equal(diff(void(0), to), to, "diff undefined to x returns x")
+
+}
+
+exports["test diff to null"] = function(assert) {
+ var from = { a: 1, b: 2 }
+ assert.deepEqual(diff({ a: 1, b: 2 }, null),
+ { a: null, b: null },
+ "diff x null returns x with all properties nullified")
+}
+
+exports["test diff identical"] = function(assert) {
+ assert.deepEqual(diff({}, {}), {}, "diff on empty objects is {}")
+
+ assert.deepEqual(diff({ a: 1, b: 2 }, { a: 1, b: 2 }), {},
+ "if properties match diff is {}")
+
+ assert.deepEqual(diff({ a: 1, b: { c: { d: 3, e: 4 } } },
+ { a: 1, b: { c: { d: 3, e: 4 } } }), {},
+ "diff between identical nested hashes is {}")
+
+}
+
+exports["test diff delete"] = function(assert) {
+ assert.deepEqual(diff({ a: 1, b: 2 }, { b: 2 }), { a: null },
+ "missing property is deleted")
+ assert.deepEqual(diff({ a: 1, b: 2 }, { a: 2 }), { a: 2, b: null },
+ "missing property is deleted another updated")
+ assert.deepEqual(diff({ a: 1, b: 2 }, {}), { a: null, b: null },
+ "missing propertes are deleted")
+ assert.deepEqual(diff({ a: 1, b: { c: { d: 2 } } }, {}),
+ { a: null, b: null },
+ "missing deep propertes are deleted")
+ assert.deepEqual(diff({ a: 1, b: { c: { d: 2 } } }, { b: { c: {} } }),
+ { a: null, b: { c: { d: null } } },
+ "missing nested propertes are deleted")
+}
+
+exports["test add update"] = function(assert) {
+ assert.deepEqual(diff({ a: 1, b: 2 }, { b: 2, c: 3 }), { a: null, c: 3 },
+ "delete and add")
+ assert.deepEqual(diff({ a: 1, b: 2 }, { a: 2, c: 3 }), { a: 2, b: null, c: 3 },
+ "delete and adds")
+ assert.deepEqual(diff({}, { a: 1, b: 2 }), { a: 1, b: 2 },
+ "diff on empty objcet returns equivalen of to")
+ assert.deepEqual(diff({ a: 1, b: { c: { d: 2 } } }, { d: 3 }),
+ { a: null, b: null, d: 3 },
+ "missing deep propertes are deleted")
+ assert.deepEqual(diff({ b: { c: {} }, d: null }, { a: 1, b: { c: { d: 2 } } }),
+ { a: 1, b: { c: { d: 2 } } },
+ "missing nested propertes are deleted")
+}
diff --git a/toolkit/jetpack/diffpatcher/test/index.js b/toolkit/jetpack/diffpatcher/test/index.js
new file mode 100644
index 000000000..c06407e7c
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/test/index.js
@@ -0,0 +1,14 @@
+"use strict";
+
+var diff = require("../diff")
+var patch = require("../patch")
+
+exports["test diff"] = require("./diff")
+exports["test patch"] = require("./patch")
+
+exports["test patch(a, diff(a, b)) => b"] = function(assert) {
+ var a = { a: { b: 1 }, c: { d: 2 } }
+ var b = { a: { e: 3 }, c: { d: 4 } }
+
+ assert.deepEqual(patch(a, diff(a, b)), b, "patch(a, diff(a, b)) => b")
+}
diff --git a/toolkit/jetpack/diffpatcher/test/patch.js b/toolkit/jetpack/diffpatcher/test/patch.js
new file mode 100644
index 000000000..dc2e38229
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/test/patch.js
@@ -0,0 +1,83 @@
+"use strict";
+
+var patch = require("../patch")
+
+exports["test patch delete"] = function(assert) {
+ var hash = { a: 1, b: 2 }
+
+ assert.deepEqual(patch(hash, { a: null }), { b: 2 }, "null removes property")
+}
+
+exports["test patch delete with void"] = function(assert) {
+ var hash = { a: 1, b: 2 }
+
+ assert.deepEqual(patch(hash, { a: void(0) }), { b: 2 },
+ "void(0) removes property")
+}
+
+exports["test patch delete missing"] = function(assert) {
+ assert.deepEqual(patch({ a: 1, b: 2 }, { c: null }),
+ { a: 1, b: 2 },
+ "null removes property if exists");
+
+ assert.deepEqual(patch({ a: 1, b: 2 }, { c: void(0) }),
+ { a: 1, b: 2 },
+ "void removes property if exists");
+}
+
+exports["test delete deleted"] = function(assert) {
+ assert.deepEqual(patch({ a: null, b: 2, c: 3, d: void(0)},
+ { a: void(0), b: null, d: null }),
+ {c: 3},
+ "removed all existing and non existing");
+}
+
+exports["test update deleted"] = function(assert) {
+ assert.deepEqual(patch({ a: null, b: void(0), c: 3},
+ { a: { b: 2 } }),
+ { a: { b: 2 }, c: 3 },
+ "replace deleted");
+}
+
+exports["test patch delete with void"] = function(assert) {
+ var hash = { a: 1, b: 2 }
+
+ assert.deepEqual(patch(hash, { a: void(0) }), { b: 2 },
+ "void(0) removes property")
+}
+
+
+exports["test patch addition"] = function(assert) {
+ var hash = { a: 1, b: 2 }
+
+ assert.deepEqual(patch(hash, { c: 3 }), { a: 1, b: 2, c: 3 },
+ "new properties are added")
+}
+
+exports["test patch addition"] = function(assert) {
+ var hash = { a: 1, b: 2 }
+
+ assert.deepEqual(patch(hash, { c: 3 }), { a: 1, b: 2, c: 3 },
+ "new properties are added")
+}
+
+exports["test hash on itself"] = function(assert) {
+ var hash = { a: 1, b: 2 }
+
+ assert.deepEqual(patch(hash, hash), hash,
+ "applying hash to itself returns hash itself")
+}
+
+exports["test patch with empty delta"] = function(assert) {
+ var hash = { a: 1, b: 2 }
+
+ assert.deepEqual(patch(hash, {}), hash,
+ "applying empty delta results in no changes")
+}
+
+exports["test patch nested data"] = function(assert) {
+ assert.deepEqual(patch({ a: { b: 1 }, c: { d: 2 } },
+ { a: { b: null, e: 3 }, c: { d: 4 } }),
+ { a: { e: 3 }, c: { d: 4 } },
+ "nested structures can also be patched")
+}
diff --git a/toolkit/jetpack/diffpatcher/test/tap.js b/toolkit/jetpack/diffpatcher/test/tap.js
new file mode 100644
index 000000000..e550b82f5
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/test/tap.js
@@ -0,0 +1,3 @@
+"use strict";
+
+require("retape")(require("./index"))
diff --git a/toolkit/jetpack/framescript/FrameScriptManager.jsm b/toolkit/jetpack/framescript/FrameScriptManager.jsm
new file mode 100644
index 000000000..1ce6ceb07
--- /dev/null
+++ b/toolkit/jetpack/framescript/FrameScriptManager.jsm
@@ -0,0 +1,27 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const globalMM = Components.classes["@mozilla.org/globalmessagemanager;1"].
+ getService(Components.interfaces.nsIMessageListenerManager);
+
+// Load frame scripts from the same dir as this module.
+// Since this JSM will be loaded using require(), PATH will be
+// overridden while running tests, just like any other module.
+const PATH = __URI__.replace('framescript/FrameScriptManager.jsm', '');
+
+// Builds a unique loader ID for this runtime. We prefix with the SDK path so
+// overriden versions of the SDK don't conflict
+var LOADER_ID = 0;
+this.getNewLoaderID = () => {
+ return PATH + ":" + LOADER_ID++;
+}
+
+const frame_script = function(contentFrame, PATH) {
+ let { registerContentFrame } = Components.utils.import(PATH + 'framescript/content.jsm', {});
+ registerContentFrame(contentFrame);
+}
+globalMM.loadFrameScript("data:,(" + frame_script.toString() + ")(this, " + JSON.stringify(PATH) + ");", true);
+
+this.EXPORTED_SYMBOLS = ['getNewLoaderID'];
diff --git a/toolkit/jetpack/framescript/content.jsm b/toolkit/jetpack/framescript/content.jsm
new file mode 100644
index 000000000..eaee26be3
--- /dev/null
+++ b/toolkit/jetpack/framescript/content.jsm
@@ -0,0 +1,94 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { utils: Cu, classes: Cc, interfaces: Ci } = Components;
+const { Services } = Cu.import('resource://gre/modules/Services.jsm');
+
+const cpmm = Cc['@mozilla.org/childprocessmessagemanager;1'].
+ getService(Ci.nsISyncMessageSender);
+
+this.EXPORTED_SYMBOLS = ["registerContentFrame"];
+
+// This may be an overriden version of the SDK so use the PATH as a key for the
+// initial messages before we have a loaderID.
+const PATH = __URI__.replace('framescript/content.jsm', '');
+
+const { Loader } = Cu.import(PATH + 'toolkit/loader.js', {});
+
+// one Loader instance per addon (per @loader/options to be precise)
+var addons = new Map();
+
+// Tell the parent that a new process is ready
+cpmm.sendAsyncMessage('sdk/remote/process/start', {
+ modulePath: PATH
+});
+
+// Load a child process module loader with the given loader options
+cpmm.addMessageListener('sdk/remote/process/load', ({ data: { modulePath, loaderID, options, reason } }) => {
+ if (modulePath != PATH)
+ return;
+
+ // During startup races can mean we get a second load message
+ if (addons.has(loaderID))
+ return;
+
+ options.waiveInterposition = true;
+
+ let loader = Loader.Loader(options);
+ let addon = {
+ loader,
+ require: Loader.Require(loader, { id: 'LoaderHelper' }),
+ }
+ addons.set(loaderID, addon);
+
+ cpmm.sendAsyncMessage('sdk/remote/process/attach', {
+ loaderID,
+ processID: Services.appinfo.processID,
+ isRemote: Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
+ });
+
+ addon.child = addon.require('sdk/remote/child');
+
+ for (let contentFrame of frames.values())
+ addon.child.registerContentFrame(contentFrame);
+});
+
+// Unload a child process loader
+cpmm.addMessageListener('sdk/remote/process/unload', ({ data: { loaderID, reason } }) => {
+ if (!addons.has(loaderID))
+ return;
+
+ let addon = addons.get(loaderID);
+ Loader.unload(addon.loader, reason);
+
+ // We want to drop the reference to the loader but never allow creating a new
+ // loader with the same ID
+ addons.set(loaderID, {});
+})
+
+
+var frames = new Set();
+
+this.registerContentFrame = contentFrame => {
+ contentFrame.addEventListener("unload", () => {
+ unregisterContentFrame(contentFrame);
+ }, false);
+
+ frames.add(contentFrame);
+
+ for (let addon of addons.values()) {
+ if ("child" in addon)
+ addon.child.registerContentFrame(contentFrame);
+ }
+};
+
+function unregisterContentFrame(contentFrame) {
+ frames.delete(contentFrame);
+
+ for (let addon of addons.values()) {
+ if ("child" in addon)
+ addon.child.unregisterContentFrame(contentFrame);
+ }
+}
diff --git a/toolkit/jetpack/framescript/context-menu.js b/toolkit/jetpack/framescript/context-menu.js
new file mode 100644
index 000000000..3915b7cd8
--- /dev/null
+++ b/toolkit/jetpack/framescript/context-menu.js
@@ -0,0 +1,215 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { query, constant, cache } = require("sdk/lang/functional");
+const { pairs, each, map, object } = require("sdk/util/sequence");
+const { nodeToMessageManager } = require("./util");
+
+// Decorator function that takes `f` function and returns one that attempts
+// to run `f` with given arguments. In case of exception error is logged
+// and `fallback` is returned instead.
+const Try = (fn, fallback=null) => (...args) => {
+ try {
+ return fn(...args);
+ } catch(error) {
+ console.error(error);
+ return fallback;
+ }
+};
+
+// Decorator funciton that takes `f` function and returns one that returns
+// JSON cloned result of whatever `f` returns for given arguments.
+const JSONReturn = f => (...args) => JSON.parse(JSON.stringify(f(...args)));
+
+const Null = constant(null);
+
+// Table of readers mapped to field names they're going to be reading.
+const readers = Object.create(null);
+// Read function takes "contextmenu" event target `node` and returns table of
+// read field names mapped to appropriate values. Read uses above defined read
+// table to read data for all registered readers.
+const read = node =>
+ object(...map(([id, read]) => [id, read(node, id)], pairs(readers)));
+
+// Table of built-in readers, each takes a descriptor and returns a reader:
+// descriptor -> node -> JSON
+const parsers = Object.create(null)
+// Function takes a descriptor of the remotely defined reader and parsese it
+// to construct a local reader that's going to read out data from context menu
+// target.
+const parse = descriptor => {
+ const parser = parsers[descriptor.category];
+ if (!parser) {
+ console.error("Unknown reader descriptor was received", descriptor, `"${descriptor.category}"`);
+ return Null
+ }
+ return Try(parser(descriptor));
+}
+
+// TODO: Test how chrome's mediaType behaves to try and match it's behavior.
+const HTML_NS = "http://www.w3.org/1999/xhtml";
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+const SVG_NS = "http://www.w3.org/2000/svg";
+
+// Firefox always creates a HTMLVideoElement when loading an ogg file
+// directly. If the media is actually audio, be smarter and provide a
+// context menu with audio operations.
+// Source: https://github.com/mozilla/gecko-dev/blob/28c2fca3753c5371643843fc2f2f205146b083b7/browser/base/content/nsContextMenu.js#L632-L637
+const isVideoLoadingAudio = node =>
+ node.readyState >= node.HAVE_METADATA &&
+ (node.videoWidth == 0 || node.videoHeight == 0)
+
+const isVideo = node =>
+ node instanceof node.ownerDocument.defaultView.HTMLVideoElement &&
+ !isVideoLoadingAudio(node);
+
+const isAudio = node => {
+ const {HTMLVideoElement, HTMLAudioElement} = node.ownerDocument.defaultView;
+ return node instanceof HTMLAudioElement ? true :
+ node instanceof HTMLVideoElement ? isVideoLoadingAudio(node) :
+ false;
+};
+
+const isImage = ({namespaceURI, localName}) =>
+ namespaceURI === HTML_NS && localName === "img" ? true :
+ namespaceURI === XUL_NS && localName === "image" ? true :
+ namespaceURI === SVG_NS && localName === "image" ? true :
+ false;
+
+parsers["reader/MediaType()"] = constant(node =>
+ isImage(node) ? "image" :
+ isAudio(node) ? "audio" :
+ isVideo(node) ? "video" :
+ null);
+
+
+const readLink = node =>
+ node.namespaceURI === HTML_NS && node.localName === "a" ? node.href :
+ readLink(node.parentNode);
+
+parsers["reader/LinkURL()"] = constant(node =>
+ node.matches("a, a *") ? readLink(node) : null);
+
+// Reader that reads out `true` if "contextmenu" `event.target` matches
+// `descriptor.selector` and `false` if it does not.
+parsers["reader/SelectorMatch()"] = ({selector}) =>
+ node => node.matches(selector);
+
+// Accessing `selectionStart` and `selectionEnd` properties on non
+// editable input nodes throw exceptions, there for we need this util
+// function to guard us against them.
+const getInputSelection = node => {
+ try {
+ if ("selectionStart" in node && "selectionEnd" in node) {
+ const {selectionStart, selectionEnd} = node;
+ return {selectionStart, selectionEnd}
+ }
+ }
+ catch(_) {}
+
+ return null;
+}
+
+// Selection reader does not really cares about descriptor so it is
+// a constant function returning selection reader. Selection reader
+// returns string of the selected text or `null` if there is no selection.
+parsers["reader/Selection()"] = constant(node => {
+ const selection = node.ownerDocument.getSelection();
+ if (!selection.isCollapsed) {
+ return selection.toString();
+ }
+ // If target node is editable (text, input, textarea, etc..) document does
+ // not really handles selections there. There for we fallback to checking
+ // `selectionStart` `selectionEnd` properties and if they are present we
+ // extract selections manually from the `node.value`.
+ else {
+ const selection = getInputSelection(node);
+ const isSelected = selection &&
+ Number.isInteger(selection.selectionStart) &&
+ Number.isInteger(selection.selectionEnd) &&
+ selection.selectionStart !== selection.selectionEnd;
+ return isSelected ? node.value.substring(selection.selectionStart,
+ selection.selectionEnd) :
+ null;
+ }
+});
+
+// Query reader just reads out properties from the node, so we just use `query`
+// utility function.
+parsers["reader/Query()"] = ({path}) => JSONReturn(query(path));
+// Attribute reader just reads attribute of the event target node.
+parsers["reader/Attribute()"] = ({name}) => node => node.getAttribute(name);
+
+// Extractor reader defines generates a reader out of serialized function, who's
+// return value is JSON cloned. Note: We do know source will evaluate to function
+// as that's what we serialized on the other end, it's also ok if generated function
+// is going to throw as registered readers are wrapped in try catch to avoid breakting
+// unrelated readers.
+parsers["reader/Extractor()"] = ({source}) =>
+ JSONReturn(new Function("return (" + source + ")")());
+
+// If the context-menu target node or any of its ancestors is one of these,
+// Firefox uses a tailored context menu, and so the page context doesn't apply.
+// There for `reader/isPage()` will read `false` in that case otherwise it's going
+// to read `true`.
+const nonPageElements = ["a", "applet", "area", "button", "canvas", "object",
+ "embed", "img", "input", "map", "video", "audio", "menu",
+ "option", "select", "textarea", "[contenteditable=true]"];
+const nonPageSelector = nonPageElements.
+ concat(nonPageElements.map(tag => `${tag} *`)).
+ join(", ");
+
+// Note: isPageContext implementation could have actually used SelectorMatch reader,
+// but old implementation was also checked for collapsed selection there for to keep
+// the behavior same we end up implementing a new reader.
+parsers["reader/isPage()"] = constant(node =>
+ node.ownerDocument.defaultView.getSelection().isCollapsed &&
+ !node.matches(nonPageSelector));
+
+// Reads `true` if node is in an iframe otherwise returns true.
+parsers["reader/isFrame()"] = constant(node =>
+ !!node.ownerDocument.defaultView.frameElement);
+
+parsers["reader/isEditable()"] = constant(node => {
+ const selection = getInputSelection(node);
+ return selection ? !node.readOnly && !node.disabled : node.isContentEditable;
+});
+
+
+// TODO: Add some reader to read out tab id.
+
+const onReadersUpdate = message => {
+ each(([id, descriptor]) => {
+ if (descriptor) {
+ readers[id] = parse(descriptor);
+ }
+ else {
+ delete readers[id];
+ }
+ }, pairs(message.data));
+};
+exports.onReadersUpdate = onReadersUpdate;
+
+
+const onContextMenu = event => {
+ if (!event.defaultPrevented) {
+ const manager = nodeToMessageManager(event.target);
+ manager.sendSyncMessage("sdk/context-menu/read", read(event.target), readers);
+ }
+};
+exports.onContextMenu = onContextMenu;
+
+
+const onContentFrame = (frame) => {
+ // Listen for contextmenu events in on this frame.
+ frame.addEventListener("contextmenu", onContextMenu);
+ // Listen to registered reader changes and update registry.
+ frame.addMessageListener("sdk/context-menu/readers", onReadersUpdate);
+
+ // Request table of readers (if this is loaded in a new process some table
+ // changes may be missed, this is way to sync up).
+ frame.sendAsyncMessage("sdk/context-menu/readers?");
+};
+exports.onContentFrame = onContentFrame;
diff --git a/toolkit/jetpack/framescript/manager.js b/toolkit/jetpack/framescript/manager.js
new file mode 100644
index 000000000..1f261e1fa
--- /dev/null
+++ b/toolkit/jetpack/framescript/manager.js
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const mime = "application/javascript";
+const requireURI = module.uri.replace("framescript/manager.js",
+ "toolkit/require.js");
+
+const requireLoadURI = `data:${mime},this["Components"].utils.import("${requireURI}")`
+
+// Loads module with given `id` into given `messageManager` via shared module loader. If `init`
+// string is passed, will call module export with that name and pass frame script environment
+// of the `messageManager` into it. Since module will load only once per process (which is
+// once for chrome proces & second for content process) it is useful to have an init function
+// to setup event listeners on each content frame.
+const loadModule = (messageManager, id, allowDelayed, init) => {
+ const moduleLoadURI = `${requireLoadURI}.require("${id}")`
+ const uri = init ? `${moduleLoadURI}.${init}(this)` : moduleLoadURI;
+ messageManager.loadFrameScript(uri, allowDelayed);
+};
+exports.loadModule = loadModule;
diff --git a/toolkit/jetpack/framescript/util.js b/toolkit/jetpack/framescript/util.js
new file mode 100644
index 000000000..fb6834608
--- /dev/null
+++ b/toolkit/jetpack/framescript/util.js
@@ -0,0 +1,25 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+
+const { Ci } = require("chrome");
+
+const windowToMessageManager = window =>
+ window.
+ QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDocShell).
+ sameTypeRootTreeItem.
+ QueryInterface(Ci.nsIDocShell).
+ QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIContentFrameMessageManager);
+exports.windowToMessageManager = windowToMessageManager;
+
+const nodeToMessageManager = node =>
+ windowToMessageManager(node.ownerDocument.defaultView);
+exports.nodeToMessageManager = nodeToMessageManager;
diff --git a/toolkit/jetpack/index.js b/toolkit/jetpack/index.js
new file mode 100644
index 000000000..e0032240a
--- /dev/null
+++ b/toolkit/jetpack/index.js
@@ -0,0 +1,3 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
diff --git a/toolkit/jetpack/jetpack-id/index.js b/toolkit/jetpack/jetpack-id/index.js
new file mode 100644
index 000000000..6c1493f1d
--- /dev/null
+++ b/toolkit/jetpack/jetpack-id/index.js
@@ -0,0 +1,53 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * Takes parsed `package.json` manifest and returns
+ * valid add-on id for it.
+ */
+function getID(manifest) {
+ manifest = manifest || {};
+
+ if (manifest.id) {
+
+ if (typeof manifest.id !== "string") {
+ return null;
+ }
+
+ // If manifest.id is already valid (as domain or GUID), use it
+ if (isValidAOMName(manifest.id)) {
+ return manifest.id;
+ }
+ // Otherwise, this ID is invalid so return `null`
+ return null;
+ }
+
+ // If no `id` defined, turn `name` into a domain ID,
+ // as we transition to `name` being an id, similar to node/npm, but
+ // append a '@' to make it compatible with Firefox requirements
+ if (manifest.name) {
+
+ if (typeof manifest.name !== "string") {
+ return null;
+ }
+
+ var modifiedName = "@" + manifest.name;
+ return isValidAOMName(modifiedName) ? modifiedName : null;
+ }
+
+ // If no `id` or `name` property, return null as this manifest
+ // is invalid
+ return null;
+}
+
+module.exports = getID;
+
+/**
+ * Regex taken from XPIProvider.jsm in the Addon Manager to validate proper
+ * IDs that are able to be used.
+ * http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/internal/XPIProvider.jsm#209
+ */
+function isValidAOMName (s) {
+ return /^(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}|[a-z0-9-\._]*\@[a-z0-9-\._]+)$/i.test(s || "");
+}
diff --git a/toolkit/jetpack/jetpack-id/package.json b/toolkit/jetpack/jetpack-id/package.json
new file mode 100644
index 000000000..62a1c73ba
--- /dev/null
+++ b/toolkit/jetpack/jetpack-id/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "jetpack-id",
+ "version": "1.0.0",
+ "description": "Creates an ID from a Firefox Jetpack manifest",
+ "main": "index.js",
+ "repository": {
+ "type": "git",
+ "url": "http://github.com/jsantell/jetpack-id"
+ },
+ "author": {
+ "name": "Jordan Santell",
+ "url": "http://github.com/jsantell"
+ },
+ "license": "MPL-2.0",
+ "scripts": {
+ "test": "./node_modules/.bin/mocha --reporter spec --ui bdd"
+ },
+ "keywords": [
+ "jetpack",
+ "addon",
+ "mozilla",
+ "firefox"
+ ],
+ "devDependencies": {
+ "mocha": "*",
+ "chai": "*"
+ }
+}
diff --git a/toolkit/jetpack/method/.travis.yml b/toolkit/jetpack/method/.travis.yml
new file mode 100644
index 000000000..780731a47
--- /dev/null
+++ b/toolkit/jetpack/method/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - 0.4
+ - 0.5
+ - 0.6
diff --git a/toolkit/jetpack/method/History.md b/toolkit/jetpack/method/History.md
new file mode 100644
index 000000000..95258c45f
--- /dev/null
+++ b/toolkit/jetpack/method/History.md
@@ -0,0 +1,55 @@
+# Changes
+
+## 1.0.2 / 2012-12-26
+
+ - Delegate to polymorphic methods from `.define` and `.implement` so, they
+ can be overidden.
+
+## 1.0.1 / 2012-11-11
+
+ - Fix issues with different `Error` types as they all inherit from
+ `Error`.
+
+## 1.0.0 / 2012-11-09
+
+ - Add browser test integration.
+ - Fix cross-browser incompatibilities & test failures.
+ - Add support for host objects.
+ - Add optional `hint` argument for method to ease debugging.
+ - Remove default implementation at definition time.
+
+## 0.1.1 / 2012-10-15
+
+ - Fix regression causing custom type implementation to be stored on objects.
+
+## 0.1.0 / 2012-10-15
+
+ - Remove dependency on name module.
+ - Implement fallback for engines that do not support ES5.
+ - Add support for built-in type extensions without extending their prototypes.
+ - Make API for default definitions more intuitive.
+ Skipping type argument now defines default:
+
+ isFoo.define(function(value) {
+ return false
+ })
+
+ - Make exposed `define` and `implement` polymorphic.
+ - Removed dev dependency on swank-js.
+ - Primitive types `string, number, boolean` no longer inherit method
+ implementations from `Object`.
+
+## 0.0.3 / 2012-07-17
+
+ - Remove module boilerplate
+
+## 0.0.2 / 2012-06-26
+
+ - Name changes to make it less conflicting with other library conventions.
+ - Expose function version of `define` & `implement` methods.
+ - Expose `Null` and `Undefined` object holding implementations for an
+ associated types.
+
+## 0.0.1 / 2012-06-25
+
+ - Initial release
diff --git a/toolkit/jetpack/method/License.md b/toolkit/jetpack/method/License.md
new file mode 100644
index 000000000..ed76489a3
--- /dev/null
+++ b/toolkit/jetpack/method/License.md
@@ -0,0 +1,18 @@
+Copyright 2012 Irakli Gozalishvili. All rights reserved.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
diff --git a/toolkit/jetpack/method/Readme.md b/toolkit/jetpack/method/Readme.md
new file mode 100644
index 000000000..9584c9160
--- /dev/null
+++ b/toolkit/jetpack/method/Readme.md
@@ -0,0 +1,117 @@
+# method
+
+[![Build Status](https://secure.travis-ci.org/Gozala/method.png)](http://travis-ci.org/Gozala/method)
+
+Library provides an API for defining polymorphic methods that dispatch on the
+first argument type. This provides a powerful way for decouple abstraction
+interface definition from an actual implementation per type, without risks
+of interference with other libraries.
+
+### Motivation
+
+ - Provide a high-performance, dynamic polymorphism construct as an
+ alternative to existing object methods that does not provides any
+ mechanics for guarding against name conflicts.
+ - Allow independent extension of types, and implementations of methods
+ on types, by different parties.
+
+## Install
+
+ npm install method
+
+## Use
+
+```js
+var method = require("method")
+
+// Define `isWatchable` method that can be implemented for any type.
+var isWatchable = method("isWatchable")
+
+// If you call it on any object it will
+// throw as nothing implements that method yet.
+//isWatchable({}) // => Exception: method is not implemented
+
+// If you define private method on `Object.prototype`
+// all objects will inherit it.
+Object.prototype[isWatchable] = function() {
+ return false;
+}
+
+isWatchable({}) // => false
+
+
+// Although `isWatchable` property above will be enumerable and there for
+// may damage some assumbtions made by other libraries. There for it"s
+// recomended to use built-in helpers methods that will define extension
+// without breaking assumbtions made by other libraries:
+
+isWatchable.define(Object, function() { return false })
+
+
+// There are primitive types in JS that won"t inherit methods from Object:
+isWatchable(null) // => Exception: method is not implemented
+
+// One could either implement methods for such types:
+isWatchable.define(null, function() { return false })
+isWatchable.define(undefined, function() { return false })
+
+// Or simply define default implementation:
+isWatchable.define(function() { return false })
+
+// Alternatively default implementation may be provided at creation:
+isWatchable = method(function() { return false })
+
+// Method dispatches on an first argument type. That allows us to create
+// new types with an alternative implementations:
+function Watchable() {}
+isWatchable.define(Watchable, function() { return true })
+
+// This will make all `Watchable` instances watchable!
+isWatchable(new Watchable()) // => true
+
+// Arbitrary objects can also be extended to implement given method. For example
+// any object can simply made watchable:
+function watchable(object) {
+ return isWatchable.implement(objct, function() { return true })
+}
+
+isWatchable(watchable({})) // => true
+
+// Full protocols can be defined with such methods:
+var observers = "observers@" + module.filename
+var watchers = method("watchers")
+var watch = method("watch")
+var unwatch = method("unwatch")
+
+watchers.define(Watchable, function(target) {
+ return target[observers] || (target[observers] = [])
+})
+
+watch.define(Watchable, function(target, watcher) {
+ var observers = watchers(target)
+ if (observers.indexOf(watcher) < 0) observers.push(watcher)
+ return target
+})
+unwatch.define(Watchable, function(target, watcher) {
+ var observers = watchers(target)
+ var index = observers.indexOf(watcher)
+ if (observers.indexOf(watcher) >= 0) observers.unshift(watcher)
+ return target
+})
+
+// Define type Port that inherits form Watchable
+
+function Port() {}
+Port.prototype = Object.create(Watchable.prototype)
+
+var emit = method("emit")
+emit.define(Port, function(port, message) {
+ watchers(port).slice().forEach(function(watcher) {
+ watcher(message)
+ })
+})
+
+var p = new Port()
+watch(p, console.log)
+emit(p, "hello world") // => info: "hello world"
+```
diff --git a/toolkit/jetpack/method/core.js b/toolkit/jetpack/method/core.js
new file mode 100644
index 000000000..a6a5261e6
--- /dev/null
+++ b/toolkit/jetpack/method/core.js
@@ -0,0 +1,225 @@
+"use strict";
+
+var defineProperty = Object.defineProperty || function(object, name, property) {
+ object[name] = property.value
+ return object
+}
+
+// Shortcut for `Object.prototype.toString` for faster access.
+var typefy = Object.prototype.toString
+
+// Map to for jumping from typeof(value) to associated type prefix used
+// as a hash in the map of builtin implementations.
+var types = { "function": "Object", "object": "Object" }
+
+// Array is used to save method implementations for the host objects in order
+// to avoid extending them with non-primitive values that could cause leaks.
+var host = []
+// Hash map is used to save method implementations for builtin types in order
+// to avoid extending their prototypes. This also allows to share method
+// implementations for types across diff contexts / frames / compartments.
+var builtin = {}
+
+function Primitive() {}
+function ObjectType() {}
+ObjectType.prototype = new Primitive()
+function ErrorType() {}
+ErrorType.prototype = new ObjectType()
+
+var Default = builtin.Default = Primitive.prototype
+var Null = builtin.Null = new Primitive()
+var Void = builtin.Void = new Primitive()
+builtin.String = new Primitive()
+builtin.Number = new Primitive()
+builtin.Boolean = new Primitive()
+
+builtin.Object = ObjectType.prototype
+builtin.Error = ErrorType.prototype
+
+builtin.EvalError = new ErrorType()
+builtin.InternalError = new ErrorType()
+builtin.RangeError = new ErrorType()
+builtin.ReferenceError = new ErrorType()
+builtin.StopIteration = new ErrorType()
+builtin.SyntaxError = new ErrorType()
+builtin.TypeError = new ErrorType()
+builtin.URIError = new ErrorType()
+
+
+function Method(hint) {
+ /**
+ Private Method is a callable private name that dispatches on the first
+ arguments same named Method:
+
+ method(object, ...rest) => object[method](...rest)
+
+ Optionally hint string may be provided that will be used in generated names
+ to ease debugging.
+
+ ## Example
+
+ var foo = Method()
+
+ // Implementation for any types
+ foo.define(function(value, arg1, arg2) {
+ // ...
+ })
+
+ // Implementation for a specific type
+ foo.define(BarType, function(bar, arg1, arg2) {
+ // ...
+ })
+ **/
+
+ // Create an internal unique name if `hint` is provided it is used to
+ // prefix name to ease debugging.
+ var name = (hint || "") + "#" + Math.random().toString(32).substr(2)
+
+ function dispatch(value) {
+ // Method dispatches on type of the first argument.
+ // If first argument is `null` or `void` associated implementation is
+ // looked up in the `builtin` hash where implementations for built-ins
+ // are stored.
+ var type = null
+ var method = value === null ? Null[name] :
+ value === void(0) ? Void[name] :
+ // Otherwise attempt to use method with a generated private
+ // `name` that is supposedly in the prototype chain of the
+ // `target`.
+ value[name] ||
+ // Otherwise assume it's one of the built-in type instances,
+ // in which case implementation is stored in a `builtin` hash.
+ // Attempt to find a implementation for the given built-in
+ // via constructor name and method name.
+ ((type = builtin[(value.constructor || "").name]) &&
+ type[name]) ||
+ // Otherwise assume it's a host object. For host objects
+ // actual method implementations are stored in the `host`
+ // array and only index for the implementation is stored
+ // in the host object's prototype chain. This avoids memory
+ // leaks that otherwise could happen when saving JS objects
+ // on host object.
+ host[value["!" + name] || void(0)] ||
+ // Otherwise attempt to lookup implementation for builtins by
+ // a type of the value. This basically makes sure that all
+ // non primitive values will delegate to an `Object`.
+ ((type = builtin[types[typeof(value)]]) && type[name])
+
+
+ // If method implementation for the type is still not found then
+ // just fallback for default implementation.
+ method = method || Default[name]
+
+
+ // If implementation is still not found (which also means there is no
+ // default) just throw an error with a descriptive message.
+ if (!method) throw TypeError("Type does not implements method: " + name)
+
+ // If implementation was found then just delegate.
+ return method.apply(method, arguments)
+ }
+
+ // Make `toString` of the dispatch return a private name, this enables
+ // method definition without sugar:
+ //
+ // var method = Method()
+ // object[method] = function() { /***/ }
+ dispatch.toString = function toString() { return name }
+
+ // Copy utility methods for convenient API.
+ dispatch.implement = implementMethod
+ dispatch.define = defineMethod
+
+ return dispatch
+}
+
+// Create method shortcuts form functions.
+var defineMethod = function defineMethod(Type, lambda) {
+ return define(this, Type, lambda)
+}
+var implementMethod = function implementMethod(object, lambda) {
+ return implement(this, object, lambda)
+}
+
+// Define `implement` and `define` polymorphic methods to allow definitions
+// and implementations through them.
+var implement = Method("implement")
+var define = Method("define")
+
+
+function _implement(method, object, lambda) {
+ /**
+ Implements `Method` for the given `object` with a provided `implementation`.
+ Calling `Method` with `object` as a first argument will dispatch on provided
+ implementation.
+ **/
+ return defineProperty(object, method.toString(), {
+ enumerable: false,
+ configurable: false,
+ writable: false,
+ value: lambda
+ })
+}
+
+function _define(method, Type, lambda) {
+ /**
+ Defines `Method` for the given `Type` with a provided `implementation`.
+ Calling `Method` with a first argument of this `Type` will dispatch on
+ provided `implementation`. If `Type` is a `Method` default implementation
+ is defined. If `Type` is a `null` or `undefined` `Method` is implemented
+ for that value type.
+ **/
+
+ // Attempt to guess a type via `Object.prototype.toString.call` hack.
+ var type = Type && typefy.call(Type.prototype)
+
+ // If only two arguments are passed then `Type` is actually an implementation
+ // for a default type.
+ if (!lambda) Default[method] = Type
+ // If `Type` is `null` or `void` store implementation accordingly.
+ else if (Type === null) Null[method] = lambda
+ else if (Type === void(0)) Void[method] = lambda
+ // If `type` hack indicates built-in type and type has a name us it to
+ // store a implementation into associated hash. If hash for this type does
+ // not exists yet create one.
+ else if (type !== "[object Object]" && Type.name) {
+ var Bulitin = builtin[Type.name] || (builtin[Type.name] = new ObjectType())
+ Bulitin[method] = lambda
+ }
+ // If `type` hack indicates an object, that may be either object or any
+ // JS defined "Class". If name of the constructor is `Object`, assume it's
+ // built-in `Object` and store implementation accordingly.
+ else if (Type.name === "Object")
+ builtin.Object[method] = lambda
+ // Host objects are pain!!! Every browser does some crazy stuff for them
+ // So far all browser seem to not implement `call` method for host object
+ // constructors. If that is a case here, assume it's a host object and
+ // store implementation in a `host` array and store `index` in the array
+ // in a `Type.prototype` itself. This avoids memory leaks that could be
+ // caused by storing JS objects on a host objects.
+ else if (Type.call === void(0)) {
+ var index = host.indexOf(lambda)
+ if (index < 0) index = host.push(lambda) - 1
+ // Prefix private name with `!` so it can be dispatched from the method
+ // without type checks.
+ implement("!" + method, Type.prototype, index)
+ }
+ // If Got that far `Type` is user defined JS `Class`. Define private name
+ // as hidden property on it's prototype.
+ else
+ implement(method, Type.prototype, lambda)
+}
+
+// And provided implementations for a polymorphic equivalents.
+_define(define, _define)
+_define(implement, _implement)
+
+// Define exports on `Method` as it's only thing being exported.
+Method.implement = implement
+Method.define = define
+Method.Method = Method
+Method.method = Method
+Method.builtin = builtin
+Method.host = host
+
+module.exports = Method
diff --git a/toolkit/jetpack/method/package.json b/toolkit/jetpack/method/package.json
new file mode 100644
index 000000000..7bb004e28
--- /dev/null
+++ b/toolkit/jetpack/method/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "method",
+ "id": "method",
+ "version": "1.0.2",
+ "description": "Functional polymorphic method dispatch",
+ "keywords": [
+ "method",
+ "dispatch",
+ "protocol",
+ "polymorphism",
+ "type dispatch"
+ ],
+ "author": "Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)",
+ "homepage": "https://github.com/Gozala/method",
+ "main": "./core.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/Gozala/method.git",
+ "web": "https://github.com/Gozala/method"
+ },
+ "bugs": {
+ "url": "http://github.com/Gozala/method/issues/"
+ },
+ "devDependencies": {
+ "test": "~0.x.0",
+ "repl-utils": "~2.0.1",
+ "phantomify": "~0.1.0"
+ },
+ "scripts": {
+ "test": "npm run test-node && npm run test-browser",
+ "test-browser": "node ./node_modules/phantomify/bin/cmd.js ./test/browser.js",
+ "test-node": "node ./test/common.js",
+ "repl": "node node_modules/repl-utils"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/Gozala/method/License.md"
+ }
+ ]
+}
diff --git a/toolkit/jetpack/method/test/browser.js b/toolkit/jetpack/method/test/browser.js
new file mode 100644
index 000000000..7c8e6cd52
--- /dev/null
+++ b/toolkit/jetpack/method/test/browser.js
@@ -0,0 +1,20 @@
+"use strict";
+
+exports["test common"] = require("./common")
+
+var Method = require("../core")
+
+exports["test host objects"] = function(assert) {
+ var isElement = Method("is-element")
+ isElement.define(function() { return false })
+
+ isElement.define(Element, function() { return true })
+
+ assert.notDeepEqual(typeof(Element.prototype[isElement]), "number",
+ "Host object's prototype is extended with a number value")
+
+ assert.ok(!isElement({}), "object is not an Element")
+ assert.ok(document.createElement("div"), "Element is an element")
+}
+
+require("test").run(exports)
diff --git a/toolkit/jetpack/method/test/common.js b/toolkit/jetpack/method/test/common.js
new file mode 100644
index 000000000..0418c3a23
--- /dev/null
+++ b/toolkit/jetpack/method/test/common.js
@@ -0,0 +1,272 @@
+"use strict";
+
+var Method = require("../core")
+
+function type(value) {
+ return Object.prototype.toString.call(value).
+ split(" ").
+ pop().
+ split("]").
+ shift().
+ toLowerCase()
+}
+
+var values = [
+ null, // 0
+ undefined, // 1
+ Infinity, // 2
+ NaN, // 3
+ 5, // 4
+ {}, // 5
+ Object.create({}), // 6
+ Object.create(null), // 7
+ [], // 8
+ /foo/, // 9
+ new Date(), // 10
+ Function, // 11
+ function() {}, // 12
+ true, // 13
+ false, // 14
+ "string" // 15
+]
+
+function True() { return true }
+function False() { return false }
+
+var trues = values.map(True)
+var falses = values.map(False)
+
+exports["test throws if not implemented"] = function(assert) {
+ var method = Method("nope")
+
+ assert.throws(function() {
+ method({})
+ }, /not implement/i, "method throws if not implemented")
+
+ assert.throws(function() {
+ method(null)
+ }, /not implement/i, "method throws on null")
+}
+
+exports["test all types inherit from default"] = function(assert) {
+ var isImplemented = Method("isImplemented")
+ isImplemented.define(function() { return true })
+
+ values.forEach(function(value) {
+ assert.ok(isImplemented(value),
+ type(value) + " inherits deafult implementation")
+ })
+}
+
+exports["test default can be implemented later"] = function(assert) {
+ var isImplemented = Method("isImplemented")
+ isImplemented.define(function() {
+ return true
+ })
+
+ values.forEach(function(value) {
+ assert.ok(isImplemented(value),
+ type(value) + " inherits deafult implementation")
+ })
+}
+
+exports["test dispatch not-implemented"] = function(assert) {
+ var isDefault = Method("isDefault")
+ values.forEach(function(value) {
+ assert.throws(function() {
+ isDefault(value)
+ }, /not implement/, type(value) + " throws if not implemented")
+ })
+}
+
+exports["test dispatch default"] = function(assert) {
+ var isDefault = Method("isDefault")
+
+ // Implement default
+ isDefault.define(True)
+ assert.deepEqual(values.map(isDefault), trues,
+ "all implementation inherit from default")
+
+}
+
+exports["test dispatch null"] = function(assert) {
+ var isNull = Method("isNull")
+
+ // Implement default
+ isNull.define(False)
+ isNull.define(null, True)
+ assert.deepEqual(values.map(isNull),
+ [ true ].
+ concat(falses.slice(1)),
+ "only null gets methods defined for null")
+}
+
+exports["test dispatch undefined"] = function(assert) {
+ var isUndefined = Method("isUndefined")
+
+ // Implement default
+ isUndefined.define(False)
+ isUndefined.define(undefined, True)
+ assert.deepEqual(values.map(isUndefined),
+ [ false, true ].
+ concat(falses.slice(2)),
+ "only undefined gets methods defined for undefined")
+}
+
+exports["test dispatch object"] = function(assert) {
+ var isObject = Method("isObject")
+
+ // Implement default
+ isObject.define(False)
+ isObject.define(Object, True)
+ assert.deepEqual(values.map(isObject),
+ [ false, false, false, false, false ].
+ concat(trues.slice(5, 13)).
+ concat([false, false, false]),
+ "all values except primitives inherit Object methods")
+
+}
+
+exports["test dispatch number"] = function(assert) {
+ var isNumber = Method("isNumber")
+ isNumber.define(False)
+ isNumber.define(Number, True)
+
+ assert.deepEqual(values.map(isNumber),
+ falses.slice(0, 2).
+ concat(true, true, true).
+ concat(falses.slice(5)),
+ "all numbers inherit from Number method")
+}
+
+exports["test dispatch string"] = function(assert) {
+ var isString = Method("isString")
+ isString.define(False)
+ isString.define(String, True)
+
+ assert.deepEqual(values.map(isString),
+ falses.slice(0, 15).
+ concat(true),
+ "all strings inherit from String method")
+}
+
+exports["test dispatch function"] = function(assert) {
+ var isFunction = Method("isFunction")
+ isFunction.define(False)
+ isFunction.define(Function, True)
+
+ assert.deepEqual(values.map(isFunction),
+ falses.slice(0, 11).
+ concat(true, true).
+ concat(falses.slice(13)),
+ "all functions inherit from Function method")
+}
+
+exports["test dispatch date"] = function(assert) {
+ var isDate = Method("isDate")
+ isDate.define(False)
+ isDate.define(Date, True)
+
+ assert.deepEqual(values.map(isDate),
+ falses.slice(0, 10).
+ concat(true).
+ concat(falses.slice(11)),
+ "all dates inherit from Date method")
+}
+
+exports["test dispatch RegExp"] = function(assert) {
+ var isRegExp = Method("isRegExp")
+ isRegExp.define(False)
+ isRegExp.define(RegExp, True)
+
+ assert.deepEqual(values.map(isRegExp),
+ falses.slice(0, 9).
+ concat(true).
+ concat(falses.slice(10)),
+ "all regexps inherit from RegExp method")
+}
+
+exports["test redefine for descendant"] = function(assert) {
+ var isFoo = Method("isFoo")
+ var ancestor = {}
+ isFoo.implement(ancestor, function() { return true })
+ var descendant = Object.create(ancestor)
+ isFoo.implement(descendant, function() { return false })
+
+ assert.ok(isFoo(ancestor), "defined on ancestor")
+ assert.ok(!isFoo(descendant), "overrided for descendant")
+}
+
+exports["test on custom types"] = function(assert) {
+ function Bar() {}
+ var isBar = Method("isBar")
+
+ isBar.define(function() { return false })
+ isBar.define(Bar, function() { return true })
+
+ assert.ok(!isBar({}), "object is get's default implementation")
+ assert.ok(isBar(new Bar()), "Foo type objects get own implementation")
+
+ var isObject = Method("isObject")
+ isObject.define(function() { return false })
+ isObject.define(Object, function() { return true })
+
+ assert.ok(isObject(new Bar()), "foo inherits implementation from object")
+
+
+ isObject.define(Bar, function() { return false })
+
+ assert.ok(!isObject(new Bar()),
+ "implementation inherited form object can be overrided")
+}
+
+
+exports["test error types"] = function(assert) {
+ var isError = Method("isError")
+ isError.define(function() { return false })
+ isError.define(Error, function() { return true })
+
+ assert.ok(isError(Error("boom")), "error is error")
+ assert.ok(isError(TypeError("boom")), "type error is an error")
+ assert.ok(isError(EvalError("boom")), "eval error is an error")
+ assert.ok(isError(RangeError("boom")), "range error is an error")
+ assert.ok(isError(ReferenceError("boom")), "reference error is an error")
+ assert.ok(isError(SyntaxError("boom")), "syntax error is an error")
+ assert.ok(isError(URIError("boom")), "URI error is an error")
+}
+
+exports["test override define polymorphic method"] = function(assert) {
+ var define = Method.define
+ var implement = Method.implement
+
+ var fn = Method("fn")
+ var methods = {}
+ implement(define, fn, function(method, label, implementation) {
+ methods[label] = implementation
+ })
+
+ function foo() {}
+
+ define(fn, "foo-case", foo)
+
+ assert.equal(methods["foo-case"], foo, "define set property")
+}
+
+exports["test override define via method API"] = function(assert) {
+ var define = Method.define
+ var implement = Method.implement
+
+ var fn = Method("fn")
+ var methods = {}
+ define.implement(fn, function(method, label, implementation) {
+ methods[label] = implementation
+ })
+
+ function foo() {}
+
+ define(fn, "foo-case", foo)
+
+ assert.equal(methods["foo-case"], foo, "define set property")
+}
+
+require("test").run(exports)
diff --git a/toolkit/jetpack/modules/system/Startup.js b/toolkit/jetpack/modules/system/Startup.js
new file mode 100644
index 000000000..b9e5d88b3
--- /dev/null
+++ b/toolkit/jetpack/modules/system/Startup.js
@@ -0,0 +1,57 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+var EXPORTED_SYMBOLS = ["Startup"];
+
+var { utils: Cu, interfaces: Ci, classes: Cc } = Components;
+const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+const { defer } = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
+
+const { XulApp } = Cu.import("resource://gre/modules/commonjs/sdk/system/xul-app.jsm", {});
+
+const appStartupSrv = Cc["@mozilla.org/toolkit/app-startup;1"]
+ .getService(Ci.nsIAppStartup);
+
+const NAME2TOPIC = {
+ 'Firefox': 'sessionstore-windows-restored',
+ 'Fennec': 'sessionstore-windows-restored',
+ 'SeaMonkey': 'sessionstore-windows-restored',
+ 'Thunderbird': 'mail-startup-done',
+ 'Instantbird': 'xul-window-visible'
+};
+
+var Startup = {
+ initialized: !appStartupSrv.startingUp
+};
+var exports = Startup;
+
+var gOnceInitializedDeferred = defer();
+exports.onceInitialized = gOnceInitializedDeferred.promise;
+
+// Set 'final-ui-startup' as default topic for unknown applications
+var appStartup = 'final-ui-startup';
+
+if (Startup.initialized) {
+ gOnceInitializedDeferred.resolve()
+}
+else {
+ // Gets the topic that fit best as application startup event, in according with
+ // the current application (e.g. Firefox, Fennec, Thunderbird...)
+ for (let name of Object.keys(NAME2TOPIC)) {
+ if (XulApp.is(name)) {
+ appStartup = NAME2TOPIC[name];
+ break;
+ }
+ }
+
+ let listener = function (subject, topic) {
+ Services.obs.removeObserver(this, topic);
+ Startup.initialized = true;
+ Services.tm.currentThread.dispatch(() => gOnceInitializedDeferred.resolve(),
+ Ci.nsIThread.DISPATCH_NORMAL);
+ }
+
+ Services.obs.addObserver(listener, appStartup, false);
+}
diff --git a/toolkit/jetpack/modules/system/moz.build b/toolkit/jetpack/modules/system/moz.build
new file mode 100644
index 000000000..60fec1c9e
--- /dev/null
+++ b/toolkit/jetpack/modules/system/moz.build
@@ -0,0 +1,9 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+EXTRA_JS_MODULES.sdk.system += [
+ 'Startup.js',
+]
diff --git a/toolkit/jetpack/moz.build b/toolkit/jetpack/moz.build
new file mode 100644
index 000000000..2024e6a7c
--- /dev/null
+++ b/toolkit/jetpack/moz.build
@@ -0,0 +1,481 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+EXTRA_JS_MODULES.sdk += [
+ 'app-extension/bootstrap.js',
+]
+
+EXTRA_JS_MODULES.sdk.system += [
+ 'modules/system/Startup.js',
+]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] != "gonk":
+ EXTRA_JS_MODULES.commonjs.method.test += [
+ 'method/test/browser.js',
+ 'method/test/common.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.deprecated += [
+ 'sdk/deprecated/api-utils.js',
+ 'sdk/deprecated/sync-worker.js',
+ 'sdk/deprecated/unit-test-finder.js',
+ 'sdk/deprecated/unit-test.js',
+ 'sdk/deprecated/window-utils.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.frame += [
+ 'sdk/frame/hidden-frame.js',
+ 'sdk/frame/utils.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.panel += [
+ 'sdk/panel/events.js',
+ 'sdk/panel/utils.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.places += [
+ 'sdk/places/bookmarks.js',
+ 'sdk/places/contract.js',
+ 'sdk/places/events.js',
+ 'sdk/places/favicon.js',
+ 'sdk/places/history.js',
+ 'sdk/places/utils.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.places.host += [
+ 'sdk/places/host/host-bookmarks.js',
+ 'sdk/places/host/host-query.js',
+ 'sdk/places/host/host-tags.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.tabs += [
+ 'sdk/tabs/common.js',
+ 'sdk/tabs/events.js',
+ 'sdk/tabs/helpers.js',
+ 'sdk/tabs/namespace.js',
+ 'sdk/tabs/observer.js',
+ 'sdk/tabs/tab-fennec.js',
+ 'sdk/tabs/tab-firefox.js',
+ 'sdk/tabs/tab.js',
+ 'sdk/tabs/tabs-firefox.js',
+ 'sdk/tabs/utils.js',
+ 'sdk/tabs/worker.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.test += [
+ 'sdk/test/assert.js',
+ 'sdk/test/harness.js',
+ 'sdk/test/httpd.js',
+ 'sdk/test/loader.js',
+ 'sdk/test/memory.js',
+ 'sdk/test/options.js',
+ 'sdk/test/runner.js',
+ 'sdk/test/utils.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.ui += [
+ 'sdk/ui/component.js',
+ 'sdk/ui/frame.js',
+ 'sdk/ui/id.js',
+ 'sdk/ui/sidebar.js',
+ 'sdk/ui/state.js',
+ 'sdk/ui/toolbar.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.ui.button += [
+ 'sdk/ui/button/action.js',
+ 'sdk/ui/button/contract.js',
+ 'sdk/ui/button/toggle.js',
+ 'sdk/ui/button/view.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.ui.sidebar += [
+ 'sdk/ui/sidebar/actions.js',
+ 'sdk/ui/sidebar/contract.js',
+ 'sdk/ui/sidebar/namespace.js',
+ 'sdk/ui/sidebar/utils.js',
+ 'sdk/ui/sidebar/view.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.window += [
+ 'sdk/window/browser.js',
+ 'sdk/window/events.js',
+ 'sdk/window/helpers.js',
+ 'sdk/window/namespace.js',
+ 'sdk/window/utils.js',
+ ]
+
+ EXTRA_JS_MODULES.commonjs.sdk.windows += [
+ 'sdk/windows/fennec.js',
+ 'sdk/windows/firefox.js',
+ 'sdk/windows/observer.js',
+ 'sdk/windows/tabs-fennec.js',
+ ]
+
+EXTRA_JS_MODULES.commonjs += [
+ 'index.js',
+ 'test.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk += [
+ 'sdk/webextension.js',
+]
+
+EXTRA_JS_MODULES.commonjs.dev += [
+ 'dev/debuggee.js',
+ 'dev/frame-script.js',
+ 'dev/panel.js',
+ 'dev/ports.js',
+ 'dev/theme.js',
+ 'dev/toolbox.js',
+ 'dev/utils.js',
+ 'dev/volcan.js',
+]
+
+EXTRA_JS_MODULES.commonjs.dev.panel += [
+ 'dev/panel/view.js',
+]
+
+EXTRA_JS_MODULES.commonjs.dev.theme += [
+ 'dev/theme/hooks.js',
+]
+
+EXTRA_JS_MODULES.commonjs.diffpatcher += [
+ 'diffpatcher/diff.js',
+ 'diffpatcher/index.js',
+ 'diffpatcher/patch.js',
+ 'diffpatcher/rebase.js',
+]
+
+EXTRA_JS_MODULES.commonjs.diffpatcher.test += [
+ 'diffpatcher/test/common.js',
+ 'diffpatcher/test/diff.js',
+ 'diffpatcher/test/index.js',
+ 'diffpatcher/test/patch.js',
+ 'diffpatcher/test/tap.js',
+]
+
+EXTRA_JS_MODULES.commonjs.framescript += [
+ 'framescript/content.jsm',
+ 'framescript/context-menu.js',
+ 'framescript/FrameScriptManager.jsm',
+ 'framescript/manager.js',
+ 'framescript/util.js',
+]
+
+EXTRA_JS_MODULES.commonjs['jetpack-id'] += [
+ 'jetpack-id/index.js',
+]
+
+EXTRA_JS_MODULES.commonjs.method += [
+ 'method/core.js',
+]
+
+EXTRA_JS_MODULES.commonjs['mozilla-toolkit-versioning'] += [
+ 'mozilla-toolkit-versioning/index.js',
+]
+
+EXTRA_JS_MODULES.commonjs['mozilla-toolkit-versioning'].lib += [
+ 'mozilla-toolkit-versioning/lib/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.node += [
+ 'node/os.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk += [
+ 'sdk/base64.js',
+ 'sdk/clipboard.js',
+ 'sdk/context-menu.js',
+ 'sdk/context-menu@2.js',
+ 'sdk/hotkeys.js',
+ 'sdk/indexed-db.js',
+ 'sdk/l10n.js',
+ 'sdk/messaging.js',
+ 'sdk/notifications.js',
+ 'sdk/page-mod.js',
+ 'sdk/page-worker.js',
+ 'sdk/panel.js',
+ 'sdk/passwords.js',
+ 'sdk/private-browsing.js',
+ 'sdk/querystring.js',
+ 'sdk/request.js',
+ 'sdk/selection.js',
+ 'sdk/self.js',
+ 'sdk/simple-prefs.js',
+ 'sdk/simple-storage.js',
+ 'sdk/system.js',
+ 'sdk/tabs.js',
+ 'sdk/test.js',
+ 'sdk/timers.js',
+ 'sdk/ui.js',
+ 'sdk/url.js',
+ 'sdk/windows.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.addon += [
+ 'sdk/addon/bootstrap.js',
+ 'sdk/addon/events.js',
+ 'sdk/addon/host.js',
+ 'sdk/addon/installer.js',
+ 'sdk/addon/manager.js',
+ 'sdk/addon/runner.js',
+ 'sdk/addon/window.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.browser += [
+ 'sdk/browser/events.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.console += [
+ 'sdk/console/plain-text.js',
+ 'sdk/console/traceback.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.content += [
+ 'sdk/content/content-worker.js',
+ 'sdk/content/content.js',
+ 'sdk/content/context-menu.js',
+ 'sdk/content/events.js',
+ 'sdk/content/l10n-html.js',
+ 'sdk/content/loader.js',
+ 'sdk/content/mod.js',
+ 'sdk/content/page-mod.js',
+ 'sdk/content/page-worker.js',
+ 'sdk/content/sandbox.js',
+ 'sdk/content/tab-events.js',
+ 'sdk/content/thumbnail.js',
+ 'sdk/content/utils.js',
+ 'sdk/content/worker-child.js',
+ 'sdk/content/worker.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.content.sandbox += [
+ 'sdk/content/sandbox/events.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk['context-menu'] += [
+ 'sdk/context-menu/context.js',
+ 'sdk/context-menu/core.js',
+ 'sdk/context-menu/readers.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.core += [
+ 'sdk/core/disposable.js',
+ 'sdk/core/heritage.js',
+ 'sdk/core/namespace.js',
+ 'sdk/core/observer.js',
+ 'sdk/core/promise.js',
+ 'sdk/core/reference.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.deprecated.events += [
+ 'sdk/deprecated/events/assembler.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.dom += [
+ 'sdk/dom/events-shimmed.js',
+ 'sdk/dom/events.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.dom.events += [
+ 'sdk/dom/events/keys.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.event += [
+ 'sdk/event/chrome.js',
+ 'sdk/event/core.js',
+ 'sdk/event/dom.js',
+ 'sdk/event/target.js',
+ 'sdk/event/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.fs += [
+ 'sdk/fs/path.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.input += [
+ 'sdk/input/browser.js',
+ 'sdk/input/customizable-ui.js',
+ 'sdk/input/frame.js',
+ 'sdk/input/system.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.io += [
+ 'sdk/io/buffer.js',
+ 'sdk/io/byte-streams.js',
+ 'sdk/io/file.js',
+ 'sdk/io/fs.js',
+ 'sdk/io/stream.js',
+ 'sdk/io/text-streams.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.keyboard += [
+ 'sdk/keyboard/hotkeys.js',
+ 'sdk/keyboard/observer.js',
+ 'sdk/keyboard/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.l10n += [
+ 'sdk/l10n/core.js',
+ 'sdk/l10n/html.js',
+ 'sdk/l10n/loader.js',
+ 'sdk/l10n/locale.js',
+ 'sdk/l10n/plural-rules.js',
+ 'sdk/l10n/prefs.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.l10n.json += [
+ 'sdk/l10n/json/core.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.l10n.properties += [
+ 'sdk/l10n/properties/core.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.lang += [
+ 'sdk/lang/functional.js',
+ 'sdk/lang/type.js',
+ 'sdk/lang/weak-set.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.lang.functional += [
+ 'sdk/lang/functional/concurrent.js',
+ 'sdk/lang/functional/core.js',
+ 'sdk/lang/functional/helpers.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.loader += [
+ 'sdk/loader/cuddlefish.js',
+ 'sdk/loader/sandbox.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.model += [
+ 'sdk/model/core.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.net += [
+ 'sdk/net/url.js',
+ 'sdk/net/xhr.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.output += [
+ 'sdk/output/system.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk['page-mod'] += [
+ 'sdk/page-mod/match-pattern.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.passwords += [
+ 'sdk/passwords/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.platform += [
+ 'sdk/platform/xpcom.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.preferences += [
+ 'sdk/preferences/event-target.js',
+ 'sdk/preferences/native-options.js',
+ 'sdk/preferences/service.js',
+ 'sdk/preferences/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk['private-browsing'] += [
+ 'sdk/private-browsing/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.remote += [
+ 'sdk/remote/child.js',
+ 'sdk/remote/core.js',
+ 'sdk/remote/parent.js',
+ 'sdk/remote/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.stylesheet += [
+ 'sdk/stylesheet/style.js',
+ 'sdk/stylesheet/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.system += [
+ 'sdk/system/child_process.js',
+ 'sdk/system/environment.js',
+ 'sdk/system/events-shimmed.js',
+ 'sdk/system/events.js',
+ 'sdk/system/globals.js',
+ 'sdk/system/process.js',
+ 'sdk/system/runtime.js',
+ 'sdk/system/unload.js',
+ 'sdk/system/xul-app.js',
+ 'sdk/system/xul-app.jsm',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.system.child_process += [
+ 'sdk/system/child_process/subprocess.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.tab += [
+ 'sdk/tab/events.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.ui.button.view += [
+ 'sdk/ui/button/view/events.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.ui.frame += [
+ 'sdk/ui/frame/model.js',
+ 'sdk/ui/frame/view.html',
+ 'sdk/ui/frame/view.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.ui.state += [
+ 'sdk/ui/state/events.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.ui.toolbar += [
+ 'sdk/ui/toolbar/model.js',
+ 'sdk/ui/toolbar/view.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.uri += [
+ 'sdk/uri/resource.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.url += [
+ 'sdk/url/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.util += [
+ 'sdk/util/array.js',
+ 'sdk/util/collection.js',
+ 'sdk/util/contract.js',
+ 'sdk/util/deprecate.js',
+ 'sdk/util/dispatcher.js',
+ 'sdk/util/list.js',
+ 'sdk/util/match-pattern.js',
+ 'sdk/util/object.js',
+ 'sdk/util/rules.js',
+ 'sdk/util/sequence.js',
+ 'sdk/util/uuid.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.view += [
+ 'sdk/view/core.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.worker += [
+ 'sdk/worker/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.sdk.zip += [
+ 'sdk/zip/utils.js',
+]
+
+EXTRA_JS_MODULES.commonjs.toolkit += [
+ 'toolkit/loader.js',
+ 'toolkit/require.js',
+]
diff --git a/toolkit/jetpack/mozilla-toolkit-versioning/index.js b/toolkit/jetpack/mozilla-toolkit-versioning/index.js
new file mode 100644
index 000000000..2f607c880
--- /dev/null
+++ b/toolkit/jetpack/mozilla-toolkit-versioning/index.js
@@ -0,0 +1,112 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var versionParse = require('./lib/utils').versionParse;
+
+var COMPARATORS = ['>=', '<=', '>', '<', '=', '~', '^'];
+
+exports.parse = function (input) {
+ input = input || '';
+ input = input.trim();
+ if (!input)
+ throw new Error('`parse` argument must be a populated string.');
+
+ // Handle the "*" case
+ if (input === "*") {
+ return { min: undefined, max: undefined };
+ }
+
+ var inputs = input.split(' ');
+ var min;
+ var max;
+
+ // 1.2.3 - 2.3.4
+ if (inputs.length === 3 && inputs[1] === '-') {
+ return { min: inputs[0], max: inputs[2] };
+ }
+
+ inputs.forEach(function (input) {
+ var parsed = parseExpression(input);
+ var version = parsed.version;
+ var comparator = parsed.comparator;
+
+ // 1.2.3
+ if (inputs.length === 1 && !comparator)
+ min = max = version;
+
+ // Parse min
+ if (~comparator.indexOf('>')) {
+ if (~comparator.indexOf('='))
+ min = version; // >=1.2.3
+ else
+ min = increment(version); // >1.2.3
+ }
+ else if (~comparator.indexOf('<')) {
+ if (~comparator.indexOf('='))
+ max = version; // <=1.2.3
+ else
+ max = decrement(version); // <1.2.3
+ }
+ });
+
+ return {
+ min: min,
+ max : max
+ };
+};
+
+function parseExpression (input) {
+ for (var i = 0; i < COMPARATORS.length; i++)
+ if (~input.indexOf(COMPARATORS[i]))
+ return {
+ comparator: COMPARATORS[i],
+ version: input.substr(COMPARATORS[i].length)
+ };
+ return { version: input, comparator: '' };
+}
+
+/**
+ * Takes a version string ('1.2.3') and returns a version string
+ * that'll parse as one less than the input string ('1.2.3.-1').
+ *
+ * @param {String} vString
+ * @return {String}
+ */
+function decrement (vString) {
+ return vString + (vString.charAt(vString.length - 1) === '.' ? '' : '.') + '-1';
+}
+exports.decrement = decrement;
+
+/**
+ * Takes a version string ('1.2.3') and returns a version string
+ * that'll parse as greater than the input string by the smallest margin
+ * possible ('1.2.3.1').
+ * listed as number-A, string-B, number-C, string-D in
+ * Mozilla's Toolkit Format.
+ * https://developer.mozilla.org/en-US/docs/Toolkit_version_format
+ *
+ * @param {String} vString
+ * @return {String}
+ */
+function increment (vString) {
+ var match = versionParse(vString);
+ var a = match[1];
+ var b = match[2];
+ var c = match[3];
+ var d = match[4];
+ var lastPos = vString.length - 1;
+ var lastChar = vString.charAt(lastPos);
+
+ if (!b) {
+ return vString + (lastChar === '.' ? '' : '.') + '1';
+ }
+ if (!c) {
+ return vString + '1';
+ }
+ if (!d) {
+ return vString.substr(0, lastPos) + (++lastChar);
+ }
+ return vString.substr(0, lastPos) + String.fromCharCode(lastChar.charCodeAt(0) + 1);
+}
+exports.increment = increment;
diff --git a/toolkit/jetpack/mozilla-toolkit-versioning/lib/utils.js b/toolkit/jetpack/mozilla-toolkit-versioning/lib/utils.js
new file mode 100644
index 000000000..e068085c0
--- /dev/null
+++ b/toolkit/jetpack/mozilla-toolkit-versioning/lib/utils.js
@@ -0,0 +1,15 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * Breaks up a version string into the 4 components
+ * defined in:
+ * https://developer.mozilla.org/en-US/docs/Toolkit_version_format
+ * @params {String} val
+ * @return {String}
+ */
+function versionParse (val) {
+ return val.match(/^([0-9\.]*)([a-zA-Z]*)([0-9\.]*)([a-zA-Z]*)$/);
+}
+exports.versionParse = versionParse;
diff --git a/toolkit/jetpack/mozilla-toolkit-versioning/package.json b/toolkit/jetpack/mozilla-toolkit-versioning/package.json
new file mode 100644
index 000000000..d9b0424e5
--- /dev/null
+++ b/toolkit/jetpack/mozilla-toolkit-versioning/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "mozilla-toolkit-versioning",
+ "version": "0.0.2",
+ "description": "Parser for Mozilla's toolkit version format",
+ "main": "index.js",
+ "scripts": {
+ "test": "./node_modules/.bin/mocha --reporter spec --ui bdd"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jsantell/mozilla-toolkit-versioning.git"
+ },
+ "author": "Jordan Santell",
+ "license": "MIT",
+ "dependencies": {},
+ "devDependencies": {
+ "mocha": "^1.21.4",
+ "chai": "^1.9.1",
+ "mozilla-version-comparator": "^1.0.2"
+ }
+}
diff --git a/toolkit/jetpack/node/os.js b/toolkit/jetpack/node/os.js
new file mode 100644
index 000000000..1c41a9246
--- /dev/null
+++ b/toolkit/jetpack/node/os.js
@@ -0,0 +1,90 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci } = require('chrome');
+const system = require('../sdk/system');
+const runtime = require('../sdk/system/runtime');
+const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
+const isWindows = system.platform === 'win32';
+const endianness = ((new Uint32Array((new Uint8Array([1,2,3,4])).buffer))[0] === 0x04030201) ? 'LE' : 'BE';
+
+XPCOMUtils.defineLazyGetter(this, "oscpu", () => {
+ try {
+ return Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).oscpu;
+ } catch (e) {
+ return "";
+ }
+});
+
+XPCOMUtils.defineLazyGetter(this, "hostname", () => {
+ try {
+ // On some platforms (Linux according to try), this service does not exist and fails.
+ return Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService).myHostName;
+ } catch (e) {
+ return "";
+ }
+});
+
+/**
+ * Returns a path to a temp directory
+ */
+exports.tmpdir = () => system.pathFor('TmpD');
+
+/**
+ * Returns the endianness of the architecture: either 'LE' or 'BE'
+ */
+exports.endianness = () => endianness;
+
+/**
+ * Returns hostname of the machine
+ */
+exports.hostname = () => hostname;
+
+/**
+ * Name of the OS type
+ * Possible values:
+ * https://developer.mozilla.org/en/OS_TARGET
+ */
+exports.type = () => runtime.OS;
+
+/**
+ * Name of the OS Platform in lower case string.
+ * Possible values:
+ * https://developer.mozilla.org/en/OS_TARGET
+ */
+exports.platform = () => system.platform;
+
+/**
+ * Type of processor architecture running:
+ * 'arm', 'ia32', 'x86', 'x64'
+ */
+exports.arch = () => system.architecture;
+
+/**
+ * Returns the operating system release.
+ */
+exports.release = () => {
+ let match = oscpu.match(/(\d[\.\d]*)/);
+ return match && match.length > 1 ? match[1] : oscpu;
+};
+
+/**
+ * Returns EOL character for the OS
+ */
+exports.EOL = isWindows ? '\r\n' : '\n';
+
+/**
+ * Returns [0, 0, 0], as this is not implemented.
+ */
+exports.loadavg = () => [0, 0, 0];
+
+['uptime', 'totalmem', 'freemem', 'cpus'].forEach(method => {
+ exports[method] = () => { throw new Error('os.' + method + ' is not supported.'); };
+});
diff --git a/toolkit/jetpack/sdk/addon/bootstrap.js b/toolkit/jetpack/sdk/addon/bootstrap.js
new file mode 100644
index 000000000..0397d91e5
--- /dev/null
+++ b/toolkit/jetpack/sdk/addon/bootstrap.js
@@ -0,0 +1,182 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Cu } = require("chrome");
+const { NetUtil } = require("resource://gre/modules/NetUtil.jsm");
+const { Task: { spawn } } = require("resource://gre/modules/Task.jsm");
+const { readURI } = require("sdk/net/url");
+const { mount, unmount } = require("sdk/uri/resource");
+const { setTimeout } = require("sdk/timers");
+const { Loader, Require, Module, main, unload } = require("toolkit/loader");
+const prefs = require("sdk/preferences/service");
+
+// load below now, so that it can be used by sdk/addon/runner
+// see bug https://bugzilla.mozilla.org/show_bug.cgi?id=1042239
+const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {});
+
+const REASON = [ "unknown", "startup", "shutdown", "enable", "disable",
+ "install", "uninstall", "upgrade", "downgrade" ];
+
+const UUID_PATTERN = /^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/;
+// Takes add-on ID and normalizes it to a domain name so that add-on
+// can be mapped to resource://domain/
+const readDomain = id =>
+ // If only `@` character is the first one, than just substract it,
+ // otherwise fallback to legacy normalization code path. Note: `.`
+ // is valid character for resource substitutaiton & we intend to
+ // make add-on URIs intuitive, so it's best to just stick to an
+ // add-on author typed input.
+ id.lastIndexOf("@") === 0 ? id.substr(1).toLowerCase() :
+ id.toLowerCase().
+ replace(/@/g, "-at-").
+ replace(/\./g, "-dot-").
+ replace(UUID_PATTERN, "$1");
+
+const readPaths = id => {
+ const base = `extensions.modules.${id}.path.`;
+ const domain = readDomain(id);
+ return prefs.keys(base).reduce((paths, key) => {
+ const value = prefs.get(key);
+ const name = key.replace(base, "");
+ const path = name.split(".").join("/");
+ const prefix = path.length ? `${path}/` : path;
+ const uri = value.endsWith("/") ? value : `${value}/`;
+ const root = `extensions.modules.${domain}.commonjs.path.${name}`;
+
+ mount(root, uri);
+
+ paths[prefix] = `resource://${root}/`;
+ return paths;
+ }, {});
+};
+
+const Bootstrap = function(mountURI) {
+ this.mountURI = mountURI;
+ this.install = this.install.bind(this);
+ this.uninstall = this.uninstall.bind(this);
+ this.startup = this.startup.bind(this);
+ this.shutdown = this.shutdown.bind(this);
+};
+Bootstrap.prototype = {
+ constructor: Bootstrap,
+ mount(domain, rootURI) {
+ mount(domain, rootURI);
+ this.domain = domain;
+ },
+ unmount() {
+ if (this.domain) {
+ unmount(this.domain);
+ this.domain = null;
+ }
+ },
+ install(addon, reason) {
+ return new Promise(resolve => resolve());
+ },
+ uninstall(addon, reason) {
+ return new Promise(resolve => {
+ const {id} = addon;
+
+ prefs.reset(`extensions.${id}.sdk.domain`);
+ prefs.reset(`extensions.${id}.sdk.version`);
+ prefs.reset(`extensions.${id}.sdk.rootURI`);
+ prefs.reset(`extensions.${id}.sdk.baseURI`);
+ prefs.reset(`extensions.${id}.sdk.load.reason`);
+
+ resolve();
+ });
+ },
+ startup(addon, reasonCode) {
+ const { id, version, resourceURI: { spec: addonURI } } = addon;
+ const rootURI = this.mountURI || addonURI;
+ const reason = REASON[reasonCode];
+ const self = this;
+
+ return spawn(function*() {
+ const metadata = JSON.parse(yield readURI(`${rootURI}package.json`));
+ const domain = readDomain(id);
+ const baseURI = `resource://${domain}/`;
+
+ this.mount(domain, rootURI);
+
+ prefs.set(`extensions.${id}.sdk.domain`, domain);
+ prefs.set(`extensions.${id}.sdk.version`, version);
+ prefs.set(`extensions.${id}.sdk.rootURI`, rootURI);
+ prefs.set(`extensions.${id}.sdk.baseURI`, baseURI);
+ prefs.set(`extensions.${id}.sdk.load.reason`, reason);
+
+ const command = prefs.get(`extensions.${id}.sdk.load.command`);
+
+ const loader = Loader({
+ id,
+ isNative: true,
+ checkCompatibility: true,
+ prefixURI: baseURI,
+ rootURI: baseURI,
+ name: metadata.name,
+ paths: Object.assign({
+ "": "resource://gre/modules/commonjs/",
+ "devtools/": "resource://devtools/",
+ "./": baseURI
+ }, readPaths(id)),
+ manifest: metadata,
+ metadata: metadata,
+ modules: {
+ "@test/options": {},
+ },
+ noQuit: prefs.get(`extensions.${id}.sdk.test.no-quit`, false)
+ });
+ self.loader = loader;
+
+ const module = Module("package.json", `${baseURI}package.json`);
+ const require = Require(loader, module);
+ const main = command === "test" ? "sdk/test/runner" : null;
+ const prefsURI = `${baseURI}defaults/preferences/prefs.js`;
+
+ // Init the 'sdk/webextension' module from the bootstrap addon parameter.
+ require("sdk/webextension").initFromBootstrapAddonParam(addon);
+
+ const { startup } = require("sdk/addon/runner");
+ startup(reason, {loader, main, prefsURI});
+ }.bind(this)).catch(error => {
+ console.error(`Failed to start ${id} addon`, error);
+ throw error;
+ });
+ },
+ shutdown(addon, code) {
+ this.unmount();
+ return this.unload(REASON[code]);
+ },
+ unload(reason) {
+ return new Promise(resolve => {
+ const { loader } = this;
+ if (loader) {
+ this.loader = null;
+ unload(loader, reason);
+
+ setTimeout(() => {
+ for (let uri of Object.keys(loader.sandboxes)) {
+ let sandbox = loader.sandboxes[uri];
+ if (Cu.getClassName(sandbox, true) == "Sandbox")
+ Cu.nukeSandbox(sandbox);
+ delete loader.sandboxes[uri];
+ delete loader.modules[uri];
+ }
+
+ try {
+ Cu.nukeSandbox(loader.sharedGlobalSandbox);
+ } catch (e) {
+ Cu.reportError(e);
+ }
+
+ resolve();
+ }, 1000);
+ }
+ else {
+ resolve();
+ }
+ });
+ }
+};
+exports.Bootstrap = Bootstrap;
diff --git a/toolkit/jetpack/sdk/addon/events.js b/toolkit/jetpack/sdk/addon/events.js
new file mode 100644
index 000000000..45bada6e1
--- /dev/null
+++ b/toolkit/jetpack/sdk/addon/events.js
@@ -0,0 +1,56 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental'
+};
+
+var { request: hostReq, response: hostRes } = require('./host');
+var { defer: async } = require('../lang/functional');
+var { defer } = require('../core/promise');
+var { emit: emitSync, on, off } = require('../event/core');
+var { uuid } = require('../util/uuid');
+var emit = async(emitSync);
+
+// Map of IDs to deferreds
+var requests = new Map();
+
+// May not be necessary to wrap this in `async`
+// once promises are async via bug 881047
+var receive = async(function ({data, id, error}) {
+ let request = requests.get(id);
+ if (request) {
+ if (error) request.reject(error);
+ else request.resolve(clone(data));
+ requests.delete(id);
+ }
+});
+on(hostRes, 'data', receive);
+
+/*
+ * Send is a helper to be used in client APIs to send
+ * a request to host
+ */
+function send (eventName, data) {
+ let id = uuid();
+ let deferred = defer();
+ requests.set(id, deferred);
+ emit(hostReq, 'data', {
+ id: id,
+ data: clone(data),
+ event: eventName
+ });
+ return deferred.promise;
+}
+exports.send = send;
+
+/*
+ * Implement internal structured cloning algorithm in the future?
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#internal-structured-cloning-algorithm
+ */
+function clone (obj) {
+ return JSON.parse(JSON.stringify(obj || {}));
+}
diff --git a/toolkit/jetpack/sdk/addon/host.js b/toolkit/jetpack/sdk/addon/host.js
new file mode 100644
index 000000000..91aa0e869
--- /dev/null
+++ b/toolkit/jetpack/sdk/addon/host.js
@@ -0,0 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+exports.request = {};
+exports.response = {};
diff --git a/toolkit/jetpack/sdk/addon/installer.js b/toolkit/jetpack/sdk/addon/installer.js
new file mode 100644
index 000000000..bb8cf8d16
--- /dev/null
+++ b/toolkit/jetpack/sdk/addon/installer.js
@@ -0,0 +1,121 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci, Cu } = require("chrome");
+const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
+const { defer } = require("../core/promise");
+const { setTimeout } = require("../timers");
+
+/**
+ * `install` method error codes:
+ *
+ * https://developer.mozilla.org/en/Addons/Add-on_Manager/AddonManager#AddonInstall_errors
+ */
+exports.ERROR_NETWORK_FAILURE = AddonManager.ERROR_NETWORK_FAILURE;
+exports.ERROR_INCORRECT_HASH = AddonManager.ERROR_INCORRECT_HASH;
+exports.ERROR_CORRUPT_FILE = AddonManager.ERROR_CORRUPT_FILE;
+exports.ERROR_FILE_ACCESS = AddonManager.ERROR_FILE_ACCESS;
+
+/**
+ * Immediatly install an addon.
+ *
+ * @param {String} xpiPath
+ * file path to an xpi file to install
+ * @return {Promise}
+ * A promise resolved when the addon is finally installed.
+ * Resolved with addon id as value or rejected with an error code.
+ */
+exports.install = function install(xpiPath) {
+ let { promise, resolve, reject } = defer();
+
+ // Create nsIFile for the xpi file
+ let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
+ try {
+ file.initWithPath(xpiPath);
+ }
+ catch(e) {
+ reject(exports.ERROR_FILE_ACCESS);
+ return promise;
+ }
+
+ // Listen for installation end
+ let listener = {
+ onInstallEnded: function(aInstall, aAddon) {
+ aInstall.removeListener(listener);
+ // Bug 749745: on FF14+, onInstallEnded is called just before `startup()`
+ // is called, but we expect to resolve the promise only after it.
+ // As startup is called synchronously just after onInstallEnded,
+ // a simple setTimeout(0) is enough
+ setTimeout(resolve, 0, aAddon.id);
+ },
+ onInstallFailed: function (aInstall) {
+ aInstall.removeListener(listener);
+ reject(aInstall.error);
+ },
+ onDownloadFailed: function(aInstall) {
+ this.onInstallFailed(aInstall);
+ }
+ };
+
+ // Order AddonManager to install the addon
+ AddonManager.getInstallForFile(file, function(install) {
+ if (install.error == 0) {
+ install.addListener(listener);
+ install.install();
+ } else {
+ reject(install.error);
+ }
+ });
+
+ return promise;
+};
+
+exports.uninstall = function uninstall(addonId) {
+ let { promise, resolve, reject } = defer();
+
+ // Listen for uninstallation end
+ let listener = {
+ onUninstalled: function onUninstalled(aAddon) {
+ if (aAddon.id != addonId)
+ return;
+ AddonManager.removeAddonListener(listener);
+ resolve();
+ }
+ };
+ AddonManager.addAddonListener(listener);
+
+ // Order Addonmanager to uninstall the addon
+ getAddon(addonId).then(addon => addon.uninstall(), reject);
+
+ return promise;
+};
+
+exports.disable = function disable(addonId) {
+ return getAddon(addonId).then(addon => {
+ addon.userDisabled = true;
+ return addonId;
+ });
+};
+
+exports.enable = function enabled(addonId) {
+ return getAddon(addonId).then(addon => {
+ addon.userDisabled = false;
+ return addonId;
+ });
+};
+
+exports.isActive = function isActive(addonId) {
+ return getAddon(addonId).then(addon => addon.isActive && !addon.appDisabled);
+};
+
+const getAddon = function getAddon (id) {
+ let { promise, resolve, reject } = defer();
+ AddonManager.getAddonByID(id, addon => addon ? resolve(addon) : reject());
+ return promise;
+}
+exports.getAddon = getAddon;
diff --git a/toolkit/jetpack/sdk/addon/manager.js b/toolkit/jetpack/sdk/addon/manager.js
new file mode 100644
index 000000000..7ac0a7d6e
--- /dev/null
+++ b/toolkit/jetpack/sdk/addon/manager.js
@@ -0,0 +1,18 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
+const { defer } = require("../core/promise");
+
+function getAddonByID(id) {
+ let { promise, resolve } = defer();
+ AddonManager.getAddonByID(id, resolve);
+ return promise;
+}
+exports.getAddonByID = getAddonByID;
diff --git a/toolkit/jetpack/sdk/addon/runner.js b/toolkit/jetpack/sdk/addon/runner.js
new file mode 100644
index 000000000..3977a04e4
--- /dev/null
+++ b/toolkit/jetpack/sdk/addon/runner.js
@@ -0,0 +1,180 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci, Cu } = require('chrome');
+const { rootURI, metadata, isNative } = require('@loader/options');
+const { id, loadReason } = require('../self');
+const { descriptor, Sandbox, evaluate, main, resolveURI } = require('toolkit/loader');
+const { once } = require('../system/events');
+const { exit, env, staticArgs } = require('../system');
+const { when: unload } = require('../system/unload');
+const globals = require('../system/globals');
+const xulApp = require('../system/xul-app');
+const { get } = require('../preferences/service');
+const appShellService = Cc['@mozilla.org/appshell/appShellService;1'].
+ getService(Ci.nsIAppShellService);
+const { preferences } = metadata;
+
+const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {}).exports;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyGetter(this, "BrowserToolboxProcess", function () {
+ return Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm", {}).
+ BrowserToolboxProcess;
+});
+
+// Initializes default preferences
+function setDefaultPrefs(prefsURI) {
+ const prefs = Cc['@mozilla.org/preferences-service;1'].
+ getService(Ci.nsIPrefService).
+ QueryInterface(Ci.nsIPrefBranch2);
+ const branch = prefs.getDefaultBranch('');
+ const sandbox = Sandbox({
+ name: prefsURI,
+ prototype: {
+ pref: function(key, val) {
+ switch (typeof val) {
+ case 'boolean':
+ branch.setBoolPref(key, val);
+ break;
+ case 'number':
+ if (val % 1 == 0) // number must be a integer, otherwise ignore it
+ branch.setIntPref(key, val);
+ break;
+ case 'string':
+ branch.setCharPref(key, val);
+ break;
+ }
+ }
+ }
+ });
+ // load preferences.
+ evaluate(sandbox, prefsURI);
+}
+
+function definePseudo(loader, id, exports) {
+ let uri = resolveURI(id, loader.mapping);
+ loader.modules[uri] = { exports: exports };
+}
+
+function startup(reason, options) {
+ return Startup.onceInitialized.then(() => {
+ // Inject globals ASAP in order to have console API working ASAP
+ Object.defineProperties(options.loader.globals, descriptor(globals));
+
+ // NOTE: Module is intentionally required only now because it relies
+ // on existence of hidden window, which does not exists until startup.
+ let { ready } = require('../addon/window');
+ // Load localization manifest and .properties files.
+ // Run the addon even in case of error (best effort approach)
+ require('../l10n/loader').
+ load(rootURI).
+ then(null, function failure(error) {
+ if (!isNative)
+ console.info("Error while loading localization: " + error.message);
+ }).
+ then(function onLocalizationReady(data) {
+ // Exports data to a pseudo module so that api-utils/l10n/core
+ // can get access to it
+ definePseudo(options.loader, '@l10n/data', data ? data : null);
+ return ready;
+ }).then(function() {
+ run(options);
+ }).then(null, console.exception);
+ return void 0; // otherwise we raise a warning, see bug 910304
+ });
+}
+
+function run(options) {
+ try {
+ // Try initializing HTML localization before running main module. Just print
+ // an exception in case of error, instead of preventing addon to be run.
+ try {
+ // Do not enable HTML localization while running test as it is hard to
+ // disable. Because unit tests are evaluated in a another Loader who
+ // doesn't have access to this current loader.
+ if (options.main !== 'sdk/test/runner') {
+ require('../l10n/html').enable();
+ }
+ }
+ catch(error) {
+ console.exception(error);
+ }
+
+ // native-options does stuff directly with preferences key from package.json
+ if (preferences && preferences.length > 0) {
+ try {
+ require('../preferences/native-options').
+ enable({ preferences: preferences, id: id }).
+ catch(console.exception);
+ }
+ catch (error) {
+ console.exception(error);
+ }
+ }
+ else {
+ // keeping support for addons packaged with older SDK versions,
+ // when cfx didn't include the 'preferences' key in @loader/options
+
+ // Initialize inline options localization, without preventing addon to be
+ // run in case of error
+ try {
+ require('../l10n/prefs').enable();
+ }
+ catch(error) {
+ console.exception(error);
+ }
+
+ // TODO: When bug 564675 is implemented this will no longer be needed
+ // Always set the default prefs, because they disappear on restart
+ if (options.prefsURI) {
+ // Only set if `prefsURI` specified
+ try {
+ setDefaultPrefs(options.prefsURI);
+ }
+ catch (err) {
+ // cfx bootstrap always passes prefsURI, even in addons without prefs
+ }
+ }
+ }
+
+ // this is where the addon's main.js finally run.
+ let program = main(options.loader, options.main);
+
+ if (typeof(program.onUnload) === 'function')
+ unload(program.onUnload);
+
+ if (typeof(program.main) === 'function') {
+ program.main({
+ loadReason: loadReason,
+ staticArgs: staticArgs
+ }, {
+ print: function print(_) { dump(_ + '\n') },
+ quit: exit
+ });
+ }
+
+ if (get("extensions." + id + ".sdk.debug.show", false)) {
+ BrowserToolboxProcess.init({ addonID: id });
+ }
+ } catch (error) {
+ console.exception(error);
+ throw error;
+ }
+}
+exports.startup = startup;
+
+// If add-on is lunched via `cfx run` we need to use `system.exit` to let
+// cfx know we're done (`cfx test` will take care of exit so we don't do
+// anything here).
+if (env.CFX_COMMAND === 'run') {
+ unload(function(reason) {
+ if (reason === 'shutdown')
+ exit(0);
+ });
+}
diff --git a/toolkit/jetpack/sdk/addon/window.js b/toolkit/jetpack/sdk/addon/window.js
new file mode 100644
index 000000000..93ed1d8dc
--- /dev/null
+++ b/toolkit/jetpack/sdk/addon/window.js
@@ -0,0 +1,66 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Ci, Cc } = require("chrome");
+const { make: makeWindow, getHiddenWindow } = require("../window/utils");
+const { create: makeFrame, getDocShell } = require("../frame/utils");
+const { defer } = require("../core/promise");
+const { when: unload } = require("../system/unload");
+const cfxArgs = require("../test/options");
+
+var addonPrincipal = Cc["@mozilla.org/systemprincipal;1"].
+ createInstance(Ci.nsIPrincipal);
+
+var hiddenWindow = getHiddenWindow();
+
+if (cfxArgs.parseable) {
+ console.info("hiddenWindow document.documentURI:" +
+ hiddenWindow.document.documentURI);
+ console.info("hiddenWindow document.readyState:" +
+ hiddenWindow.document.readyState);
+}
+
+// Once Bug 565388 is fixed and shipped we'll be able to make invisible,
+// permanent docShells. Meanwhile we create hidden top level window and
+// use it's docShell.
+var frame = makeFrame(hiddenWindow.document, {
+ nodeName: "iframe",
+ namespaceURI: "http://www.w3.org/1999/xhtml",
+ allowJavascript: true,
+ allowPlugins: true
+})
+var docShell = getDocShell(frame);
+var eventTarget = docShell.chromeEventHandler;
+
+// We need to grant docShell system principals in order to load XUL document
+// from data URI into it.
+docShell.createAboutBlankContentViewer(addonPrincipal);
+
+// Get a reference to the DOM window of the given docShell and load
+// such document into that would allow us to create XUL iframes, that
+// are necessary for hidden frames etc..
+var window = docShell.contentViewer.DOMDocument.defaultView;
+window.location = "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window/>";
+
+// Create a promise that is delivered once add-on window is interactive,
+// used by add-on runner to defer add-on loading until window is ready.
+var { promise, resolve } = defer();
+eventTarget.addEventListener("DOMContentLoaded", function handler(event) {
+ eventTarget.removeEventListener("DOMContentLoaded", handler, false);
+ resolve();
+}, false);
+
+exports.ready = promise;
+exports.window = window;
+
+// Still close window on unload to claim memory back early.
+unload(function() {
+ window.close()
+ frame.parentNode.removeChild(frame);
+});
diff --git a/toolkit/jetpack/sdk/base64.js b/toolkit/jetpack/sdk/base64.js
new file mode 100644
index 000000000..a07b302e0
--- /dev/null
+++ b/toolkit/jetpack/sdk/base64.js
@@ -0,0 +1,47 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cu } = require("chrome");
+
+// Passing an empty object as second argument to avoid scope's pollution
+// (devtools loader injects these symbols as global and prevent using
+// const here)
+var { atob, btoa } = Cu.import("resource://gre/modules/Services.jsm", {});
+
+function isUTF8(charset) {
+ let type = typeof charset;
+
+ if (type === "undefined")
+ return false;
+
+ if (type === "string" && charset.toLowerCase() === "utf-8")
+ return true;
+
+ throw new Error("The charset argument can be only 'utf-8'");
+}
+
+function toOctetChar(c) {
+ return String.fromCharCode(c.charCodeAt(0) & 0xFF);
+}
+
+exports.decode = function (data, charset) {
+ if (isUTF8(charset))
+ return decodeURIComponent(escape(atob(data)))
+
+ return atob(data);
+}
+
+exports.encode = function (data, charset) {
+ if (isUTF8(charset))
+ return btoa(unescape(encodeURIComponent(data)))
+
+ data = data.replace(/[^\x00-\xFF]/g, toOctetChar);
+ return btoa(data);
+}
diff --git a/toolkit/jetpack/sdk/browser/events.js b/toolkit/jetpack/sdk/browser/events.js
new file mode 100644
index 000000000..f91119031
--- /dev/null
+++ b/toolkit/jetpack/sdk/browser/events.js
@@ -0,0 +1,20 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { events } = require("../window/events");
+const { filter } = require("../event/utils");
+const { isBrowser } = require("../window/utils");
+
+// TODO: `isBrowser` detects weather window is a browser by checking
+// `windowtype` attribute, which means that all 'open' events will be
+// filtered out since document is not loaded yet. Maybe we can find a better
+// implementation for `isBrowser`. Either way it's not really needed yet
+// neither window tracker provides this event.
+
+exports.events = filter(events, ({target}) => isBrowser(target));
diff --git a/toolkit/jetpack/sdk/clipboard.js b/toolkit/jetpack/sdk/clipboard.js
new file mode 100644
index 000000000..048d5f2f1
--- /dev/null
+++ b/toolkit/jetpack/sdk/clipboard.js
@@ -0,0 +1,337 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "stable",
+ "engines": {
+ // TODO Fennec Support 789757
+ "Firefox": "*",
+ "SeaMonkey": "*",
+ "Thunderbird": "*"
+ }
+};
+
+const { Cc, Ci } = require("chrome");
+const { DataURL } = require("./url");
+const apiUtils = require("./deprecated/api-utils");
+/*
+While these data flavors resemble Internet media types, they do
+no directly map to them.
+*/
+const kAllowableFlavors = [
+ "text/unicode",
+ "text/html",
+ "image/png"
+ /* CURRENTLY UNSUPPORTED FLAVORS
+ "text/plain",
+ "image/jpg",
+ "image/jpeg",
+ "image/gif",
+ "text/x-moz-text-internal",
+ "AOLMAIL",
+ "application/x-moz-file",
+ "text/x-moz-url",
+ "text/x-moz-url-data",
+ "text/x-moz-url-desc",
+ "text/x-moz-url-priv",
+ "application/x-moz-nativeimage",
+ "application/x-moz-nativehtml",
+ "application/x-moz-file-promise-url",
+ "application/x-moz-file-promise-dest-filename",
+ "application/x-moz-file-promise",
+ "application/x-moz-file-promise-dir"
+ */
+];
+
+/*
+Aliases for common flavors. Not all flavors will
+get an alias. New aliases must be approved by a
+Jetpack API druid.
+*/
+const kFlavorMap = [
+ { short: "text", long: "text/unicode" },
+ { short: "html", long: "text/html" },
+ { short: "image", long: "image/png" }
+];
+
+var clipboardService = Cc["@mozilla.org/widget/clipboard;1"].
+ getService(Ci.nsIClipboard);
+
+var clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].
+ getService(Ci.nsIClipboardHelper);
+
+var imageTools = Cc["@mozilla.org/image/tools;1"].
+ getService(Ci.imgITools);
+
+exports.set = function(aData, aDataType) {
+
+ let options = {
+ data: aData,
+ datatype: aDataType || "text"
+ };
+
+ // If `aDataType` is not given or if it's "image", the data is parsed as
+ // data URL to detect a better datatype
+ if (aData && (!aDataType || aDataType === "image")) {
+ try {
+ let dataURL = new DataURL(aData);
+
+ options.datatype = dataURL.mimeType;
+ options.data = dataURL.data;
+ }
+ catch (e) {
+ // Ignore invalid URIs
+ if (e.name !== "URIError") {
+ throw e;
+ }
+ }
+ }
+
+ options = apiUtils.validateOptions(options, {
+ data: {
+ is: ["string"]
+ },
+ datatype: {
+ is: ["string"]
+ }
+ });
+
+ let flavor = fromJetpackFlavor(options.datatype);
+
+ if (!flavor)
+ throw new Error("Invalid flavor for " + options.datatype);
+
+ // Additional checks for using the simple case
+ if (flavor == "text/unicode") {
+ clipboardHelper.copyString(options.data);
+ return true;
+ }
+
+ // Below are the more complex cases where we actually have to work with a
+ // nsITransferable object
+ var xferable = Cc["@mozilla.org/widget/transferable;1"].
+ createInstance(Ci.nsITransferable);
+ if (!xferable)
+ throw new Error("Couldn't set the clipboard due to an internal error " +
+ "(couldn't create a Transferable object).");
+ // Bug 769440: Starting with FF16, transferable have to be inited
+ if ("init" in xferable)
+ xferable.init(null);
+
+ switch (flavor) {
+ case "text/html":
+ // add text/html flavor
+ let str = Cc["@mozilla.org/supports-string;1"].
+ createInstance(Ci.nsISupportsString);
+
+ str.data = options.data;
+ xferable.addDataFlavor(flavor);
+ xferable.setTransferData(flavor, str, str.data.length * 2);
+
+ // add a text/unicode flavor (html converted to plain text)
+ str = Cc["@mozilla.org/supports-string;1"].
+ createInstance(Ci.nsISupportsString);
+ let converter = Cc["@mozilla.org/feed-textconstruct;1"].
+ createInstance(Ci.nsIFeedTextConstruct);
+
+ converter.type = "html";
+ converter.text = options.data;
+ str.data = converter.plainText();
+ xferable.addDataFlavor("text/unicode");
+ xferable.setTransferData("text/unicode", str, str.data.length * 2);
+ break;
+
+ // Set images to the clipboard is not straightforward, to have an idea how
+ // it works on platform side, see:
+ // http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsCopySupport.cpp?rev=7857c5bff017#530
+ case "image/png":
+ let image = options.data;
+
+ let container = {};
+
+ try {
+ let input = Cc["@mozilla.org/io/string-input-stream;1"].
+ createInstance(Ci.nsIStringInputStream);
+
+ input.setData(image, image.length);
+
+ imageTools.decodeImageData(input, flavor, container);
+ }
+ catch (e) {
+ throw new Error("Unable to decode data given in a valid image.");
+ }
+
+ // Store directly the input stream makes the cliboard's data available
+ // for Firefox but not to the others application or to the OS. Therefore,
+ // a `nsISupportsInterfacePointer` object that reference an `imgIContainer`
+ // with the image is needed.
+ var imgPtr = Cc["@mozilla.org/supports-interface-pointer;1"].
+ createInstance(Ci.nsISupportsInterfacePointer);
+
+ imgPtr.data = container.value;
+
+ xferable.addDataFlavor(flavor);
+ xferable.setTransferData(flavor, imgPtr, -1);
+
+ break;
+ default:
+ throw new Error("Unable to handle the flavor " + flavor + ".");
+ }
+
+ // TODO: Not sure if this will ever actually throw. -zpao
+ try {
+ clipboardService.setData(
+ xferable,
+ null,
+ clipboardService.kGlobalClipboard
+ );
+ } catch (e) {
+ throw new Error("Couldn't set clipboard data due to an internal error: " + e);
+ }
+ return true;
+};
+
+
+exports.get = function(aDataType) {
+ let options = {
+ datatype: aDataType
+ };
+
+ // Figure out the best data type for the clipboard's data, if omitted
+ if (!aDataType) {
+ if (~currentFlavors().indexOf("image"))
+ options.datatype = "image";
+ else
+ options.datatype = "text";
+ }
+
+ options = apiUtils.validateOptions(options, {
+ datatype: {
+ is: ["string"]
+ }
+ });
+
+ var xferable = Cc["@mozilla.org/widget/transferable;1"].
+ createInstance(Ci.nsITransferable);
+ if (!xferable)
+ throw new Error("Couldn't set the clipboard due to an internal error " +
+ "(couldn't create a Transferable object).");
+ // Bug 769440: Starting with FF16, transferable have to be inited
+ if ("init" in xferable)
+ xferable.init(null);
+
+ var flavor = fromJetpackFlavor(options.datatype);
+
+ // Ensure that the user hasn't requested a flavor that we don't support.
+ if (!flavor)
+ throw new Error("Getting the clipboard with the flavor '" + flavor +
+ "' is not supported.");
+
+ // TODO: Check for matching flavor first? Probably not worth it.
+
+ xferable.addDataFlavor(flavor);
+ // Get the data into our transferable.
+ clipboardService.getData(
+ xferable,
+ clipboardService.kGlobalClipboard
+ );
+
+ var data = {};
+ var dataLen = {};
+ try {
+ xferable.getTransferData(flavor, data, dataLen);
+ } catch (e) {
+ // Clipboard doesn't contain data in flavor, return null.
+ return null;
+ }
+
+ // There's no data available, return.
+ if (data.value === null)
+ return null;
+
+ // TODO: Add flavors here as we support more in kAllowableFlavors.
+ switch (flavor) {
+ case "text/unicode":
+ case "text/html":
+ data = data.value.QueryInterface(Ci.nsISupportsString).data;
+ break;
+ case "image/png":
+ let dataURL = new DataURL();
+
+ dataURL.mimeType = flavor;
+ dataURL.base64 = true;
+
+ let image = data.value;
+
+ // Due to the differences in how images could be stored in the clipboard
+ // the checks below are needed. The clipboard could already provide the
+ // image as byte streams, but also as pointer, or as image container.
+ // If it's not possible obtain a byte stream, the function returns `null`.
+ if (image instanceof Ci.nsISupportsInterfacePointer)
+ image = image.data;
+
+ if (image instanceof Ci.imgIContainer)
+ image = imageTools.encodeImage(image, flavor);
+
+ if (image instanceof Ci.nsIInputStream) {
+ let binaryStream = Cc["@mozilla.org/binaryinputstream;1"].
+ createInstance(Ci.nsIBinaryInputStream);
+
+ binaryStream.setInputStream(image);
+
+ dataURL.data = binaryStream.readBytes(binaryStream.available());
+
+ data = dataURL.toString();
+ }
+ else
+ data = null;
+
+ break;
+ default:
+ data = null;
+ }
+
+ return data;
+};
+
+function currentFlavors() {
+ // Loop over kAllowableFlavors, calling hasDataMatchingFlavors for each.
+ // This doesn't seem like the most efficient way, but we can't get
+ // confirmation for specific flavors any other way. This is supposed to be
+ // an inexpensive call, so performance shouldn't be impacted (much).
+ var currentFlavors = [];
+ for (var flavor of kAllowableFlavors) {
+ var matches = clipboardService.hasDataMatchingFlavors(
+ [flavor],
+ 1,
+ clipboardService.kGlobalClipboard
+ );
+ if (matches)
+ currentFlavors.push(toJetpackFlavor(flavor));
+ }
+ return currentFlavors;
+};
+
+Object.defineProperty(exports, "currentFlavors", { get : currentFlavors });
+
+// SUPPORT FUNCTIONS ////////////////////////////////////////////////////////
+
+function toJetpackFlavor(aFlavor) {
+ for (let flavorMap of kFlavorMap)
+ if (flavorMap.long == aFlavor)
+ return flavorMap.short;
+ // Return null in the case where we don't match
+ return null;
+}
+
+function fromJetpackFlavor(aJetpackFlavor) {
+ // TODO: Handle proper flavors better
+ for (let flavorMap of kFlavorMap)
+ if (flavorMap.short == aJetpackFlavor || flavorMap.long == aJetpackFlavor)
+ return flavorMap.long;
+ // Return null in the case where we don't match.
+ return null;
+}
diff --git a/toolkit/jetpack/sdk/console/plain-text.js b/toolkit/jetpack/sdk/console/plain-text.js
new file mode 100644
index 000000000..0e44cf106
--- /dev/null
+++ b/toolkit/jetpack/sdk/console/plain-text.js
@@ -0,0 +1,78 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci, Cu, Cr } = require("chrome");
+const self = require("../self");
+const prefs = require("../preferences/service");
+const { merge } = require("../util/object");
+const { ConsoleAPI } = Cu.import("resource://gre/modules/Console.jsm", {});
+
+const DEFAULT_LOG_LEVEL = "error";
+const ADDON_LOG_LEVEL_PREF = "extensions." + self.id + ".sdk.console.logLevel";
+const SDK_LOG_LEVEL_PREF = "extensions.sdk.console.logLevel";
+
+var logLevel = DEFAULT_LOG_LEVEL;
+function setLogLevel() {
+ logLevel = prefs.get(ADDON_LOG_LEVEL_PREF,
+ prefs.get(SDK_LOG_LEVEL_PREF,
+ DEFAULT_LOG_LEVEL));
+}
+setLogLevel();
+
+var logLevelObserver = {
+ QueryInterface: function(iid) {
+ if (!iid.equals(Ci.nsIObserver) &&
+ !iid.equals(Ci.nsISupportsWeakReference) &&
+ !iid.equals(Ci.nsISupports))
+ throw Cr.NS_ERROR_NO_INTERFACE;
+ return this;
+ },
+ observe: function(subject, topic, data) {
+ setLogLevel();
+ }
+};
+var branch = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefService).
+ getBranch(null);
+branch.addObserver(ADDON_LOG_LEVEL_PREF, logLevelObserver, true);
+branch.addObserver(SDK_LOG_LEVEL_PREF, logLevelObserver, true);
+
+function PlainTextConsole(print, innerID) {
+
+ let consoleOptions = {
+ prefix: self.name,
+ maxLogLevel: logLevel,
+ dump: print,
+ innerID: innerID,
+ consoleID: "addon/" + self.id
+ };
+ let console = new ConsoleAPI(consoleOptions);
+
+ // As we freeze the console object, we can't modify this property afterward
+ Object.defineProperty(console, "maxLogLevel", {
+ get: function() {
+ return logLevel;
+ }
+ });
+
+ // We defined the `__exposedProps__` in our console chrome object.
+ //
+ // Meanwhile we're investigating with the platform team if `__exposedProps__`
+ // are needed, or are just a left-over.
+
+ console.__exposedProps__ = Object.keys(ConsoleAPI.prototype).reduce(function(exposed, prop) {
+ exposed[prop] = "r";
+ return exposed;
+ }, {});
+
+ Object.freeze(console);
+ return console;
+};
+exports.PlainTextConsole = PlainTextConsole;
diff --git a/toolkit/jetpack/sdk/console/traceback.js b/toolkit/jetpack/sdk/console/traceback.js
new file mode 100644
index 000000000..be0fb7b94
--- /dev/null
+++ b/toolkit/jetpack/sdk/console/traceback.js
@@ -0,0 +1,86 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Ci, components } = require("chrome");
+const { parseStack, sourceURI } = require("toolkit/loader");
+const { readURISync } = require("../net/url");
+
+function safeGetFileLine(path, line) {
+ try {
+ var scheme = require("../url").URL(path).scheme;
+ // TODO: There should be an easier, more accurate way to figure out
+ // what's the case here.
+ if (!(scheme == "http" || scheme == "https"))
+ return readURISync(path).split("\n")[line - 1];
+ } catch (e) {}
+ return null;
+}
+
+function nsIStackFramesToJSON(frame) {
+ var stack = [];
+
+ while (frame) {
+ if (frame.filename) {
+ stack.unshift({
+ fileName: sourceURI(frame.filename),
+ lineNumber: frame.lineNumber,
+ name: frame.name
+ });
+ }
+ frame = frame.caller;
+ }
+
+ return stack;
+};
+
+var fromException = exports.fromException = function fromException(e) {
+ if (e instanceof Ci.nsIException)
+ return nsIStackFramesToJSON(e.location);
+ if (e.stack && e.stack.length)
+ return parseStack(e.stack);
+ if (e.fileName && typeof(e.lineNumber == "number"))
+ return [{fileName: sourceURI(e.fileName),
+ lineNumber: e.lineNumber,
+ name: null}];
+ return [];
+};
+
+var get = exports.get = function get() {
+ return nsIStackFramesToJSON(components.stack.caller);
+};
+
+var format = exports.format = function format(tbOrException) {
+ if (tbOrException === undefined) {
+ tbOrException = get();
+ tbOrException.pop();
+ }
+
+ var tb;
+ if (typeof(tbOrException) == "object" &&
+ tbOrException.constructor.name == "Array")
+ tb = tbOrException;
+ else
+ tb = fromException(tbOrException);
+
+ var lines = ["Traceback (most recent call last):"];
+
+ tb.forEach(
+ function(frame) {
+ if (!(frame.fileName || frame.lineNumber || frame.name))
+ return;
+
+ lines.push(' File "' + frame.fileName + '", line ' +
+ frame.lineNumber + ', in ' + frame.name);
+ var sourceLine = safeGetFileLine(frame.fileName, frame.lineNumber);
+ if (sourceLine)
+ lines.push(' ' + sourceLine.trim());
+ });
+
+ return lines.join("\n");
+};
diff --git a/toolkit/jetpack/sdk/content/content-worker.js b/toolkit/jetpack/sdk/content/content-worker.js
new file mode 100644
index 000000000..0a8225733
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/content-worker.js
@@ -0,0 +1,305 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+Object.freeze({
+ // TODO: Bug 727854 Use same implementation than common JS modules,
+ // i.e. EventEmitter module
+
+ /**
+ * Create an EventEmitter instance.
+ */
+ createEventEmitter: function createEventEmitter(emit) {
+ let listeners = Object.create(null);
+ let eventEmitter = Object.freeze({
+ emit: emit,
+ on: function on(name, callback) {
+ if (typeof callback !== "function")
+ return this;
+ if (!(name in listeners))
+ listeners[name] = [];
+ listeners[name].push(callback);
+ return this;
+ },
+ once: function once(name, callback) {
+ eventEmitter.on(name, function onceCallback() {
+ eventEmitter.removeListener(name, onceCallback);
+ callback.apply(callback, arguments);
+ });
+ },
+ removeListener: function removeListener(name, callback) {
+ if (!(name in listeners))
+ return;
+ let index = listeners[name].indexOf(callback);
+ if (index == -1)
+ return;
+ listeners[name].splice(index, 1);
+ }
+ });
+ function onEvent(name) {
+ if (!(name in listeners))
+ return [];
+ let args = Array.slice(arguments, 1);
+ let results = [];
+ for (let callback of listeners[name]) {
+ results.push(callback.apply(null, args));
+ }
+ return results;
+ }
+ return {
+ eventEmitter: eventEmitter,
+ emit: onEvent
+ };
+ },
+
+ /**
+ * Create an EventEmitter instance to communicate with chrome module
+ * by passing only strings between compartments.
+ * This function expects `emitToChrome` function, that allows to send
+ * events to the chrome module. It returns the EventEmitter as `pipe`
+ * attribute, and, `onChromeEvent` a function that allows chrome module
+ * to send event into the EventEmitter.
+ *
+ * pipe.emit --> emitToChrome
+ * onChromeEvent --> callback registered through pipe.on
+ */
+ createPipe: function createPipe(emitToChrome) {
+ let ContentWorker = this;
+ function onEvent(type, ...args) {
+ // JSON.stringify is buggy with cross-sandbox values,
+ // it may return "{}" on functions. Use a replacer to match them correctly.
+ let replacer = (k, v) =>
+ typeof(v) === "function"
+ ? (type === "console" ? Function.toString.call(v) : void(0))
+ : v;
+
+ let str = JSON.stringify([type, ...args], replacer);
+ emitToChrome(str);
+ }
+
+ let { eventEmitter, emit } =
+ ContentWorker.createEventEmitter(onEvent);
+
+ return {
+ pipe: eventEmitter,
+ onChromeEvent: function onChromeEvent(array) {
+ // We either receive a stringified array, or a real array.
+ // We still allow to pass an array of objects, in WorkerSandbox.emitSync
+ // in order to allow sending DOM node reference between content script
+ // and modules (only used for context-menu API)
+ let args = typeof array == "string" ? JSON.parse(array) : array;
+ return emit.apply(null, args);
+ }
+ };
+ },
+
+ injectConsole: function injectConsole(exports, pipe) {
+ exports.console = Object.freeze({
+ log: pipe.emit.bind(null, "console", "log"),
+ info: pipe.emit.bind(null, "console", "info"),
+ warn: pipe.emit.bind(null, "console", "warn"),
+ error: pipe.emit.bind(null, "console", "error"),
+ debug: pipe.emit.bind(null, "console", "debug"),
+ exception: pipe.emit.bind(null, "console", "exception"),
+ trace: pipe.emit.bind(null, "console", "trace"),
+ time: pipe.emit.bind(null, "console", "time"),
+ timeEnd: pipe.emit.bind(null, "console", "timeEnd")
+ });
+ },
+
+ injectTimers: function injectTimers(exports, chromeAPI, pipe, console) {
+ // wrapped functions from `'timer'` module.
+ // Wrapper adds `try catch` blocks to the callbacks in order to
+ // emit `error` event if exception is thrown in
+ // the Worker global scope.
+ // @see http://www.w3.org/TR/workers/#workerutils
+
+ // List of all living timeouts/intervals
+ let _timers = Object.create(null);
+
+ // Keep a reference to original timeout functions
+ let {
+ setTimeout: chromeSetTimeout,
+ setInterval: chromeSetInterval,
+ clearTimeout: chromeClearTimeout,
+ clearInterval: chromeClearInterval
+ } = chromeAPI.timers;
+
+ function registerTimer(timer) {
+ let registerMethod = null;
+ if (timer.kind == "timeout")
+ registerMethod = chromeSetTimeout;
+ else if (timer.kind == "interval")
+ registerMethod = chromeSetInterval;
+ else
+ throw new Error("Unknown timer kind: " + timer.kind);
+
+ if (typeof timer.fun == 'string') {
+ let code = timer.fun;
+ timer.fun = () => chromeAPI.sandbox.evaluate(exports, code);
+ } else if (typeof timer.fun != 'function') {
+ throw new Error('Unsupported callback type' + typeof timer.fun);
+ }
+
+ let id = registerMethod(onFire, timer.delay);
+ function onFire() {
+ try {
+ if (timer.kind == "timeout")
+ delete _timers[id];
+ timer.fun.apply(null, timer.args);
+ } catch(e) {
+ console.exception(e);
+ let wrapper = {
+ instanceOfError: instanceOf(e, Error),
+ value: e,
+ };
+ if (wrapper.instanceOfError) {
+ wrapper.value = {
+ message: e.message,
+ fileName: e.fileName,
+ lineNumber: e.lineNumber,
+ stack: e.stack,
+ name: e.name,
+ };
+ }
+ pipe.emit('error', wrapper);
+ }
+ }
+ _timers[id] = timer;
+ return id;
+ }
+
+ // copied from sdk/lang/type.js since modules are not available here
+ function instanceOf(value, Type) {
+ var isConstructorNameSame;
+ var isConstructorSourceSame;
+
+ // If `instanceof` returned `true` we know result right away.
+ var isInstanceOf = value instanceof Type;
+
+ // If `instanceof` returned `false` we do ducktype check since `Type` may be
+ // from a different sandbox. If a constructor of the `value` or a constructor
+ // of the value's prototype has same name and source we assume that it's an
+ // instance of the Type.
+ if (!isInstanceOf && value) {
+ isConstructorNameSame = value.constructor.name === Type.name;
+ isConstructorSourceSame = String(value.constructor) == String(Type);
+ isInstanceOf = (isConstructorNameSame && isConstructorSourceSame) ||
+ instanceOf(Object.getPrototypeOf(value), Type);
+ }
+ return isInstanceOf;
+ }
+
+ function unregisterTimer(id) {
+ if (!(id in _timers))
+ return;
+ let { kind } = _timers[id];
+ delete _timers[id];
+ if (kind == "timeout")
+ chromeClearTimeout(id);
+ else if (kind == "interval")
+ chromeClearInterval(id);
+ else
+ throw new Error("Unknown timer kind: " + kind);
+ }
+
+ function disableAllTimers() {
+ Object.keys(_timers).forEach(unregisterTimer);
+ }
+
+ exports.setTimeout = function ContentScriptSetTimeout(callback, delay) {
+ return registerTimer({
+ kind: "timeout",
+ fun: callback,
+ delay: delay,
+ args: Array.slice(arguments, 2)
+ });
+ };
+ exports.clearTimeout = function ContentScriptClearTimeout(id) {
+ unregisterTimer(id);
+ };
+
+ exports.setInterval = function ContentScriptSetInterval(callback, delay) {
+ return registerTimer({
+ kind: "interval",
+ fun: callback,
+ delay: delay,
+ args: Array.slice(arguments, 2)
+ });
+ };
+ exports.clearInterval = function ContentScriptClearInterval(id) {
+ unregisterTimer(id);
+ };
+
+ // On page-hide, save a list of all existing timers before disabling them,
+ // in order to be able to restore them on page-show.
+ // These events are fired when the page goes in/out of bfcache.
+ // https://developer.mozilla.org/En/Working_with_BFCache
+ let frozenTimers = [];
+ pipe.on("pageshow", function onPageShow() {
+ frozenTimers.forEach(registerTimer);
+ });
+ pipe.on("pagehide", function onPageHide() {
+ frozenTimers = [];
+ for (let id in _timers)
+ frozenTimers.push(_timers[id]);
+ disableAllTimers();
+ // Some other pagehide listeners may register some timers that won't be
+ // frozen as this particular pagehide listener is called first.
+ // So freeze these timers on next cycle.
+ chromeSetTimeout(function () {
+ for (let id in _timers)
+ frozenTimers.push(_timers[id]);
+ disableAllTimers();
+ }, 0);
+ });
+
+ // Unregister all timers when the page is destroyed
+ // (i.e. when it is removed from bfcache)
+ pipe.on("detach", function clearTimeouts() {
+ disableAllTimers();
+ _timers = {};
+ frozenTimers = [];
+ });
+ },
+
+ injectMessageAPI: function injectMessageAPI(exports, pipe, console) {
+
+ let ContentWorker = this;
+ let { eventEmitter: port, emit : portEmit } =
+ ContentWorker.createEventEmitter(pipe.emit.bind(null, "event"));
+ pipe.on("event", portEmit);
+
+ let self = {
+ port: port,
+ postMessage: pipe.emit.bind(null, "message"),
+ on: pipe.on.bind(null),
+ once: pipe.once.bind(null),
+ removeListener: pipe.removeListener.bind(null),
+ };
+ Object.defineProperty(exports, "self", {
+ value: self
+ });
+ },
+
+ injectOptions: function (exports, options) {
+ Object.defineProperty( exports.self, "options", { value: JSON.parse( options ) });
+ },
+
+ inject: function (exports, chromeAPI, emitToChrome, options) {
+ let ContentWorker = this;
+ let { pipe, onChromeEvent } =
+ ContentWorker.createPipe(emitToChrome);
+
+ ContentWorker.injectConsole(exports, pipe);
+ ContentWorker.injectTimers(exports, chromeAPI, pipe, exports.console);
+ ContentWorker.injectMessageAPI(exports, pipe, exports.console);
+ if ( options !== undefined ) {
+ ContentWorker.injectOptions(exports, options);
+ }
+
+ Object.freeze( exports.self );
+
+ return onChromeEvent;
+ }
+});
diff --git a/toolkit/jetpack/sdk/content/content.js b/toolkit/jetpack/sdk/content/content.js
new file mode 100644
index 000000000..9655223a3
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/content.js
@@ -0,0 +1,17 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "deprecated"
+};
+
+const { deprecateUsage } = require('../util/deprecate');
+
+Object.defineProperty(exports, "Worker", {
+ get: function() {
+ deprecateUsage('`sdk/content/content` is deprecated. Please use `sdk/content/worker` directly.');
+ return require('./worker').Worker;
+ }
+});
diff --git a/toolkit/jetpack/sdk/content/context-menu.js b/toolkit/jetpack/sdk/content/context-menu.js
new file mode 100644
index 000000000..2955e2f09
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/context-menu.js
@@ -0,0 +1,408 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Class } = require("../core/heritage");
+const self = require("../self");
+const { WorkerChild } = require("./worker-child");
+const { getInnerId } = require("../window/utils");
+const { Ci } = require("chrome");
+const { Services } = require("resource://gre/modules/Services.jsm");
+const system = require('../system/events');
+const { process } = require('../remote/child');
+
+// These functions are roughly copied from sdk/selection which doesn't work
+// in the content process
+function getElementWithSelection(window) {
+ let element = Services.focus.getFocusedElementForWindow(window, false, {});
+ if (!element)
+ return null;
+
+ try {
+ // Accessing selectionStart and selectionEnd on e.g. a button
+ // results in an exception thrown as per the HTML5 spec. See
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#textFieldSelection
+
+ let { value, selectionStart, selectionEnd } = element;
+
+ let hasSelection = typeof value === "string" &&
+ !isNaN(selectionStart) &&
+ !isNaN(selectionEnd) &&
+ selectionStart !== selectionEnd;
+
+ return hasSelection ? element : null;
+ }
+ catch (err) {
+ console.exception(err);
+ return null;
+ }
+}
+
+function safeGetRange(selection, rangeNumber) {
+ try {
+ let { rangeCount } = selection;
+ let range = null;
+
+ for (let rangeNumber = 0; rangeNumber < rangeCount; rangeNumber++ ) {
+ range = selection.getRangeAt(rangeNumber);
+
+ if (range && range.toString())
+ break;
+
+ range = null;
+ }
+
+ return range;
+ }
+ catch (e) {
+ return null;
+ }
+}
+
+function getSelection(window) {
+ let selection = window.getSelection();
+ let range = safeGetRange(selection);
+ if (range)
+ return range.toString();
+
+ let node = getElementWithSelection(window);
+ if (!node)
+ return null;
+
+ return node.value.substring(node.selectionStart, node.selectionEnd);
+}
+
+//These are used by PageContext.isCurrent below. If the popupNode or any of
+//its ancestors is one of these, Firefox uses a tailored context menu, and so
+//the page context doesn't apply.
+const NON_PAGE_CONTEXT_ELTS = [
+ Ci.nsIDOMHTMLAnchorElement,
+ Ci.nsIDOMHTMLAppletElement,
+ Ci.nsIDOMHTMLAreaElement,
+ Ci.nsIDOMHTMLButtonElement,
+ Ci.nsIDOMHTMLCanvasElement,
+ Ci.nsIDOMHTMLEmbedElement,
+ Ci.nsIDOMHTMLImageElement,
+ Ci.nsIDOMHTMLInputElement,
+ Ci.nsIDOMHTMLMapElement,
+ Ci.nsIDOMHTMLMediaElement,
+ Ci.nsIDOMHTMLMenuElement,
+ Ci.nsIDOMHTMLObjectElement,
+ Ci.nsIDOMHTMLOptionElement,
+ Ci.nsIDOMHTMLSelectElement,
+ Ci.nsIDOMHTMLTextAreaElement,
+];
+
+// List all editable types of inputs. Or is it better to have a list
+// of non-editable inputs?
+var editableInputs = {
+ email: true,
+ number: true,
+ password: true,
+ search: true,
+ tel: true,
+ text: true,
+ textarea: true,
+ url: true
+};
+
+var CONTEXTS = {};
+
+var Context = Class({
+ initialize: function(id) {
+ this.id = id;
+ },
+
+ adjustPopupNode: function adjustPopupNode(popupNode) {
+ return popupNode;
+ },
+
+ // Gets state to pass through to the parent process for the node the user
+ // clicked on
+ getState: function(popupNode) {
+ return false;
+ }
+});
+
+// Matches when the context-clicked node doesn't have any of
+// NON_PAGE_CONTEXT_ELTS in its ancestors
+CONTEXTS.PageContext = Class({
+ extends: Context,
+
+ getState: function(popupNode) {
+ // If there is a selection in the window then this context does not match
+ if (!popupNode.ownerDocument.defaultView.getSelection().isCollapsed)
+ return false;
+
+ // If the clicked node or any of its ancestors is one of the blocked
+ // NON_PAGE_CONTEXT_ELTS then this context does not match
+ while (!(popupNode instanceof Ci.nsIDOMDocument)) {
+ if (NON_PAGE_CONTEXT_ELTS.some(type => popupNode instanceof type))
+ return false;
+
+ popupNode = popupNode.parentNode;
+ }
+
+ return true;
+ }
+});
+
+// Matches when there is an active selection in the window
+CONTEXTS.SelectionContext = Class({
+ extends: Context,
+
+ getState: function(popupNode) {
+ if (!popupNode.ownerDocument.defaultView.getSelection().isCollapsed)
+ return true;
+
+ try {
+ // The node may be a text box which has selectionStart and selectionEnd
+ // properties. If not this will throw.
+ let { selectionStart, selectionEnd } = popupNode;
+ return !isNaN(selectionStart) && !isNaN(selectionEnd) &&
+ selectionStart !== selectionEnd;
+ }
+ catch (e) {
+ return false;
+ }
+ }
+});
+
+// Matches when the context-clicked node or any of its ancestors matches the
+// selector given
+CONTEXTS.SelectorContext = Class({
+ extends: Context,
+
+ initialize: function initialize(id, selector) {
+ Context.prototype.initialize.call(this, id);
+ this.selector = selector;
+ },
+
+ adjustPopupNode: function adjustPopupNode(popupNode) {
+ let selector = this.selector;
+
+ while (!(popupNode instanceof Ci.nsIDOMDocument)) {
+ if (popupNode.matches(selector))
+ return popupNode;
+
+ popupNode = popupNode.parentNode;
+ }
+
+ return null;
+ },
+
+ getState: function(popupNode) {
+ return !!this.adjustPopupNode(popupNode);
+ }
+});
+
+// Matches when the page url matches any of the patterns given
+CONTEXTS.URLContext = Class({
+ extends: Context,
+
+ getState: function(popupNode) {
+ return popupNode.ownerDocument.URL;
+ }
+});
+
+// Matches when the user-supplied predicate returns true
+CONTEXTS.PredicateContext = Class({
+ extends: Context,
+
+ getState: function(node) {
+ let window = node.ownerDocument.defaultView;
+ let data = {};
+
+ data.documentType = node.ownerDocument.contentType;
+
+ data.documentURL = node.ownerDocument.location.href;
+ data.targetName = node.nodeName.toLowerCase();
+ data.targetID = node.id || null ;
+
+ if ((data.targetName === 'input' && editableInputs[node.type]) ||
+ data.targetName === 'textarea') {
+ data.isEditable = !node.readOnly && !node.disabled;
+ }
+ else {
+ data.isEditable = node.isContentEditable;
+ }
+
+ data.selectionText = getSelection(window, "TEXT");
+
+ data.srcURL = node.src || null;
+ data.value = node.value || null;
+
+ while (!data.linkURL && node) {
+ data.linkURL = node.href || null;
+ node = node.parentNode;
+ }
+
+ return data;
+ },
+});
+
+function instantiateContext({ id, type, args }) {
+ if (!(type in CONTEXTS)) {
+ console.error("Attempt to use unknown context " + type);
+ return;
+ }
+ return new CONTEXTS[type](id, ...args);
+}
+
+var ContextWorker = Class({
+ implements: [ WorkerChild ],
+
+ // Calls the context workers context listeners and returns the first result
+ // that is either a string or a value that evaluates to true. If all of the
+ // listeners returned false then returns false. If there are no listeners,
+ // returns true (show the menu item by default).
+ getMatchedContext: function getCurrentContexts(popupNode) {
+ let results = this.sandbox.emitSync("context", popupNode);
+ if (!results.length)
+ return true;
+ return results.reduce((val, result) => val || result);
+ },
+
+ // Emits a click event in the worker's port. popupNode is the node that was
+ // context-clicked, and clickedItemData is the data of the item that was
+ // clicked.
+ fireClick: function fireClick(popupNode, clickedItemData) {
+ this.sandbox.emitSync("click", popupNode, clickedItemData);
+ }
+});
+
+// Gets the item's content script worker for a window, creating one if necessary
+// Once created it will be automatically destroyed when the window unloads.
+// If there is not content scripts for the item then null will be returned.
+function getItemWorkerForWindow(item, window) {
+ if (!item.contentScript && !item.contentScriptFile)
+ return null;
+
+ let id = getInnerId(window);
+ let worker = item.workerMap.get(id);
+
+ if (worker)
+ return worker;
+
+ worker = ContextWorker({
+ id: item.id,
+ window,
+ manager: item.manager,
+ contentScript: item.contentScript,
+ contentScriptFile: item.contentScriptFile,
+ onDetach: function() {
+ item.workerMap.delete(id);
+ }
+ });
+
+ item.workerMap.set(id, worker);
+
+ return worker;
+}
+
+// A very simple remote proxy for every item. It's job is to provide data for
+// the main process to use to determine visibility state and to call into
+// content scripts when clicked.
+var RemoteItem = Class({
+ initialize: function(options, manager) {
+ this.id = options.id;
+ this.contexts = options.contexts.map(instantiateContext);
+ this.contentScript = options.contentScript;
+ this.contentScriptFile = options.contentScriptFile;
+
+ this.manager = manager;
+
+ this.workerMap = new Map();
+ keepAlive.set(this.id, this);
+ },
+
+ destroy: function() {
+ for (let worker of this.workerMap.values()) {
+ worker.destroy();
+ }
+ keepAlive.delete(this.id);
+ },
+
+ activate: function(popupNode, data) {
+ let worker = getItemWorkerForWindow(this, popupNode.ownerDocument.defaultView);
+ if (!worker)
+ return;
+
+ for (let context of this.contexts)
+ popupNode = context.adjustPopupNode(popupNode);
+
+ worker.fireClick(popupNode, data);
+ },
+
+ // Fills addonInfo with state data to send through to the main process
+ getContextState: function(popupNode, addonInfo) {
+ if (!(self.id in addonInfo)) {
+ addonInfo[self.id] = {
+ processID: process.id,
+ items: {}
+ };
+ }
+
+ let worker = getItemWorkerForWindow(this, popupNode.ownerDocument.defaultView);
+ let contextStates = {};
+ for (let context of this.contexts)
+ contextStates[context.id] = context.getState(popupNode);
+
+ addonInfo[self.id].items[this.id] = {
+ // It isn't ideal to create a PageContext for every item but there isn't
+ // a good shared place to do it.
+ pageContext: (new CONTEXTS.PageContext()).getState(popupNode),
+ contextStates,
+ hasWorker: !!worker,
+ workerContext: worker ? worker.getMatchedContext(popupNode) : true
+ }
+ }
+});
+exports.RemoteItem = RemoteItem;
+
+// Holds remote items for this frame.
+var keepAlive = new Map();
+
+// Called to create remote proxies for items. If they already exist we destroy
+// and recreate. This can happen if the item changes in some way or in odd
+// timing cases where the frame script is create around the same time as the
+// item is created in the main process
+process.port.on('sdk/contextmenu/createitems', (process, items) => {
+ for (let itemoptions of items) {
+ let oldItem = keepAlive.get(itemoptions.id);
+ if (oldItem) {
+ oldItem.destroy();
+ }
+
+ let item = new RemoteItem(itemoptions, this);
+ }
+});
+
+process.port.on('sdk/contextmenu/destroyitems', (process, items) => {
+ for (let id of items) {
+ let item = keepAlive.get(id);
+ item.destroy();
+ }
+});
+
+var lastPopupNode = null;
+
+system.on('content-contextmenu', ({ subject }) => {
+ let { event: { target: popupNode }, addonInfo } = subject.wrappedJSObject;
+ lastPopupNode = popupNode;
+
+ for (let item of keepAlive.values()) {
+ item.getContextState(popupNode, addonInfo);
+ }
+}, true);
+
+process.port.on('sdk/contextmenu/activateitems', (process, items, data) => {
+ for (let id of items) {
+ let item = keepAlive.get(id);
+ if (!item)
+ continue;
+
+ item.activate(lastPopupNode, data);
+ }
+});
diff --git a/toolkit/jetpack/sdk/content/events.js b/toolkit/jetpack/sdk/content/events.js
new file mode 100644
index 000000000..c085b6179
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/events.js
@@ -0,0 +1,57 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Ci } = require("chrome");
+const { open } = require("../event/dom");
+const { observe } = require("../event/chrome");
+const { filter, merge, map, expand } = require("../event/utils");
+const { windows } = require("../window/utils");
+const { events: windowEvents } = require("sdk/window/events");
+
+// Note: Please note that even though pagehide event is included
+// it's not observable reliably since it's not always triggered
+// when closing tabs. Implementation can be imrpoved once that
+// event will be necessary.
+var TYPES = ["DOMContentLoaded", "load", "pageshow", "pagehide"];
+
+var insert = observe("document-element-inserted");
+var windowCreate = merge([
+ observe("content-document-global-created"),
+ observe("chrome-document-global-created")
+]);
+var create = map(windowCreate, function({target, data, type}) {
+ return { target: target.document, type: type, data: data }
+});
+
+function streamEventsFrom({document}) {
+ // Map supported event types to a streams of those events on the given
+ // `window` for the inserted document and than merge these streams into
+ // single form stream off all window state change events.
+ let stateChanges = TYPES.map(function(type) {
+ return open(document, type, { capture: true });
+ });
+
+ // Since load events on document occur for every loded resource
+ return filter(merge(stateChanges), function({target}) {
+ return target instanceof Ci.nsIDOMDocument
+ })
+}
+exports.streamEventsFrom = streamEventsFrom;
+
+var opened = windows(null, { includePrivate: true });
+var state = merge(opened.map(streamEventsFrom));
+
+
+var futureReady = filter(windowEvents, ({type}) =>
+ type === "DOMContentLoaded");
+var futureWindows = map(futureReady, ({target}) => target);
+var futureState = expand(futureWindows, streamEventsFrom);
+
+exports.events = merge([insert, create, state, futureState]);
diff --git a/toolkit/jetpack/sdk/content/l10n-html.js b/toolkit/jetpack/sdk/content/l10n-html.js
new file mode 100644
index 000000000..f324623dc
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/l10n-html.js
@@ -0,0 +1,133 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Ci, Cc, Cu } = require("chrome");
+const core = require("../l10n/core");
+const { loadSheet, removeSheet } = require("../stylesheet/utils");
+const { process, frames } = require("../remote/child");
+var observerService = Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService);
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+const addObserver = ShimWaiver.getProperty(observerService, "addObserver");
+const removeObserver = ShimWaiver.getProperty(observerService, "removeObserver");
+
+const assetsURI = require('../self').data.url();
+
+const hideSheetUri = "data:text/css,:root {visibility: hidden !important;}";
+
+function translateElementAttributes(element) {
+ // Translateable attributes
+ const attrList = ['title', 'accesskey', 'alt', 'label', 'placeholder'];
+ const ariaAttrMap = {
+ 'ariaLabel': 'aria-label',
+ 'ariaValueText': 'aria-valuetext',
+ 'ariaMozHint': 'aria-moz-hint'
+ };
+ const attrSeparator = '.';
+
+ // Try to translate each of the attributes
+ for (let attribute of attrList) {
+ const data = core.get(element.dataset.l10nId + attrSeparator + attribute);
+ if (data)
+ element.setAttribute(attribute, data);
+ }
+
+ // Look for the aria attribute translations that match fxOS's aliases
+ for (let attrAlias in ariaAttrMap) {
+ const data = core.get(element.dataset.l10nId + attrSeparator + attrAlias);
+ if (data)
+ element.setAttribute(ariaAttrMap[attrAlias], data);
+ }
+}
+
+// Taken from Gaia:
+// https://github.com/andreasgal/gaia/blob/04fde2640a7f40314643016a5a6c98bf3755f5fd/webapi.js#L1470
+function translateElement(element) {
+ element = element || document;
+
+ // check all translatable children (= w/ a `data-l10n-id' attribute)
+ var children = element.querySelectorAll('*[data-l10n-id]');
+ var elementCount = children.length;
+ for (var i = 0; i < elementCount; i++) {
+ var child = children[i];
+
+ // translate the child
+ var key = child.dataset.l10nId;
+ var data = core.get(key);
+ if (data)
+ child.textContent = data;
+
+ translateElementAttributes(child);
+ }
+}
+exports.translateElement = translateElement;
+
+function onDocumentReady2Translate(event) {
+ let document = event.target;
+ document.removeEventListener("DOMContentLoaded", onDocumentReady2Translate,
+ false);
+
+ translateElement(document);
+
+ try {
+ // Finally display document when we finished replacing all text content
+ if (document.defaultView)
+ removeSheet(document.defaultView, hideSheetUri, 'user');
+ }
+ catch(e) {
+ console.exception(e);
+ }
+}
+
+function onContentWindow(document) {
+ // Accept only HTML documents
+ if (!(document instanceof Ci.nsIDOMHTMLDocument))
+ return;
+
+ // Bug 769483: data:URI documents instanciated with nsIDOMParser
+ // have a null `location` attribute at this time
+ if (!document.location)
+ return;
+
+ // Accept only document from this addon
+ if (document.location.href.indexOf(assetsURI) !== 0)
+ return;
+
+ try {
+ // First hide content of the document in order to have content blinking
+ // between untranslated and translated states
+ loadSheet(document.defaultView, hideSheetUri, 'user');
+ }
+ catch(e) {
+ console.exception(e);
+ }
+ // Wait for DOM tree to be built before applying localization
+ document.addEventListener("DOMContentLoaded", onDocumentReady2Translate,
+ false);
+}
+
+// Listen to creation of content documents in order to translate them as soon
+// as possible in their loading process
+const ON_CONTENT = "document-element-inserted";
+let enabled = false;
+function enable() {
+ if (enabled)
+ return;
+ addObserver(onContentWindow, ON_CONTENT, false);
+ enabled = true;
+}
+process.port.on("sdk/l10n/html/enable", enable);
+
+function disable() {
+ if (!enabled)
+ return;
+ removeObserver(onContentWindow, ON_CONTENT);
+ enabled = false;
+}
+process.port.on("sdk/l10n/html/disable", disable);
diff --git a/toolkit/jetpack/sdk/content/loader.js b/toolkit/jetpack/sdk/content/loader.js
new file mode 100644
index 000000000..e4f0dd2aa
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/loader.js
@@ -0,0 +1,74 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { isValidURI, isLocalURL, URL } = require('../url');
+const { contract } = require('../util/contract');
+const { isString, isNil, instanceOf, isJSONable } = require('../lang/type');
+const { validateOptions,
+ string, array, object, either, required } = require('../deprecated/api-utils');
+
+const isValidScriptFile = (value) =>
+ (isString(value) || instanceOf(value, URL)) && isLocalURL(value);
+
+// map of property validations
+const valid = {
+ contentURL: {
+ is: either(string, object),
+ ok: url => isNil(url) || isLocalURL(url) || isValidURI(url),
+ msg: 'The `contentURL` option must be a valid URL.'
+ },
+ contentScriptFile: {
+ is: either(string, object, array),
+ ok: value => isNil(value) || [].concat(value).every(isValidScriptFile),
+ msg: 'The `contentScriptFile` option must be a local URL or an array of URLs.'
+ },
+ contentScript: {
+ is: either(string, array),
+ ok: value => isNil(value) || [].concat(value).every(isString),
+ msg: 'The `contentScript` option must be a string or an array of strings.'
+ },
+ contentScriptWhen: {
+ is: required(string),
+ map: value => value || 'end',
+ ok: value => ~['start', 'ready', 'end'].indexOf(value),
+ msg: 'The `contentScriptWhen` option must be either "start", "ready" or "end".'
+ },
+ contentScriptOptions: {
+ ok: value => isNil(value) || isJSONable(value),
+ msg: 'The contentScriptOptions should be a jsonable value.'
+ }
+};
+exports.validationAttributes = valid;
+
+/**
+ * Shortcut function to validate property with validation.
+ * @param {Object|Number|String} suspect
+ * value to validate
+ * @param {Object} validation
+ * validation rule passed to `api-utils`
+ */
+function validate(suspect, validation) {
+ return validateOptions(
+ { $: suspect },
+ { $: validation }
+ ).$;
+}
+
+function Allow(script) {
+ return {
+ get script() {
+ return script;
+ },
+ set script(value) {
+ script = !!value;
+ }
+ };
+}
+
+exports.contract = contract(valid);
diff --git a/toolkit/jetpack/sdk/content/mod.js b/toolkit/jetpack/sdk/content/mod.js
new file mode 100644
index 000000000..81fe9ee42
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/mod.js
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Ci } = require("chrome");
+const { dispatcher } = require("../util/dispatcher");
+const { add, remove, iterator } = require("../lang/weak-set");
+
+var getTargetWindow = dispatcher("getTargetWindow");
+
+getTargetWindow.define(function (target) {
+ if (target instanceof Ci.nsIDOMWindow)
+ return target;
+ if (target instanceof Ci.nsIDOMDocument)
+ return target.defaultView || null;
+
+ return null;
+});
+
+exports.getTargetWindow = getTargetWindow;
+
+var attachTo = dispatcher("attachTo");
+exports.attachTo = attachTo;
+
+var detachFrom = dispatcher("detatchFrom");
+exports.detachFrom = detachFrom;
+
+function attach(modification, target) {
+ if (!modification)
+ return;
+
+ let window = getTargetWindow(target);
+
+ attachTo(modification, window);
+
+ // modification are stored per content; `window` reference can still be the
+ // same even if the content is changed, therefore `document` is used instead.
+ add(modification, window.document);
+}
+exports.attach = attach;
+
+function detach(modification, target) {
+ if (!modification)
+ return;
+
+ if (target) {
+ let window = getTargetWindow(target);
+ detachFrom(modification, window);
+ remove(modification, window.document);
+ }
+ else {
+ let documents = iterator(modification);
+ for (let document of documents) {
+ let window = document.defaultView;
+ // The window might have already gone away
+ if (!window)
+ continue;
+ detachFrom(modification, document.defaultView);
+ remove(modification, document);
+ }
+ }
+}
+exports.detach = detach;
diff --git a/toolkit/jetpack/sdk/content/page-mod.js b/toolkit/jetpack/sdk/content/page-mod.js
new file mode 100644
index 000000000..8ff9b1e7b
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/page-mod.js
@@ -0,0 +1,236 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { getAttachEventType } = require('../content/utils');
+const { Class } = require('../core/heritage');
+const { Disposable } = require('../core/disposable');
+const { WeakReference } = require('../core/reference');
+const { WorkerChild } = require('./worker-child');
+const { EventTarget } = require('../event/target');
+const { on, emit, once, setListeners } = require('../event/core');
+const { on: domOn, removeListener: domOff } = require('../dom/events');
+const { isRegExp, isUndefined } = require('../lang/type');
+const { merge } = require('../util/object');
+const { isBrowser, getFrames } = require('../window/utils');
+const { getTabs, getURI: getTabURI } = require('../tabs/utils');
+const { ignoreWindow } = require('../private-browsing/utils');
+const { Style } = require("../stylesheet/style");
+const { attach, detach } = require("../content/mod");
+const { has, hasAny } = require("../util/array");
+const { Rules } = require("../util/rules");
+const { List, addListItem, removeListItem } = require('../util/list');
+const { when } = require("../system/unload");
+const { uuid } = require('../util/uuid');
+const { frames, process } = require('../remote/child');
+
+const pagemods = new Map();
+const styles = new WeakMap();
+var styleFor = (mod) => styles.get(mod);
+
+// Helper functions
+var modMatchesURI = (mod, uri) => mod.include.matchesAny(uri) && !mod.exclude.matchesAny(uri);
+
+/**
+ * PageMod constructor (exported below).
+ * @constructor
+ */
+const ChildPageMod = Class({
+ implements: [
+ EventTarget,
+ Disposable,
+ ],
+ setup: function PageMod(model) {
+ merge(this, model);
+
+ // Set listeners on {PageMod} itself, not the underlying worker,
+ // like `onMessage`, as it'll get piped.
+ setListeners(this, model);
+
+ function deserializeRules(rules) {
+ for (let rule of rules) {
+ yield rule.type == "string" ? rule.value
+ : new RegExp(rule.pattern, rule.flags);
+ }
+ }
+
+ let include = [...deserializeRules(this.include)];
+ this.include = Rules();
+ this.include.add.apply(this.include, include);
+
+ let exclude = [...deserializeRules(this.exclude)];
+ this.exclude = Rules();
+ this.exclude.add.apply(this.exclude, exclude);
+
+ if (this.contentStyle || this.contentStyleFile) {
+ styles.set(this, Style({
+ uri: this.contentStyleFile,
+ source: this.contentStyle
+ }));
+ }
+
+ pagemods.set(this.id, this);
+ this.seenDocuments = new WeakMap();
+
+ // `applyOnExistingDocuments` has to be called after `pagemods.add()`
+ // otherwise its calls to `onContent` method won't do anything.
+ if (has(this.attachTo, 'existing'))
+ applyOnExistingDocuments(this);
+ },
+
+ dispose: function() {
+ let style = styleFor(this);
+ if (style)
+ detach(style);
+
+ for (let i in this.include)
+ this.include.remove(this.include[i]);
+
+ pagemods.delete(this.id);
+ }
+});
+
+function onContentWindow({ target: document }) {
+ // Return if we have no pagemods
+ if (pagemods.size === 0)
+ return;
+
+ let window = document.defaultView;
+ // XML documents don't have windows, and we don't yet support them.
+ if (!window)
+ return;
+
+ // Frame event listeners are bound to the frame the event came from by default
+ let frame = this;
+ // We apply only on documents in tabs of Firefox
+ if (!frame.isTab)
+ return;
+
+ // When the tab is private, only addons with 'private-browsing' flag in
+ // their package.json can apply content script to private documents
+ if (ignoreWindow(window))
+ return;
+
+ for (let pagemod of pagemods.values()) {
+ if (modMatchesURI(pagemod, window.location.href))
+ onContent(pagemod, window);
+ }
+}
+frames.addEventListener("DOMDocElementInserted", onContentWindow, true);
+
+function applyOnExistingDocuments (mod) {
+ for (let frame of frames) {
+ // Fake a newly created document
+ let window = frame.content;
+ // on startup with e10s, contentWindow might not exist yet,
+ // in which case we will get notified by "document-element-inserted".
+ if (!window || !window.frames)
+ return;
+ let uri = window.location.href;
+ if (has(mod.attachTo, "top") && modMatchesURI(mod, uri))
+ onContent(mod, window);
+ if (has(mod.attachTo, "frame"))
+ getFrames(window).
+ filter(iframe => modMatchesURI(mod, iframe.location.href)).
+ forEach(frame => onContent(mod, frame));
+ }
+}
+
+function createWorker(mod, window) {
+ let workerId = String(uuid());
+
+ // Instruct the parent to connect to this worker. Do this first so the parent
+ // side is connected before the worker attempts to send any messages there
+ let frame = frames.getFrameForWindow(window.top);
+ frame.port.emit('sdk/page-mod/worker-create', mod.id, {
+ id: workerId,
+ url: window.location.href
+ });
+
+ // Create a child worker and notify the parent
+ let worker = WorkerChild({
+ id: workerId,
+ window: window,
+ contentScript: mod.contentScript,
+ contentScriptFile: mod.contentScriptFile,
+ contentScriptOptions: mod.contentScriptOptions
+ });
+
+ once(worker, 'detach', () => worker.destroy());
+}
+
+function onContent (mod, window) {
+ let isTopDocument = window.top === window;
+ // Is a top level document and `top` is not set, ignore
+ if (isTopDocument && !has(mod.attachTo, "top"))
+ return;
+ // Is a frame document and `frame` is not set, ignore
+ if (!isTopDocument && !has(mod.attachTo, "frame"))
+ return;
+
+ // ensure we attach only once per document
+ let seen = mod.seenDocuments;
+ if (seen.has(window.document))
+ return;
+ seen.set(window.document, true);
+
+ let style = styleFor(mod);
+ if (style)
+ attach(style, window);
+
+ // Immediately evaluate content script if the document state is already
+ // matching contentScriptWhen expectations
+ if (isMatchingAttachState(mod, window)) {
+ createWorker(mod, window);
+ return;
+ }
+
+ let eventName = getAttachEventType(mod) || 'load';
+ domOn(window, eventName, function onReady (e) {
+ if (e.target.defaultView !== window)
+ return;
+ domOff(window, eventName, onReady, true);
+ createWorker(mod, window);
+
+ // Attaching is asynchronous so if the document is already loaded we will
+ // miss the pageshow event so send a synthetic one.
+ if (window.document.readyState == "complete") {
+ mod.on('attach', worker => {
+ try {
+ worker.send('pageshow');
+ emit(worker, 'pageshow');
+ }
+ catch (e) {
+ // This can fail if an earlier attach listener destroyed the worker
+ }
+ });
+ }
+ }, true);
+}
+
+function isMatchingAttachState (mod, window) {
+ let state = window.document.readyState;
+ return 'start' === mod.contentScriptWhen ||
+ // Is `load` event already dispatched?
+ 'complete' === state ||
+ // Is DOMContentLoaded already dispatched and waiting for it?
+ ('ready' === mod.contentScriptWhen && state === 'interactive')
+}
+
+process.port.on('sdk/page-mod/create', (process, model) => {
+ if (pagemods.has(model.id))
+ return;
+
+ new ChildPageMod(model);
+});
+
+process.port.on('sdk/page-mod/destroy', (process, id) => {
+ let mod = pagemods.get(id);
+ if (mod)
+ mod.destroy();
+});
diff --git a/toolkit/jetpack/sdk/content/page-worker.js b/toolkit/jetpack/sdk/content/page-worker.js
new file mode 100644
index 000000000..e9e741120
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/page-worker.js
@@ -0,0 +1,154 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { frames } = require("../remote/child");
+const { Class } = require("../core/heritage");
+const { Disposable } = require('../core/disposable');
+const { data } = require("../self");
+const { once } = require("../dom/events");
+const { getAttachEventType } = require("./utils");
+const { Rules } = require('../util/rules');
+const { uuid } = require('../util/uuid');
+const { WorkerChild } = require("./worker-child");
+const { Cc, Ci, Cu } = require("chrome");
+const { observe } = require("../event/chrome");
+const { on } = require("../event/core");
+
+const appShell = Cc["@mozilla.org/appshell/appShellService;1"].getService(Ci.nsIAppShellService);
+
+const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
+
+const pages = new Map();
+
+const DOC_INSERTED = "document-element-inserted";
+
+function isValidURL(page, url) {
+ return !page.rules || page.rules.matchesAny(url);
+}
+
+const ChildPage = Class({
+ implements: [ Disposable ],
+ setup: function(frame, id, options) {
+ this.id = id;
+ this.frame = frame;
+ this.options = options;
+
+ this.webNav = appShell.createWindowlessBrowser(false);
+ this.docShell.allowJavascript = this.options.allow.script;
+
+ // Accessing the browser's window forces the initial about:blank document to
+ // be created before we start listening for notifications
+ this.contentWindow;
+
+ this.webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_LOCATION);
+
+ pages.set(this.id, this);
+
+ this.contentURL = options.contentURL;
+
+ if (options.include) {
+ this.rules = Rules();
+ this.rules.add.apply(this.rules, [].concat(options.include));
+ }
+ },
+
+ dispose: function() {
+ pages.delete(this.id);
+ this.webProgress.removeProgressListener(this);
+ this.webNav.close();
+ this.webNav = null;
+ },
+
+ attachWorker: function() {
+ if (!isValidURL(this, this.contentWindow.location.href))
+ return;
+
+ this.options.id = uuid().toString();
+ this.options.window = this.contentWindow;
+ this.frame.port.emit("sdk/frame/connect", this.id, {
+ id: this.options.id,
+ url: this.contentWindow.document.documentURIObject.spec
+ });
+ new WorkerChild(this.options);
+ },
+
+ get docShell() {
+ return this.webNav.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDocShell);
+ },
+
+ get webProgress() {
+ return this.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebProgress);
+ },
+
+ get contentWindow() {
+ return this.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindow);
+ },
+
+ get contentURL() {
+ return this.options.contentURL;
+ },
+ set contentURL(url) {
+ this.options.contentURL = url;
+
+ url = this.options.contentURL ? data.url(this.options.contentURL) : "about:blank";
+ this.webNav.loadURI(url, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
+ },
+
+ onLocationChange: function(progress, request, location, flags) {
+ // Ignore inner-frame events
+ if (progress != this.webProgress)
+ return;
+ // Ignore events that don't change the document
+ if (flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT)
+ return;
+
+ let event = getAttachEventType(this.options);
+ // Attaching at the start of the load is handled by the
+ // document-element-inserted listener.
+ if (event == DOC_INSERTED)
+ return;
+
+ once(this.contentWindow, event, () => {
+ this.attachWorker();
+ }, false);
+ },
+
+ QueryInterface: XPCOMUtils.generateQI(["nsIWebProgressListener", "nsISupportsWeakReference"])
+});
+
+on(observe(DOC_INSERTED), "data", ({ target }) => {
+ let page = Array.from(pages.values()).find(p => p.contentWindow.document === target);
+ if (!page)
+ return;
+
+ if (getAttachEventType(page.options) == DOC_INSERTED)
+ page.attachWorker();
+});
+
+frames.port.on("sdk/frame/create", (frame, id, options) => {
+ new ChildPage(frame, id, options);
+});
+
+frames.port.on("sdk/frame/set", (frame, id, params) => {
+ let page = pages.get(id);
+ if (!page)
+ return;
+
+ if ("allowScript" in params)
+ page.docShell.allowJavascript = params.allowScript;
+ if ("contentURL" in params)
+ page.contentURL = params.contentURL;
+});
+
+frames.port.on("sdk/frame/destroy", (frame, id) => {
+ let page = pages.get(id);
+ if (!page)
+ return;
+
+ page.destroy();
+});
diff --git a/toolkit/jetpack/sdk/content/sandbox.js b/toolkit/jetpack/sdk/content/sandbox.js
new file mode 100644
index 000000000..096ba5c87
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/sandbox.js
@@ -0,0 +1,426 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+const { Class } = require('../core/heritage');
+const { EventTarget } = require('../event/target');
+const { on, off, emit } = require('../event/core');
+const { events } = require('./sandbox/events');
+const { requiresAddonGlobal } = require('./utils');
+const { delay: async } = require('../lang/functional');
+const { Ci, Cu, Cc } = require('chrome');
+const timer = require('../timers');
+const { URL } = require('../url');
+const { sandbox, evaluate, load } = require('../loader/sandbox');
+const { merge } = require('../util/object');
+const { getTabForContentWindowNoShim } = require('../tabs/utils');
+const { getInnerId } = require('../window/utils');
+const { PlainTextConsole } = require('../console/plain-text');
+const { data } = require('../self');const { isChildLoader } = require('../remote/core');
+// WeakMap of sandboxes so we can access private values
+const sandboxes = new WeakMap();
+
+/* Trick the linker in order to ensure shipping these files in the XPI.
+ require('./content-worker.js');
+ Then, retrieve URL of these files in the XPI:
+*/
+var prefix = module.uri.split('sandbox.js')[0];
+const CONTENT_WORKER_URL = prefix + 'content-worker.js';
+const metadata = require('@loader/options').metadata;
+
+// Fetch additional list of domains to authorize access to for each content
+// script. It is stored in manifest `metadata` field which contains
+// package.json data. This list is originaly defined by authors in
+// `permissions` attribute of their package.json addon file.
+const permissions = (metadata && metadata['permissions']) || {};
+const EXPANDED_PRINCIPALS = permissions['cross-domain-content'] || [];
+
+const waiveSecurityMembrane = !!permissions['unsafe-content-script'];
+
+const nsIScriptSecurityManager = Ci.nsIScriptSecurityManager;
+const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].
+ getService(Ci.nsIScriptSecurityManager);
+
+const JS_VERSION = '1.8';
+
+// Tests whether this window is loaded in a tab
+function isWindowInTab(window) {
+ if (isChildLoader) {
+ let { frames } = require('../remote/child');
+ let frame = frames.getFrameForWindow(window.top);
+ return frame && frame.isTab;
+ }
+ else {
+ // The deprecated sync worker API still does everything in the main process
+ return getTabForContentWindowNoShim(window);
+ }
+}
+
+const WorkerSandbox = Class({
+ implements: [ EventTarget ],
+
+ /**
+ * Emit a message to the worker content sandbox
+ */
+ emit: function emit(type, ...args) {
+ // JSON.stringify is buggy with cross-sandbox values,
+ // it may return "{}" on functions. Use a replacer to match them correctly.
+ let replacer = (k, v) =>
+ typeof(v) === "function"
+ ? (type === "console" ? Function.toString.call(v) : void(0))
+ : v;
+
+ // Ensure having an asynchronous behavior
+ async(() =>
+ emitToContent(this, JSON.stringify([type, ...args], replacer))
+ );
+ },
+
+ /**
+ * Synchronous version of `emit`.
+ * /!\ Should only be used when it is strictly mandatory /!\
+ * Doesn't ensure passing only JSON values.
+ * Mainly used by context-menu in order to avoid breaking it.
+ */
+ emitSync: function emitSync(...args) {
+ // because the arguments could be also non JSONable values,
+ // we need to ensure the array instance is created from
+ // the content's sandbox
+ return emitToContent(this, new modelFor(this).sandbox.Array(...args));
+ },
+
+ /**
+ * Configures sandbox and loads content scripts into it.
+ * @param {Worker} worker
+ * content worker
+ */
+ initialize: function WorkerSandbox(worker, window) {
+ let model = {};
+ sandboxes.set(this, model);
+ model.worker = worker;
+ // We receive a wrapped window, that may be an xraywrapper if it's content
+ let proto = window;
+
+ // TODO necessary?
+ // Ensure that `emit` has always the right `this`
+ this.emit = this.emit.bind(this);
+ this.emitSync = this.emitSync.bind(this);
+
+ // Use expanded principal for content-script if the content is a
+ // regular web content for better isolation.
+ // (This behavior can be turned off for now with the unsafe-content-script
+ // flag to give addon developers time for making the necessary changes)
+ // But prevent it when the Worker isn't used for a content script but for
+ // injecting `addon` object into a Panel scope, for example.
+ // That's because:
+ // 1/ It is useless to use multiple domains as the worker is only used
+ // to communicate with the addon,
+ // 2/ By using it it would prevent the document to have access to any JS
+ // value of the worker. As JS values coming from multiple domain principals
+ // can't be accessed by 'mono-principals' (principal with only one domain).
+ // Even if this principal is for a domain that is specified in the multiple
+ // domain principal.
+ let principals = window;
+ let wantGlobalProperties = [];
+ let isSystemPrincipal = secMan.isSystemPrincipal(
+ window.document.nodePrincipal);
+ if (!isSystemPrincipal && !requiresAddonGlobal(worker)) {
+ if (EXPANDED_PRINCIPALS.length > 0) {
+ // We have to replace XHR constructor of the content document
+ // with a custom cross origin one, automagically added by platform code:
+ delete proto.XMLHttpRequest;
+ wantGlobalProperties.push('XMLHttpRequest');
+ }
+ if (!waiveSecurityMembrane)
+ principals = EXPANDED_PRINCIPALS.concat(window);
+ }
+
+ // Create the sandbox and bind it to window in order for content scripts to
+ // have access to all standard globals (window, document, ...)
+ let content = sandbox(principals, {
+ sandboxPrototype: proto,
+ wantXrays: !requiresAddonGlobal(worker),
+ wantGlobalProperties: wantGlobalProperties,
+ wantExportHelpers: true,
+ sameZoneAs: window,
+ metadata: {
+ SDKContentScript: true,
+ 'inner-window-id': getInnerId(window)
+ }
+ });
+ model.sandbox = content;
+
+ // We have to ensure that window.top and window.parent are the exact same
+ // object than window object, i.e. the sandbox global object. But not
+ // always, in case of iframes, top and parent are another window object.
+ let top = window.top === window ? content : content.top;
+ let parent = window.parent === window ? content : content.parent;
+ merge(content, {
+ // We need 'this === window === top' to be true in toplevel scope:
+ get window() {
+ return content;
+ },
+ get top() {
+ return top;
+ },
+ get parent() {
+ return parent;
+ }
+ });
+
+ // Use the Greasemonkey naming convention to provide access to the
+ // unwrapped window object so the content script can access document
+ // JavaScript values.
+ // NOTE: this functionality is experimental and may change or go away
+ // at any time!
+ //
+ // Note that because waivers aren't propagated between origins, we
+ // need the unsafeWindow getter to live in the sandbox.
+ var unsafeWindowGetter =
+ new content.Function('return window.wrappedJSObject || window;');
+ Object.defineProperty(content, 'unsafeWindow', {get: unsafeWindowGetter});
+
+ // Load trusted code that will inject content script API.
+ let ContentWorker = load(content, CONTENT_WORKER_URL);
+
+ // prepare a clean `self.options`
+ let options = 'contentScriptOptions' in worker ?
+ JSON.stringify(worker.contentScriptOptions) :
+ undefined;
+
+ // Then call `inject` method and communicate with this script
+ // by trading two methods that allow to send events to the other side:
+ // - `onEvent` called by content script
+ // - `result.emitToContent` called by addon script
+ let onEvent = Cu.exportFunction(onContentEvent.bind(null, this), ContentWorker);
+ let chromeAPI = createChromeAPI(ContentWorker);
+ let result = Cu.waiveXrays(ContentWorker).inject(content, chromeAPI, onEvent, options);
+
+ // Merge `emitToContent` into our private model of the
+ // WorkerSandbox so we can communicate with content script
+ model.emitToContent = result;
+
+ let console = new PlainTextConsole(null, getInnerId(window));
+
+ // Handle messages send by this script:
+ setListeners(this, console);
+
+ // Inject `addon` global into target document if document is trusted,
+ // `addon` in document is equivalent to `self` in content script.
+ if (requiresAddonGlobal(worker)) {
+ Object.defineProperty(getUnsafeWindow(window), 'addon', {
+ value: content.self,
+ configurable: true
+ }
+ );
+ }
+
+ // Inject our `console` into target document if worker doesn't have a tab
+ // (e.g Panel, PageWorker).
+ // `worker.tab` can't be used because bug 804935.
+ if (!isWindowInTab(window)) {
+ let win = getUnsafeWindow(window);
+
+ // export our chrome console to content window, as described here:
+ // https://developer.mozilla.org/en-US/docs/Components.utils.createObjectIn
+ let con = Cu.createObjectIn(win);
+
+ let genPropDesc = function genPropDesc(fun) {
+ return { enumerable: true, configurable: true, writable: true,
+ value: console[fun] };
+ }
+
+ const properties = {
+ log: genPropDesc('log'),
+ info: genPropDesc('info'),
+ warn: genPropDesc('warn'),
+ error: genPropDesc('error'),
+ debug: genPropDesc('debug'),
+ trace: genPropDesc('trace'),
+ dir: genPropDesc('dir'),
+ group: genPropDesc('group'),
+ groupCollapsed: genPropDesc('groupCollapsed'),
+ groupEnd: genPropDesc('groupEnd'),
+ time: genPropDesc('time'),
+ timeEnd: genPropDesc('timeEnd'),
+ profile: genPropDesc('profile'),
+ profileEnd: genPropDesc('profileEnd'),
+ exception: genPropDesc('exception'),
+ assert: genPropDesc('assert'),
+ count: genPropDesc('count'),
+ table: genPropDesc('table'),
+ clear: genPropDesc('clear'),
+ dirxml: genPropDesc('dirxml'),
+ markTimeline: genPropDesc('markTimeline'),
+ timeline: genPropDesc('timeline'),
+ timelineEnd: genPropDesc('timelineEnd'),
+ timeStamp: genPropDesc('timeStamp'),
+ };
+
+ Object.defineProperties(con, properties);
+ Cu.makeObjectPropsNormal(con);
+
+ win.console = con;
+ };
+
+ emit(events, "content-script-before-inserted", {
+ window: window,
+ worker: worker
+ });
+
+ // The order of `contentScriptFile` and `contentScript` evaluation is
+ // intentional, so programs can load libraries like jQuery from script URLs
+ // and use them in scripts.
+ let contentScriptFile = ('contentScriptFile' in worker)
+ ? worker.contentScriptFile
+ : null,
+ contentScript = ('contentScript' in worker)
+ ? worker.contentScript
+ : null;
+
+ if (contentScriptFile)
+ importScripts.apply(null, [this].concat(contentScriptFile));
+
+ if (contentScript) {
+ evaluateIn(
+ this,
+ Array.isArray(contentScript) ? contentScript.join(';\n') : contentScript
+ );
+ }
+ },
+ destroy: function destroy(reason) {
+ if (typeof reason != 'string')
+ reason = '';
+ this.emitSync('event', 'detach', reason);
+ let model = modelFor(this);
+ model.sandbox = null
+ model.worker = null;
+ },
+
+});
+
+exports.WorkerSandbox = WorkerSandbox;
+
+/**
+ * Imports scripts to the sandbox by reading files under urls and
+ * evaluating its source. If exception occurs during evaluation
+ * `'error'` event is emitted on the worker.
+ * This is actually an analog to the `importScript` method in web
+ * workers but in our case it's not exposed even though content
+ * scripts may be able to do it synchronously since IO operation
+ * takes place in the UI process.
+ */
+function importScripts (workerSandbox, ...urls) {
+ let { worker, sandbox } = modelFor(workerSandbox);
+ for (let i in urls) {
+ let contentScriptFile = data.url(urls[i]);
+
+ try {
+ let uri = URL(contentScriptFile);
+ if (uri.scheme === 'resource')
+ load(sandbox, String(uri));
+ else
+ throw Error('Unsupported `contentScriptFile` url: ' + String(uri));
+ }
+ catch(e) {
+ emit(worker, 'error', e);
+ }
+ }
+}
+
+function setListeners (workerSandbox, console) {
+ let { worker } = modelFor(workerSandbox);
+ // console.xxx calls
+ workerSandbox.on('console', function consoleListener (kind, ...args) {
+ console[kind].apply(console, args);
+ });
+
+ // self.postMessage calls
+ workerSandbox.on('message', function postMessage(data) {
+ // destroyed?
+ if (worker)
+ emit(worker, 'message', data);
+ });
+
+ // self.port.emit calls
+ workerSandbox.on('event', function portEmit (...eventArgs) {
+ // If not destroyed, emit event information to worker
+ // `eventArgs` has the event name as first element,
+ // and remaining elements are additional arguments to pass
+ if (worker)
+ emit.apply(null, [worker.port].concat(eventArgs));
+ });
+
+ // unwrap, recreate and propagate async Errors thrown from content-script
+ workerSandbox.on('error', function onError({instanceOfError, value}) {
+ if (worker) {
+ let error = value;
+ if (instanceOfError) {
+ error = new Error(value.message, value.fileName, value.lineNumber);
+ error.stack = value.stack;
+ error.name = value.name;
+ }
+ emit(worker, 'error', error);
+ }
+ });
+}
+
+/**
+ * Evaluates code in the sandbox.
+ * @param {String} code
+ * JavaScript source to evaluate.
+ * @param {String} [filename='javascript:' + code]
+ * Name of the file
+ */
+function evaluateIn (workerSandbox, code, filename) {
+ let { worker, sandbox } = modelFor(workerSandbox);
+ try {
+ evaluate(sandbox, code, filename || 'javascript:' + code);
+ }
+ catch(e) {
+ emit(worker, 'error', e);
+ }
+}
+
+/**
+ * Method called by the worker sandbox when it needs to send a message
+ */
+function onContentEvent (workerSandbox, args) {
+ // As `emit`, we ensure having an asynchronous behavior
+ async(function () {
+ // We emit event to chrome/addon listeners
+ emit.apply(null, [workerSandbox].concat(JSON.parse(args)));
+ });
+}
+
+
+function modelFor (workerSandbox) {
+ return sandboxes.get(workerSandbox);
+}
+
+function getUnsafeWindow (win) {
+ return win.wrappedJSObject || win;
+}
+
+function emitToContent (workerSandbox, args) {
+ return modelFor(workerSandbox).emitToContent(args);
+}
+
+function createChromeAPI (scope) {
+ return Cu.cloneInto({
+ timers: {
+ setTimeout: timer.setTimeout.bind(timer),
+ setInterval: timer.setInterval.bind(timer),
+ clearTimeout: timer.clearTimeout.bind(timer),
+ clearInterval: timer.clearInterval.bind(timer),
+ },
+ sandbox: {
+ evaluate: evaluate,
+ },
+ }, scope, {cloneFunctions: true});
+}
diff --git a/toolkit/jetpack/sdk/content/sandbox/events.js b/toolkit/jetpack/sdk/content/sandbox/events.js
new file mode 100644
index 000000000..d6f7eb004
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/sandbox/events.js
@@ -0,0 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const events = {};
+exports.events = events;
diff --git a/toolkit/jetpack/sdk/content/tab-events.js b/toolkit/jetpack/sdk/content/tab-events.js
new file mode 100644
index 000000000..9e244a853
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/tab-events.js
@@ -0,0 +1,58 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Ci } = require('chrome');
+const system = require('sdk/system/events');
+const { frames } = require('sdk/remote/child');
+const { WorkerChild } = require('sdk/content/worker-child');
+
+// map observer topics to tab event names
+const EVENTS = {
+ 'content-document-global-created': 'create',
+ 'chrome-document-global-created': 'create',
+ 'content-document-interactive': 'ready',
+ 'chrome-document-interactive': 'ready',
+ 'content-document-loaded': 'load',
+ 'chrome-document-loaded': 'load',
+// 'content-page-shown': 'pageshow', // bug 1024105
+}
+
+function topicListener({ subject, type }) {
+ // NOTE detect the window from the subject:
+ // - on *-global-created the subject is the window
+ // - in the other cases it is the document object
+ let window = subject instanceof Ci.nsIDOMWindow ? subject : subject.defaultView;
+ if (!window){
+ return;
+ }
+ let frame = frames.getFrameForWindow(window);
+ if (frame) {
+ let readyState = frame.content.document.readyState;
+ frame.port.emit('sdk/tab/event', EVENTS[type], { readyState });
+ }
+}
+
+for (let topic in EVENTS)
+ system.on(topic, topicListener, true);
+
+// bug 1024105 - content-page-shown notification doesn't pass persisted param
+function eventListener({target, type, persisted}) {
+ let frame = this;
+ if (target === frame.content.document) {
+ frame.port.emit('sdk/tab/event', type, persisted);
+ }
+}
+frames.addEventListener('pageshow', eventListener, true);
+
+frames.port.on('sdk/tab/attach', (frame, options) => {
+ options.window = frame.content;
+ new WorkerChild(options);
+});
+
+// Forward the existent frames's readyState.
+for (let frame of frames) {
+ let readyState = frame.content.document.readyState;
+ frame.port.emit('sdk/tab/event', 'init', { readyState });
+}
diff --git a/toolkit/jetpack/sdk/content/thumbnail.js b/toolkit/jetpack/sdk/content/thumbnail.js
new file mode 100644
index 000000000..783615fc6
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/thumbnail.js
@@ -0,0 +1,51 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+const { Cc, Ci, Cu } = require('chrome');
+const AppShellService = Cc['@mozilla.org/appshell/appShellService;1'].
+ getService(Ci.nsIAppShellService);
+
+const NS = 'http://www.w3.org/1999/xhtml';
+const COLOR = 'rgb(255,255,255)';
+
+/**
+ * Creates canvas element with a thumbnail of the passed window.
+ * @param {Window} window
+ * @returns {Element}
+ */
+function getThumbnailCanvasForWindow(window) {
+ let aspectRatio = 0.5625; // 16:9
+ let thumbnail = AppShellService.hiddenDOMWindow.document
+ .createElementNS(NS, 'canvas');
+ thumbnail.mozOpaque = true;
+ thumbnail.width = Math.ceil(window.screen.availWidth / 5.75);
+ thumbnail.height = Math.round(thumbnail.width * aspectRatio);
+ let ctx = thumbnail.getContext('2d');
+ let snippetWidth = window.innerWidth * .6;
+ let scale = thumbnail.width / snippetWidth;
+ ctx.scale(scale, scale);
+ ctx.drawWindow(window, window.scrollX, window.scrollY, snippetWidth,
+ snippetWidth * aspectRatio, COLOR);
+ return thumbnail;
+}
+exports.getThumbnailCanvasForWindow = getThumbnailCanvasForWindow;
+
+/**
+ * Creates Base64 encoded data URI of the thumbnail for the passed window.
+ * @param {Window} window
+ * @returns {String}
+ */
+exports.getThumbnailURIForWindow = function getThumbnailURIForWindow(window) {
+ return getThumbnailCanvasForWindow(window).toDataURL()
+};
+
+// default 80x45 blank when not available
+exports.BLANK = 'data:image/png;base64,' +
+ 'iVBORw0KGgoAAAANSUhEUgAAAFAAAAAtCAYAAAA5reyyAAAAJElEQVRoge3BAQ'+
+ 'EAAACCIP+vbkhAAQAAAAAAAAAAAAAAAADXBjhtAAGQ0AF/AAAAAElFTkSuQmCC';
diff --git a/toolkit/jetpack/sdk/content/utils.js b/toolkit/jetpack/sdk/content/utils.js
new file mode 100644
index 000000000..90995a614
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/utils.js
@@ -0,0 +1,105 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+var { merge } = require('../util/object');
+var { data } = require('../self');
+var assetsURI = data.url();
+var isArray = Array.isArray;
+var method = require('../../method/core');
+var { uuid } = require('../util/uuid');
+
+const isAddonContent = ({ contentURL }) =>
+ contentURL && data.url(contentURL).startsWith(assetsURI);
+
+exports.isAddonContent = isAddonContent;
+
+function hasContentScript({ contentScript, contentScriptFile }) {
+ return (isArray(contentScript) ? contentScript.length > 0 :
+ !!contentScript) ||
+ (isArray(contentScriptFile) ? contentScriptFile.length > 0 :
+ !!contentScriptFile);
+}
+exports.hasContentScript = hasContentScript;
+
+function requiresAddonGlobal(model) {
+ return model.injectInDocument || (isAddonContent(model) && !hasContentScript(model));
+}
+exports.requiresAddonGlobal = requiresAddonGlobal;
+
+function getAttachEventType(model) {
+ if (!model) return null;
+ let when = model.contentScriptWhen;
+ return requiresAddonGlobal(model) ? 'document-element-inserted' :
+ when === 'start' ? 'document-element-inserted' :
+ when === 'ready' ? 'DOMContentLoaded' :
+ when === 'end' ? 'load' :
+ null;
+}
+exports.getAttachEventType = getAttachEventType;
+
+var attach = method('worker-attach');
+exports.attach = attach;
+
+var connect = method('worker-connect');
+exports.connect = connect;
+
+var detach = method('worker-detach');
+exports.detach = detach;
+
+var destroy = method('worker-destroy');
+exports.destroy = destroy;
+
+function WorkerHost (workerFor) {
+ // Define worker properties that just proxy to underlying worker
+ return ['postMessage', 'port', 'url', 'tab'].reduce(function(proto, name) {
+ // Use descriptor properties instead so we can call
+ // the worker function in the context of the worker so we
+ // don't have to create new functions with `fn.bind(worker)`
+ let descriptorProp = {
+ value: function (...args) {
+ let worker = workerFor(this);
+ return worker[name].apply(worker, args);
+ }
+ };
+
+ let accessorProp = {
+ get: function () { return workerFor(this)[name]; },
+ set: function (value) { workerFor(this)[name] = value; }
+ };
+
+ Object.defineProperty(proto, name, merge({
+ enumerable: true,
+ configurable: false,
+ }, isDescriptor(name) ? descriptorProp : accessorProp));
+ return proto;
+ }, {});
+
+ function isDescriptor (prop) {
+ return ~['postMessage'].indexOf(prop);
+ }
+}
+exports.WorkerHost = WorkerHost;
+
+function makeChildOptions(options) {
+ function makeStringArray(arrayOrValue) {
+ if (!arrayOrValue)
+ return [];
+ return [].concat(arrayOrValue).map(String);
+ }
+
+ return {
+ id: String(uuid()),
+ contentScript: makeStringArray(options.contentScript),
+ contentScriptFile: makeStringArray(options.contentScriptFile),
+ contentScriptOptions: options.contentScriptOptions ?
+ JSON.stringify(options.contentScriptOptions) :
+ null,
+ }
+}
+exports.makeChildOptions = makeChildOptions;
diff --git a/toolkit/jetpack/sdk/content/worker-child.js b/toolkit/jetpack/sdk/content/worker-child.js
new file mode 100644
index 000000000..dbf65a933
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/worker-child.js
@@ -0,0 +1,158 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { merge } = require('../util/object');
+const { Class } = require('../core/heritage');
+const { emit } = require('../event/core');
+const { EventTarget } = require('../event/target');
+const { getInnerId, getByInnerId } = require('../window/utils');
+const { instanceOf, isObject } = require('../lang/type');
+const system = require('../system/events');
+const { when } = require('../system/unload');
+const { WorkerSandbox } = require('./sandbox');
+const { Ci } = require('chrome');
+const { process, frames } = require('../remote/child');
+
+const EVENTS = {
+ 'chrome-page-shown': 'pageshow',
+ 'content-page-shown': 'pageshow',
+ 'chrome-page-hidden': 'pagehide',
+ 'content-page-hidden': 'pagehide',
+ 'inner-window-destroyed': 'detach',
+}
+
+// The parent Worker must have been created (or an async message sent to spawn
+// its creation) before creating the WorkerChild or messages from the content
+// script to the parent will get lost.
+const WorkerChild = Class({
+ implements: [EventTarget],
+
+ initialize(options) {
+ merge(this, options);
+ keepAlive.set(this.id, this);
+
+ this.windowId = getInnerId(this.window);
+ if (this.contentScriptOptions)
+ this.contentScriptOptions = JSON.parse(this.contentScriptOptions);
+
+ this.port = EventTarget();
+ this.port.on('*', this.send.bind(this, 'event'));
+ this.on('*', this.send.bind(this));
+
+ this.observe = this.observe.bind(this);
+
+ for (let topic in EVENTS)
+ system.on(topic, this.observe);
+
+ this.receive = this.receive.bind(this);
+ process.port.on('sdk/worker/message', this.receive);
+
+ this.sandbox = WorkerSandbox(this, this.window);
+
+ // If the document has an unexpected readyState, its worker-child instance is initialized
+ // as frozen until one of the known readyState is reached.
+ let initialDocumentReadyState = this.window.document.readyState;
+ this.frozen = [
+ "loading", "interactive", "complete"
+ ].includes(initialDocumentReadyState) ? false : true;
+
+ if (this.frozen) {
+ console.warn("SDK worker-child started as frozen on unexpected initial document.readyState", {
+ initialDocumentReadyState, windowLocation: this.window.location.href,
+ });
+ }
+
+ this.frozenMessages = [];
+ this.on('pageshow', () => {
+ this.frozen = false;
+ this.frozenMessages.forEach(args => this.sandbox.emit(...args));
+ this.frozenMessages = [];
+ });
+ this.on('pagehide', () => {
+ this.frozen = true;
+ });
+ },
+
+ // messages
+ receive(process, id, args) {
+ if (id !== this.id)
+ return;
+ args = JSON.parse(args);
+
+ if (this.frozen)
+ this.frozenMessages.push(args);
+ else
+ this.sandbox.emit(...args);
+
+ if (args[0] === 'detach')
+ this.destroy(args[1]);
+ },
+
+ send(...args) {
+ process.port.emit('sdk/worker/event', this.id, JSON.stringify(args, exceptions));
+ },
+
+ // notifications
+ observe({ type, subject }) {
+ if (!this.sandbox)
+ return;
+
+ if (subject.defaultView && getInnerId(subject.defaultView) === this.windowId) {
+ this.sandbox.emitSync(EVENTS[type]);
+ emit(this, EVENTS[type]);
+ }
+
+ if (type === 'inner-window-destroyed' &&
+ subject.QueryInterface(Ci.nsISupportsPRUint64).data === this.windowId) {
+ this.destroy();
+ }
+ },
+
+ get frame() {
+ return frames.getFrameForWindow(this.window.top);
+ },
+
+ // detach/destroy: unload and release the sandbox
+ destroy(reason) {
+ if (!this.sandbox)
+ return;
+
+ for (let topic in EVENTS)
+ system.off(topic, this.observe);
+ process.port.off('sdk/worker/message', this.receive);
+
+ this.sandbox.destroy(reason);
+ this.sandbox = null;
+ keepAlive.delete(this.id);
+
+ this.send('detach');
+ }
+})
+exports.WorkerChild = WorkerChild;
+
+// Error instances JSON poorly
+function exceptions(key, value) {
+ if (!isObject(value) || !instanceOf(value, Error))
+ return value;
+ let _errorType = value.constructor.name;
+ let { message, fileName, lineNumber, stack, name } = value;
+ return { _errorType, message, fileName, lineNumber, stack, name };
+}
+
+// workers for windows in this tab
+var keepAlive = new Map();
+
+process.port.on('sdk/worker/create', (process, options, cpows) => {
+ options.window = cpows.window;
+ let worker = new WorkerChild(options);
+
+ let frame = frames.getFrameForWindow(options.window.top);
+ frame.port.emit('sdk/worker/connect', options.id, options.window.location.href);
+});
+
+when(reason => {
+ for (let worker of keepAlive.values())
+ worker.destroy(reason);
+});
diff --git a/toolkit/jetpack/sdk/content/worker.js b/toolkit/jetpack/sdk/content/worker.js
new file mode 100644
index 000000000..39b940a88
--- /dev/null
+++ b/toolkit/jetpack/sdk/content/worker.js
@@ -0,0 +1,180 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { emit } = require('../event/core');
+const { omit, merge } = require('../util/object');
+const { Class } = require('../core/heritage');
+const { method } = require('../lang/functional');
+const { getInnerId } = require('../window/utils');
+const { EventTarget } = require('../event/target');
+const { isPrivate } = require('../private-browsing/utils');
+const { getTabForBrowser, getTabForContentWindowNoShim, getBrowserForTab } = require('../tabs/utils');
+const { attach, connect, detach, destroy, makeChildOptions } = require('./utils');
+const { ensure } = require('../system/unload');
+const { on: observe } = require('../system/events');
+const { Ci, Cu } = require('chrome');
+const { modelFor: tabFor } = require('sdk/model/core');
+const { remoteRequire, processes, frames } = require('../remote/parent');
+remoteRequire('sdk/content/worker-child');
+
+const workers = new WeakMap();
+var modelFor = (worker) => workers.get(worker);
+
+const ERR_DESTROYED = "Couldn't find the worker to receive this message. " +
+ "The script may not be initialized yet, or may already have been unloaded.";
+
+// a handle for communication between content script and addon code
+const Worker = Class({
+ implements: [EventTarget],
+
+ initialize(options = {}) {
+ ensure(this, 'detach');
+
+ let model = {
+ attached: false,
+ destroyed: false,
+ earlyEvents: [], // fired before worker was attached
+ frozen: true, // document is not yet active
+ options,
+ };
+ workers.set(this, model);
+
+ this.on('detach', this.detach);
+ EventTarget.prototype.initialize.call(this, options);
+
+ this.receive = this.receive.bind(this);
+
+ this.port = EventTarget();
+ this.port.emit = this.send.bind(this, 'event');
+ this.postMessage = this.send.bind(this, 'message');
+
+ if ('window' in options) {
+ let window = options.window;
+ delete options.window;
+ attach(this, window);
+ }
+ },
+
+ // messages
+ receive(process, id, args) {
+ let model = modelFor(this);
+ if (id !== model.id || !model.attached)
+ return;
+ args = JSON.parse(args);
+ if (model.destroyed && args[0] != 'detach')
+ return;
+
+ if (args[0] === 'event')
+ emit(this.port, ...args.slice(1))
+ else
+ emit(this, ...args);
+ },
+
+ send(...args) {
+ let model = modelFor(this);
+ if (model.destroyed && args[0] !== 'detach')
+ throw new Error(ERR_DESTROYED);
+
+ if (!model.attached) {
+ model.earlyEvents.push(args);
+ return;
+ }
+
+ processes.port.emit('sdk/worker/message', model.id, JSON.stringify(args));
+ },
+
+ // properties
+ get url() {
+ let { url } = modelFor(this);
+ return url;
+ },
+
+ get contentURL() {
+ return this.url;
+ },
+
+ get tab() {
+ require('sdk/tabs');
+ let { frame } = modelFor(this);
+ if (!frame)
+ return null;
+ let rawTab = getTabForBrowser(frame.frameElement);
+ return rawTab && tabFor(rawTab);
+ },
+
+ toString: () => '[object Worker]',
+
+ detach: method(detach),
+ destroy: method(destroy),
+})
+exports.Worker = Worker;
+
+attach.define(Worker, function(worker, window) {
+ let model = modelFor(worker);
+ if (model.attached)
+ detach(worker);
+
+ let childOptions = makeChildOptions(model.options);
+ processes.port.emitCPOW('sdk/worker/create', [childOptions], { window });
+
+ let listener = (frame, id, url) => {
+ if (id != childOptions.id)
+ return;
+ frames.port.off('sdk/worker/connect', listener);
+ connect(worker, frame, { id, url });
+ };
+ frames.port.on('sdk/worker/connect', listener);
+});
+
+connect.define(Worker, function(worker, frame, { id, url }) {
+ let model = modelFor(worker);
+ if (model.attached)
+ detach(worker);
+
+ model.id = id;
+ model.frame = frame;
+ model.url = url;
+
+ // Messages from content -> chrome come through the process message manager
+ // since that lives longer than the frame message manager
+ processes.port.on('sdk/worker/event', worker.receive);
+
+ model.attached = true;
+ model.destroyed = false;
+ model.frozen = false;
+
+ model.earlyEvents.forEach(args => worker.send(...args));
+ model.earlyEvents = [];
+ emit(worker, 'attach');
+});
+
+// unload and release the child worker, release window reference
+detach.define(Worker, function(worker) {
+ let model = modelFor(worker);
+ if (!model.attached)
+ return;
+
+ processes.port.off('sdk/worker/event', worker.receive);
+ model.attached = false;
+ model.destroyed = true;
+ emit(worker, 'detach');
+});
+
+isPrivate.define(Worker, ({ tab }) => isPrivate(tab));
+
+// Something in the parent side has destroyed the worker, tell the child to
+// detach, the child will respond when it has detached
+destroy.define(Worker, function(worker, reason) {
+ let model = modelFor(worker);
+ model.destroyed = true;
+ if (!model.attached)
+ return;
+
+ worker.send('detach', reason);
+});
diff --git a/toolkit/jetpack/sdk/context-menu.js b/toolkit/jetpack/sdk/context-menu.js
new file mode 100644
index 000000000..004c642d4
--- /dev/null
+++ b/toolkit/jetpack/sdk/context-menu.js
@@ -0,0 +1,1188 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "stable",
+ "engines": {
+ // TODO Fennec support Bug 788334
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+const { Class, mix } = require("./core/heritage");
+const { addCollectionProperty } = require("./util/collection");
+const { ns } = require("./core/namespace");
+const { validateOptions, getTypeOf } = require("./deprecated/api-utils");
+const { URL, isValidURI } = require("./url");
+const { WindowTracker, browserWindowIterator } = require("./deprecated/window-utils");
+const { isBrowser, getInnerId } = require("./window/utils");
+const { MatchPattern } = require("./util/match-pattern");
+const { EventTarget } = require("./event/target");
+const { emit } = require('./event/core');
+const { when } = require('./system/unload');
+const { contract: loaderContract } = require('./content/loader');
+const { omit } = require('./util/object');
+const self = require('./self')
+const { remoteRequire, processes } = require('./remote/parent');
+remoteRequire('sdk/content/context-menu');
+
+// All user items we add have this class.
+const ITEM_CLASS = "addon-context-menu-item";
+
+// Items in the top-level context menu also have this class.
+const TOPLEVEL_ITEM_CLASS = "addon-context-menu-item-toplevel";
+
+// Items in the overflow submenu also have this class.
+const OVERFLOW_ITEM_CLASS = "addon-context-menu-item-overflow";
+
+// The class of the menu separator that separates standard context menu items
+// from our user items.
+const SEPARATOR_CLASS = "addon-context-menu-separator";
+
+// If more than this number of items are added to the context menu, all items
+// overflow into a "Jetpack" submenu.
+const OVERFLOW_THRESH_DEFAULT = 10;
+const OVERFLOW_THRESH_PREF =
+ "extensions.addon-sdk.context-menu.overflowThreshold";
+
+// The label of the overflow sub-xul:menu.
+//
+// TODO: Localize these.
+const OVERFLOW_MENU_LABEL = "Add-ons";
+const OVERFLOW_MENU_ACCESSKEY = "A";
+
+// The class of the overflow sub-xul:menu.
+const OVERFLOW_MENU_CLASS = "addon-content-menu-overflow-menu";
+
+// The class of the overflow submenu's xul:menupopup.
+const OVERFLOW_POPUP_CLASS = "addon-content-menu-overflow-popup";
+
+// Holds private properties for API objects
+var internal = ns();
+
+// A little hacky but this is the last process ID that last opened the context
+// menu
+var lastContextProcessId = null;
+
+var uuidModule = require('./util/uuid');
+function uuid() {
+ return uuidModule.uuid().toString();
+}
+
+function getScheme(spec) {
+ try {
+ return URL(spec).scheme;
+ }
+ catch(e) {
+ return null;
+ }
+}
+
+var Context = Class({
+ initialize: function() {
+ internal(this).id = uuid();
+ },
+
+ // Returns the node that made this context current
+ adjustPopupNode: function adjustPopupNode(popupNode) {
+ return popupNode;
+ },
+
+ // Returns whether this context is current for the current node
+ isCurrent: function isCurrent(state) {
+ return state;
+ }
+});
+
+// Matches when the context-clicked node doesn't have any of
+// NON_PAGE_CONTEXT_ELTS in its ancestors
+var PageContext = Class({
+ extends: Context,
+
+ serialize: function() {
+ return {
+ id: internal(this).id,
+ type: "PageContext",
+ args: []
+ }
+ }
+});
+exports.PageContext = PageContext;
+
+// Matches when there is an active selection in the window
+var SelectionContext = Class({
+ extends: Context,
+
+ serialize: function() {
+ return {
+ id: internal(this).id,
+ type: "SelectionContext",
+ args: []
+ }
+ }
+});
+exports.SelectionContext = SelectionContext;
+
+// Matches when the context-clicked node or any of its ancestors matches the
+// selector given
+var SelectorContext = Class({
+ extends: Context,
+
+ initialize: function initialize(selector) {
+ Context.prototype.initialize.call(this);
+ let options = validateOptions({ selector: selector }, {
+ selector: {
+ is: ["string"],
+ msg: "selector must be a string."
+ }
+ });
+ internal(this).selector = options.selector;
+ },
+
+ serialize: function() {
+ return {
+ id: internal(this).id,
+ type: "SelectorContext",
+ args: [internal(this).selector]
+ }
+ }
+});
+exports.SelectorContext = SelectorContext;
+
+// Matches when the page url matches any of the patterns given
+var URLContext = Class({
+ extends: Context,
+
+ initialize: function initialize(patterns) {
+ Context.prototype.initialize.call(this);
+ patterns = Array.isArray(patterns) ? patterns : [patterns];
+
+ try {
+ internal(this).patterns = patterns.map(p => new MatchPattern(p));
+ }
+ catch (err) {
+ throw new Error("Patterns must be a string, regexp or an array of " +
+ "strings or regexps: " + err);
+ }
+ },
+
+ isCurrent: function isCurrent(url) {
+ return internal(this).patterns.some(p => p.test(url));
+ },
+
+ serialize: function() {
+ return {
+ id: internal(this).id,
+ type: "URLContext",
+ args: []
+ }
+ }
+});
+exports.URLContext = URLContext;
+
+// Matches when the user-supplied predicate returns true
+var PredicateContext = Class({
+ extends: Context,
+
+ initialize: function initialize(predicate) {
+ Context.prototype.initialize.call(this);
+ let options = validateOptions({ predicate: predicate }, {
+ predicate: {
+ is: ["function"],
+ msg: "predicate must be a function."
+ }
+ });
+ internal(this).predicate = options.predicate;
+ },
+
+ isCurrent: function isCurrent(state) {
+ return internal(this).predicate(state);
+ },
+
+ serialize: function() {
+ return {
+ id: internal(this).id,
+ type: "PredicateContext",
+ args: []
+ }
+ }
+});
+exports.PredicateContext = PredicateContext;
+
+function removeItemFromArray(array, item) {
+ return array.filter(i => i !== item);
+}
+
+// Converts anything that isn't false, null or undefined into a string
+function stringOrNull(val) {
+ return val ? String(val) : val;
+}
+
+// Shared option validation rules for Item, Menu, and Separator
+var baseItemRules = {
+ parentMenu: {
+ is: ["object", "undefined"],
+ ok: function (v) {
+ if (!v)
+ return true;
+ return (v instanceof ItemContainer) || (v instanceof Menu);
+ },
+ msg: "parentMenu must be a Menu or not specified."
+ },
+ context: {
+ is: ["undefined", "object", "array"],
+ ok: function (v) {
+ if (!v)
+ return true;
+ let arr = Array.isArray(v) ? v : [v];
+ return arr.every(o => o instanceof Context);
+ },
+ msg: "The 'context' option must be a Context object or an array of " +
+ "Context objects."
+ },
+ onMessage: {
+ is: ["function", "undefined"]
+ },
+ contentScript: loaderContract.rules.contentScript,
+ contentScriptFile: loaderContract.rules.contentScriptFile
+};
+
+var labelledItemRules = mix(baseItemRules, {
+ label: {
+ map: stringOrNull,
+ is: ["string"],
+ ok: v => !!v,
+ msg: "The item must have a non-empty string label."
+ },
+ accesskey: {
+ map: stringOrNull,
+ is: ["string", "undefined", "null"],
+ ok: (v) => {
+ if (!v) {
+ return true;
+ }
+ return typeof v == "string" && v.length === 1;
+ },
+ msg: "The item must have a single character accesskey, or no accesskey."
+ },
+ image: {
+ map: stringOrNull,
+ is: ["string", "undefined", "null"],
+ ok: function (url) {
+ if (!url)
+ return true;
+ return isValidURI(url);
+ },
+ msg: "Image URL validation failed"
+ }
+});
+
+// Additional validation rules for Item
+var itemRules = mix(labelledItemRules, {
+ data: {
+ map: stringOrNull,
+ is: ["string", "undefined", "null"]
+ }
+});
+
+// Additional validation rules for Menu
+var menuRules = mix(labelledItemRules, {
+ items: {
+ is: ["array", "undefined"],
+ ok: function (v) {
+ if (!v)
+ return true;
+ return v.every(function (item) {
+ return item instanceof BaseItem;
+ });
+ },
+ msg: "items must be an array, and each element in the array must be an " +
+ "Item, Menu, or Separator."
+ }
+});
+
+// Returns true if any contexts match. If there are no contexts then a
+// PageContext is tested instead
+function hasMatchingContext(contexts, addonInfo) {
+ for (let context of contexts) {
+ if (!(internal(context).id in addonInfo.contextStates)) {
+ console.error("Missing state for context " + internal(context).id + " this is an error in the SDK modules.");
+ return false;
+ }
+ if (!context.isCurrent(addonInfo.contextStates[internal(context).id]))
+ return false;
+ }
+
+ return true;
+}
+
+// Tests whether an item should be visible or not based on its contexts and
+// content scripts
+function isItemVisible(item, addonInfo, usePageWorker) {
+ if (!item.context.length) {
+ if (!addonInfo.hasWorker)
+ return usePageWorker ? addonInfo.pageContext : true;
+ }
+
+ if (!hasMatchingContext(item.context, addonInfo))
+ return false;
+
+ let context = addonInfo.workerContext;
+ if (typeof(context) === "string" && context != "")
+ item.label = context;
+
+ return !!context;
+}
+
+// Called when an item is clicked to send out click events to the content
+// scripts
+function itemActivated(item, clickedNode) {
+ let items = [internal(item).id];
+ let data = item.data;
+
+ while (item.parentMenu) {
+ item = item.parentMenu;
+ items.push(internal(item).id);
+ }
+
+ let process = processes.getById(lastContextProcessId);
+ if (process)
+ process.port.emit('sdk/contextmenu/activateitems', items, data);
+}
+
+function serializeItem(item) {
+ return {
+ id: internal(item).id,
+ contexts: item.context.map(c => c.serialize()),
+ contentScript: item.contentScript,
+ contentScriptFile: item.contentScriptFile,
+ };
+}
+
+// All things that appear in the context menu extend this
+var BaseItem = Class({
+ initialize: function initialize() {
+ internal(this).id = uuid();
+
+ internal(this).contexts = [];
+ if ("context" in internal(this).options && internal(this).options.context) {
+ let contexts = internal(this).options.context;
+ if (Array.isArray(contexts)) {
+ for (let context of contexts)
+ internal(this).contexts.push(context);
+ }
+ else {
+ internal(this).contexts.push(contexts);
+ }
+ }
+
+ let parentMenu = internal(this).options.parentMenu;
+ if (!parentMenu)
+ parentMenu = contentContextMenu;
+
+ parentMenu.addItem(this);
+
+ Object.defineProperty(this, "contentScript", {
+ enumerable: true,
+ value: internal(this).options.contentScript
+ });
+
+ // Resolve URIs here as tests may have overriden self
+ let files = internal(this).options.contentScriptFile;
+ if (files) {
+ if (!Array.isArray(files))
+ files = [files];
+ files = files.map(self.data.url);
+ }
+ internal(this).options.contentScriptFile = files;
+ Object.defineProperty(this, "contentScriptFile", {
+ enumerable: true,
+ value: internal(this).options.contentScriptFile
+ });
+
+ // Notify all frames of this new item
+ sendItems([serializeItem(this)]);
+ },
+
+ destroy: function destroy() {
+ if (internal(this).destroyed)
+ return;
+
+ // Tell all existing frames that this item has been destroyed
+ processes.port.emit("sdk/contextmenu/destroyitems", [internal(this).id]);
+
+ if (this.parentMenu)
+ this.parentMenu.removeItem(this);
+
+ internal(this).destroyed = true;
+ },
+
+ get context() {
+ let contexts = internal(this).contexts.slice(0);
+ contexts.add = (context) => {
+ internal(this).contexts.push(context);
+ // Notify all frames that this item has changed
+ sendItems([serializeItem(this)]);
+ };
+ contexts.remove = (context) => {
+ internal(this).contexts = internal(this).contexts.filter(c => {
+ return c != context;
+ });
+ // Notify all frames that this item has changed
+ sendItems([serializeItem(this)]);
+ };
+ return contexts;
+ },
+
+ set context(val) {
+ internal(this).contexts = val.slice(0);
+ // Notify all frames that this item has changed
+ sendItems([serializeItem(this)]);
+ },
+
+ get parentMenu() {
+ return internal(this).parentMenu;
+ },
+});
+
+function workerMessageReceived(process, id, args) {
+ if (internal(this).id != id)
+ return;
+
+ emit(this, ...JSON.parse(args));
+}
+
+// All things that have a label on the context menu extend this
+var LabelledItem = Class({
+ extends: BaseItem,
+ implements: [ EventTarget ],
+
+ initialize: function initialize(options) {
+ BaseItem.prototype.initialize.call(this);
+ EventTarget.prototype.initialize.call(this, options);
+
+ internal(this).messageListener = workerMessageReceived.bind(this);
+ processes.port.on('sdk/worker/event', internal(this).messageListener);
+ },
+
+ destroy: function destroy() {
+ if (internal(this).destroyed)
+ return;
+
+ processes.port.off('sdk/worker/event', internal(this).messageListener);
+
+ BaseItem.prototype.destroy.call(this);
+ },
+
+ get label() {
+ return internal(this).options.label;
+ },
+
+ set label(val) {
+ internal(this).options.label = val;
+
+ MenuManager.updateItem(this);
+ },
+
+ get accesskey() {
+ return internal(this).options.accesskey;
+ },
+
+ set accesskey(val) {
+ internal(this).options.accesskey = val;
+
+ MenuManager.updateItem(this);
+ },
+
+ get image() {
+ return internal(this).options.image;
+ },
+
+ set image(val) {
+ internal(this).options.image = val;
+
+ MenuManager.updateItem(this);
+ },
+
+ get data() {
+ return internal(this).options.data;
+ },
+
+ set data(val) {
+ internal(this).options.data = val;
+ }
+});
+
+var Item = Class({
+ extends: LabelledItem,
+
+ initialize: function initialize(options) {
+ internal(this).options = validateOptions(options, itemRules);
+
+ LabelledItem.prototype.initialize.call(this, options);
+ },
+
+ toString: function toString() {
+ return "[object Item \"" + this.label + "\"]";
+ },
+
+ get data() {
+ return internal(this).options.data;
+ },
+
+ set data(val) {
+ internal(this).options.data = val;
+
+ MenuManager.updateItem(this);
+ },
+});
+exports.Item = Item;
+
+var ItemContainer = Class({
+ initialize: function initialize() {
+ internal(this).children = [];
+ },
+
+ destroy: function destroy() {
+ // Destroys the entire hierarchy
+ for (let item of internal(this).children)
+ item.destroy();
+ },
+
+ addItem: function addItem(item) {
+ let oldParent = item.parentMenu;
+
+ // Don't just call removeItem here as that would remove the corresponding
+ // UI element which is more costly than just moving it to the right place
+ if (oldParent)
+ internal(oldParent).children = removeItemFromArray(internal(oldParent).children, item);
+
+ let after = null;
+ let children = internal(this).children;
+ if (children.length > 0)
+ after = children[children.length - 1];
+
+ children.push(item);
+ internal(item).parentMenu = this;
+
+ // If there was an old parent then we just have to move the item, otherwise
+ // it needs to be created
+ if (oldParent)
+ MenuManager.moveItem(item, after);
+ else
+ MenuManager.createItem(item, after);
+ },
+
+ removeItem: function removeItem(item) {
+ // If the item isn't a child of this menu then ignore this call
+ if (item.parentMenu !== this)
+ return;
+
+ MenuManager.removeItem(item);
+
+ internal(this).children = removeItemFromArray(internal(this).children, item);
+ internal(item).parentMenu = null;
+ },
+
+ get items() {
+ return internal(this).children.slice(0);
+ },
+
+ set items(val) {
+ // Validate the arguments before making any changes
+ if (!Array.isArray(val))
+ throw new Error(menuOptionRules.items.msg);
+
+ for (let item of val) {
+ if (!(item instanceof BaseItem))
+ throw new Error(menuOptionRules.items.msg);
+ }
+
+ // Remove the old items and add the new ones
+ for (let item of internal(this).children)
+ this.removeItem(item);
+
+ for (let item of val)
+ this.addItem(item);
+ },
+});
+
+var Menu = Class({
+ extends: LabelledItem,
+ implements: [ItemContainer],
+
+ initialize: function initialize(options) {
+ internal(this).options = validateOptions(options, menuRules);
+
+ LabelledItem.prototype.initialize.call(this, options);
+ ItemContainer.prototype.initialize.call(this);
+
+ if (internal(this).options.items) {
+ for (let item of internal(this).options.items)
+ this.addItem(item);
+ }
+ },
+
+ destroy: function destroy() {
+ ItemContainer.prototype.destroy.call(this);
+ LabelledItem.prototype.destroy.call(this);
+ },
+
+ toString: function toString() {
+ return "[object Menu \"" + this.label + "\"]";
+ },
+});
+exports.Menu = Menu;
+
+var Separator = Class({
+ extends: BaseItem,
+
+ initialize: function initialize(options) {
+ internal(this).options = validateOptions(options, baseItemRules);
+
+ BaseItem.prototype.initialize.call(this);
+ },
+
+ toString: function toString() {
+ return "[object Separator]";
+ }
+});
+exports.Separator = Separator;
+
+// Holds items for the content area context menu
+var contentContextMenu = ItemContainer();
+exports.contentContextMenu = contentContextMenu;
+
+function getContainerItems(container) {
+ let items = [];
+ for (let item of internal(container).children) {
+ items.push(serializeItem(item));
+ if (item instanceof Menu)
+ items = items.concat(getContainerItems(item));
+ }
+ return items;
+}
+
+// Notify all frames of these new or changed items
+function sendItems(items) {
+ processes.port.emit("sdk/contextmenu/createitems", items);
+}
+
+// Called when a new process is created and needs to get the current list of items
+function remoteItemRequest(process) {
+ let items = getContainerItems(contentContextMenu);
+ if (items.length == 0)
+ return;
+
+ process.port.emit("sdk/contextmenu/createitems", items);
+}
+processes.forEvery(remoteItemRequest);
+
+when(function() {
+ contentContextMenu.destroy();
+});
+
+// App specific UI code lives here, it should handle populating the context
+// menu and passing clicks etc. through to the items.
+
+function countVisibleItems(nodes) {
+ return Array.reduce(nodes, function(sum, node) {
+ return node.hidden ? sum : sum + 1;
+ }, 0);
+}
+
+var MenuWrapper = Class({
+ initialize: function initialize(winWrapper, items, contextMenu) {
+ this.winWrapper = winWrapper;
+ this.window = winWrapper.window;
+ this.items = items;
+ this.contextMenu = contextMenu;
+ this.populated = false;
+ this.menuMap = new Map();
+
+ // updateItemVisibilities will run first, updateOverflowState will run after
+ // all other instances of this module have run updateItemVisibilities
+ this._updateItemVisibilities = this.updateItemVisibilities.bind(this);
+ this.contextMenu.addEventListener("popupshowing", this._updateItemVisibilities, true);
+ this._updateOverflowState = this.updateOverflowState.bind(this);
+ this.contextMenu.addEventListener("popupshowing", this._updateOverflowState, false);
+ },
+
+ destroy: function destroy() {
+ this.contextMenu.removeEventListener("popupshowing", this._updateOverflowState, false);
+ this.contextMenu.removeEventListener("popupshowing", this._updateItemVisibilities, true);
+
+ if (!this.populated)
+ return;
+
+ // If we're getting unloaded at runtime then we must remove all the
+ // generated XUL nodes
+ let oldParent = null;
+ for (let item of internal(this.items).children) {
+ let xulNode = this.getXULNodeForItem(item);
+ oldParent = xulNode.parentNode;
+ oldParent.removeChild(xulNode);
+ }
+
+ if (oldParent)
+ this.onXULRemoved(oldParent);
+ },
+
+ get separator() {
+ return this.contextMenu.querySelector("." + SEPARATOR_CLASS);
+ },
+
+ get overflowMenu() {
+ return this.contextMenu.querySelector("." + OVERFLOW_MENU_CLASS);
+ },
+
+ get overflowPopup() {
+ return this.contextMenu.querySelector("." + OVERFLOW_POPUP_CLASS);
+ },
+
+ get topLevelItems() {
+ return this.contextMenu.querySelectorAll("." + TOPLEVEL_ITEM_CLASS);
+ },
+
+ get overflowItems() {
+ return this.contextMenu.querySelectorAll("." + OVERFLOW_ITEM_CLASS);
+ },
+
+ getXULNodeForItem: function getXULNodeForItem(item) {
+ return this.menuMap.get(item);
+ },
+
+ // Recurses through the item hierarchy creating XUL nodes for everything
+ populate: function populate(menu) {
+ for (let i = 0; i < internal(menu).children.length; i++) {
+ let item = internal(menu).children[i];
+ let after = i === 0 ? null : internal(menu).children[i - 1];
+ this.createItem(item, after);
+
+ if (item instanceof Menu)
+ this.populate(item);
+ }
+ },
+
+ // Recurses through the menu setting the visibility of items. Returns true
+ // if any of the items in this menu were visible
+ setVisibility: function setVisibility(menu, addonInfo, usePageWorker) {
+ let anyVisible = false;
+
+ for (let item of internal(menu).children) {
+ let visible = isItemVisible(item, addonInfo[internal(item).id], usePageWorker);
+
+ // Recurse through Menus, if none of the sub-items were visible then the
+ // menu is hidden too.
+ if (visible && (item instanceof Menu))
+ visible = this.setVisibility(item, addonInfo, false);
+
+ let xulNode = this.getXULNodeForItem(item);
+ xulNode.hidden = !visible;
+
+ anyVisible = anyVisible || visible;
+ }
+
+ return anyVisible;
+ },
+
+ // Works out where to insert a XUL node for an item in a browser window
+ insertIntoXUL: function insertIntoXUL(item, node, after) {
+ let menupopup = null;
+ let before = null;
+
+ let menu = item.parentMenu;
+ if (menu === this.items) {
+ // Insert into the overflow popup if it exists, otherwise the normal
+ // context menu
+ menupopup = this.overflowPopup;
+ if (!menupopup)
+ menupopup = this.contextMenu;
+ }
+ else {
+ let xulNode = this.getXULNodeForItem(menu);
+ menupopup = xulNode.firstChild;
+ }
+
+ if (after) {
+ let afterNode = this.getXULNodeForItem(after);
+ before = afterNode.nextSibling;
+ }
+ else if (menupopup === this.contextMenu) {
+ let topLevel = this.topLevelItems;
+ if (topLevel.length > 0)
+ before = topLevel[topLevel.length - 1].nextSibling;
+ else
+ before = this.separator.nextSibling;
+ }
+
+ menupopup.insertBefore(node, before);
+ },
+
+ // Sets the right class for XUL nodes
+ updateXULClass: function updateXULClass(xulNode) {
+ if (xulNode.parentNode == this.contextMenu)
+ xulNode.classList.add(TOPLEVEL_ITEM_CLASS);
+ else
+ xulNode.classList.remove(TOPLEVEL_ITEM_CLASS);
+
+ if (xulNode.parentNode == this.overflowPopup)
+ xulNode.classList.add(OVERFLOW_ITEM_CLASS);
+ else
+ xulNode.classList.remove(OVERFLOW_ITEM_CLASS);
+ },
+
+ // Creates a XUL node for an item
+ createItem: function createItem(item, after) {
+ if (!this.populated)
+ return;
+
+ // Create the separator if it doesn't already exist
+ if (!this.separator) {
+ let separator = this.window.document.createElement("menuseparator");
+ separator.setAttribute("class", SEPARATOR_CLASS);
+
+ // Insert before the separator created by the old context-menu if it
+ // exists to avoid bug 832401
+ let oldSeparator = this.window.document.getElementById("jetpack-context-menu-separator");
+ if (oldSeparator && oldSeparator.parentNode != this.contextMenu)
+ oldSeparator = null;
+ this.contextMenu.insertBefore(separator, oldSeparator);
+ }
+
+ let type = "menuitem";
+ if (item instanceof Menu)
+ type = "menu";
+ else if (item instanceof Separator)
+ type = "menuseparator";
+
+ let xulNode = this.window.document.createElement(type);
+ xulNode.setAttribute("class", ITEM_CLASS);
+ if (item instanceof LabelledItem) {
+ xulNode.setAttribute("label", item.label);
+ if (item.accesskey)
+ xulNode.setAttribute("accesskey", item.accesskey);
+ if (item.image) {
+ xulNode.setAttribute("image", item.image);
+ if (item instanceof Menu)
+ xulNode.classList.add("menu-iconic");
+ else
+ xulNode.classList.add("menuitem-iconic");
+ }
+ if (item.data)
+ xulNode.setAttribute("value", item.data);
+
+ let self = this;
+ xulNode.addEventListener("command", function(event) {
+ // Only care about clicks directly on this item
+ if (event.target !== xulNode)
+ return;
+
+ itemActivated(item, xulNode);
+ }, false);
+ }
+
+ this.insertIntoXUL(item, xulNode, after);
+ this.updateXULClass(xulNode);
+ xulNode.data = item.data;
+
+ if (item instanceof Menu) {
+ let menupopup = this.window.document.createElement("menupopup");
+ xulNode.appendChild(menupopup);
+ }
+
+ this.menuMap.set(item, xulNode);
+ },
+
+ // Updates the XUL node for an item in this window
+ updateItem: function updateItem(item) {
+ if (!this.populated)
+ return;
+
+ let xulNode = this.getXULNodeForItem(item);
+
+ // TODO figure out why this requires setAttribute
+ xulNode.setAttribute("label", item.label);
+ xulNode.setAttribute("accesskey", item.accesskey || "");
+
+ if (item.image) {
+ xulNode.setAttribute("image", item.image);
+ if (item instanceof Menu)
+ xulNode.classList.add("menu-iconic");
+ else
+ xulNode.classList.add("menuitem-iconic");
+ }
+ else {
+ xulNode.removeAttribute("image");
+ xulNode.classList.remove("menu-iconic");
+ xulNode.classList.remove("menuitem-iconic");
+ }
+
+ if (item.data)
+ xulNode.setAttribute("value", item.data);
+ else
+ xulNode.removeAttribute("value");
+ },
+
+ // Moves the XUL node for an item in this window to its new place in the
+ // hierarchy
+ moveItem: function moveItem(item, after) {
+ if (!this.populated)
+ return;
+
+ let xulNode = this.getXULNodeForItem(item);
+ let oldParent = xulNode.parentNode;
+
+ this.insertIntoXUL(item, xulNode, after);
+ this.updateXULClass(xulNode);
+ this.onXULRemoved(oldParent);
+ },
+
+ // Removes the XUL nodes for an item in every window we've ever populated.
+ removeItem: function removeItem(item) {
+ if (!this.populated)
+ return;
+
+ let xulItem = this.getXULNodeForItem(item);
+
+ let oldParent = xulItem.parentNode;
+
+ oldParent.removeChild(xulItem);
+ this.menuMap.delete(item);
+
+ this.onXULRemoved(oldParent);
+ },
+
+ // Called when any XUL nodes have been removed from a menupopup. This handles
+ // making sure the separator and overflow are correct
+ onXULRemoved: function onXULRemoved(parent) {
+ if (parent == this.contextMenu) {
+ let toplevel = this.topLevelItems;
+
+ // If there are no more items then remove the separator
+ if (toplevel.length == 0) {
+ let separator = this.separator;
+ if (separator)
+ separator.parentNode.removeChild(separator);
+ }
+ }
+ else if (parent == this.overflowPopup) {
+ // If there are no more items then remove the overflow menu and separator
+ if (parent.childNodes.length == 0) {
+ let separator = this.separator;
+ separator.parentNode.removeChild(separator);
+ this.contextMenu.removeChild(parent.parentNode);
+ }
+ }
+ },
+
+ // Recurses through all the items owned by this module and sets their hidden
+ // state
+ updateItemVisibilities: function updateItemVisibilities(event) {
+ try {
+ if (event.type != "popupshowing")
+ return;
+ if (event.target != this.contextMenu)
+ return;
+
+ if (internal(this.items).children.length == 0)
+ return;
+
+ if (!this.populated) {
+ this.populated = true;
+ this.populate(this.items);
+ }
+
+ let mainWindow = event.target.ownerDocument.defaultView;
+ this.contextMenuContentData = mainWindow.gContextMenuContentData
+ if (!(self.id in this.contextMenuContentData.addonInfo)) {
+ console.warn("No context menu state data was provided.");
+ return;
+ }
+ let addonInfo = this.contextMenuContentData.addonInfo[self.id];
+ lastContextProcessId = addonInfo.processID;
+ this.setVisibility(this.items, addonInfo.items, true);
+ }
+ catch (e) {
+ console.exception(e);
+ }
+ },
+
+ // Counts the number of visible items across all modules and makes sure they
+ // are in the right place between the top level context menu and the overflow
+ // menu
+ updateOverflowState: function updateOverflowState(event) {
+ try {
+ if (event.type != "popupshowing")
+ return;
+ if (event.target != this.contextMenu)
+ return;
+
+ // The main items will be in either the top level context menu or the
+ // overflow menu at this point. Count the visible ones and if they are in
+ // the wrong place move them
+ let toplevel = this.topLevelItems;
+ let overflow = this.overflowItems;
+ let visibleCount = countVisibleItems(toplevel) +
+ countVisibleItems(overflow);
+
+ if (visibleCount == 0) {
+ let separator = this.separator;
+ if (separator)
+ separator.hidden = true;
+ let overflowMenu = this.overflowMenu;
+ if (overflowMenu)
+ overflowMenu.hidden = true;
+ }
+ else if (visibleCount > MenuManager.overflowThreshold) {
+ this.separator.hidden = false;
+ let overflowPopup = this.overflowPopup;
+ if (overflowPopup)
+ overflowPopup.parentNode.hidden = false;
+
+ if (toplevel.length > 0) {
+ // The overflow menu shouldn't exist here but let's play it safe
+ if (!overflowPopup) {
+ let overflowMenu = this.window.document.createElement("menu");
+ overflowMenu.setAttribute("class", OVERFLOW_MENU_CLASS);
+ overflowMenu.setAttribute("label", OVERFLOW_MENU_LABEL);
+ overflowMenu.setAttribute("accesskey", OVERFLOW_MENU_ACCESSKEY);
+ this.contextMenu.insertBefore(overflowMenu, this.separator.nextSibling);
+
+ overflowPopup = this.window.document.createElement("menupopup");
+ overflowPopup.setAttribute("class", OVERFLOW_POPUP_CLASS);
+ overflowMenu.appendChild(overflowPopup);
+ }
+
+ for (let xulNode of toplevel) {
+ overflowPopup.appendChild(xulNode);
+ this.updateXULClass(xulNode);
+ }
+ }
+ }
+ else {
+ this.separator.hidden = false;
+
+ if (overflow.length > 0) {
+ // Move all the overflow nodes out of the overflow menu and position
+ // them immediately before it
+ for (let xulNode of overflow) {
+ this.contextMenu.insertBefore(xulNode, xulNode.parentNode.parentNode);
+ this.updateXULClass(xulNode);
+ }
+ this.contextMenu.removeChild(this.overflowMenu);
+ }
+ }
+ }
+ catch (e) {
+ console.exception(e);
+ }
+ }
+});
+
+// This wraps every window that we've seen
+var WindowWrapper = Class({
+ initialize: function initialize(window) {
+ this.window = window;
+ this.menus = [
+ new MenuWrapper(this, contentContextMenu, window.document.getElementById("contentAreaContextMenu")),
+ ];
+ },
+
+ destroy: function destroy() {
+ for (let menuWrapper of this.menus)
+ menuWrapper.destroy();
+ },
+
+ getMenuWrapperForItem: function getMenuWrapperForItem(item) {
+ let root = item.parentMenu;
+ while (root.parentMenu)
+ root = root.parentMenu;
+
+ for (let wrapper of this.menus) {
+ if (wrapper.items === root)
+ return wrapper;
+ }
+
+ return null;
+ }
+});
+
+var MenuManager = {
+ windowMap: new Map(),
+
+ get overflowThreshold() {
+ let prefs = require("./preferences/service");
+ return prefs.get(OVERFLOW_THRESH_PREF, OVERFLOW_THRESH_DEFAULT);
+ },
+
+ // When a new window is added start watching it for context menu shows
+ onTrack: function onTrack(window) {
+ if (!isBrowser(window))
+ return;
+
+ // Generally shouldn't happen, but just in case
+ if (this.windowMap.has(window)) {
+ console.warn("Already seen this window");
+ return;
+ }
+
+ let winWrapper = WindowWrapper(window);
+ this.windowMap.set(window, winWrapper);
+ },
+
+ onUntrack: function onUntrack(window) {
+ if (!isBrowser(window))
+ return;
+
+ let winWrapper = this.windowMap.get(window);
+ // This shouldn't happen but protect against it anyway
+ if (!winWrapper)
+ return;
+ winWrapper.destroy();
+
+ this.windowMap.delete(window);
+ },
+
+ // Creates a XUL node for an item in every window we've already populated
+ createItem: function createItem(item, after) {
+ for (let [window, winWrapper] of this.windowMap) {
+ let menuWrapper = winWrapper.getMenuWrapperForItem(item);
+ if (menuWrapper)
+ menuWrapper.createItem(item, after);
+ }
+ },
+
+ // Updates the XUL node for an item in every window we've already populated
+ updateItem: function updateItem(item) {
+ for (let [window, winWrapper] of this.windowMap) {
+ let menuWrapper = winWrapper.getMenuWrapperForItem(item);
+ if (menuWrapper)
+ menuWrapper.updateItem(item);
+ }
+ },
+
+ // Moves the XUL node for an item in every window we've ever populated to its
+ // new place in the hierarchy
+ moveItem: function moveItem(item, after) {
+ for (let [window, winWrapper] of this.windowMap) {
+ let menuWrapper = winWrapper.getMenuWrapperForItem(item);
+ if (menuWrapper)
+ menuWrapper.moveItem(item, after);
+ }
+ },
+
+ // Removes the XUL nodes for an item in every window we've ever populated.
+ removeItem: function removeItem(item) {
+ for (let [window, winWrapper] of this.windowMap) {
+ let menuWrapper = winWrapper.getMenuWrapperForItem(item);
+ if (menuWrapper)
+ menuWrapper.removeItem(item);
+ }
+ }
+};
+
+WindowTracker(MenuManager);
diff --git a/toolkit/jetpack/sdk/context-menu/context.js b/toolkit/jetpack/sdk/context-menu/context.js
new file mode 100644
index 000000000..fc5aea500
--- /dev/null
+++ b/toolkit/jetpack/sdk/context-menu/context.js
@@ -0,0 +1,147 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const { Class } = require("../core/heritage");
+const { extend } = require("../util/object");
+const { MatchPattern } = require("../util/match-pattern");
+const readers = require("./readers");
+
+// Context class is required to implement a single `isCurrent(target)` method
+// that must return boolean value indicating weather given target matches a
+// context or not. Most context implementations below will have an associated
+// reader that way context implementation can setup a reader to extract necessary
+// information to make decision if target is matching a context.
+const Context = Class({
+ isRequired: false,
+ isCurrent(target) {
+ throw Error("Context class must implement isCurrent(target) method");
+ },
+ get required() {
+ Object.defineProperty(this, "required", {
+ value: Object.assign(Object.create(Object.getPrototypeOf(this)),
+ this,
+ {isRequired: true})
+ });
+ return this.required;
+ }
+});
+Context.required = function(...params) {
+ return Object.assign(new this(...params), {isRequired: true});
+};
+exports.Context = Context;
+
+
+// Next few context implementations use an associated reader to extract info
+// from the context target and story it to a private symbol associtaed with
+// a context implementation. That way name collisions are avoided while required
+// information is still carried along.
+const isPage = Symbol("context/page?")
+const PageContext = Class({
+ extends: Context,
+ read: {[isPage]: new readers.isPage()},
+ isCurrent: target => target[isPage]
+});
+exports.Page = PageContext;
+
+const isFrame = Symbol("context/frame?");
+const FrameContext = Class({
+ extends: Context,
+ read: {[isFrame]: new readers.isFrame()},
+ isCurrent: target => target[isFrame]
+});
+exports.Frame = FrameContext;
+
+const selection = Symbol("context/selection")
+const SelectionContext = Class({
+ read: {[selection]: new readers.Selection()},
+ isCurrent: target => !!target[selection]
+});
+exports.Selection = SelectionContext;
+
+const link = Symbol("context/link");
+const LinkContext = Class({
+ extends: Context,
+ read: {[link]: new readers.LinkURL()},
+ isCurrent: target => !!target[link]
+});
+exports.Link = LinkContext;
+
+const isEditable = Symbol("context/editable?")
+const EditableContext = Class({
+ extends: Context,
+ read: {[isEditable]: new readers.isEditable()},
+ isCurrent: target => target[isEditable]
+});
+exports.Editable = EditableContext;
+
+
+const mediaType = Symbol("context/mediaType")
+
+const ImageContext = Class({
+ extends: Context,
+ read: {[mediaType]: new readers.MediaType()},
+ isCurrent: target => target[mediaType] === "image"
+});
+exports.Image = ImageContext;
+
+
+const VideoContext = Class({
+ extends: Context,
+ read: {[mediaType]: new readers.MediaType()},
+ isCurrent: target => target[mediaType] === "video"
+});
+exports.Video = VideoContext;
+
+
+const AudioContext = Class({
+ extends: Context,
+ read: {[mediaType]: new readers.MediaType()},
+ isCurrent: target => target[mediaType] === "audio"
+});
+exports.Audio = AudioContext;
+
+const isSelectorMatch = Symbol("context/selector/mathches?")
+const SelectorContext = Class({
+ extends: Context,
+ initialize(selector) {
+ this.selector = selector;
+ // Each instance of selector context will need to store read
+ // data into different field, so that case with multilpe selector
+ // contexts won't cause a conflicts.
+ this[isSelectorMatch] = Symbol(selector);
+ this.read = {[this[isSelectorMatch]]: new readers.SelectorMatch(selector)};
+ },
+ isCurrent(target) {
+ return target[this[isSelectorMatch]];
+ }
+});
+exports.Selector = SelectorContext;
+
+const url = Symbol("context/url");
+const URLContext = Class({
+ extends: Context,
+ initialize(pattern) {
+ this.pattern = new MatchPattern(pattern);
+ },
+ read: {[url]: new readers.PageURL()},
+ isCurrent(target) {
+ return this.pattern.test(target[url]);
+ }
+});
+exports.URL = URLContext;
+
+var PredicateContext = Class({
+ extends: Context,
+ initialize(isMatch) {
+ if (typeof(isMatch) !== "function") {
+ throw TypeError("Predicate context mus be passed a function");
+ }
+
+ this.isMatch = isMatch
+ },
+ isCurrent(target) {
+ return this.isMatch(target);
+ }
+});
+exports.Predicate = PredicateContext;
diff --git a/toolkit/jetpack/sdk/context-menu/core.js b/toolkit/jetpack/sdk/context-menu/core.js
new file mode 100644
index 000000000..c64cddfe8
--- /dev/null
+++ b/toolkit/jetpack/sdk/context-menu/core.js
@@ -0,0 +1,384 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const Contexts = require("./context");
+const Readers = require("./readers");
+const Component = require("../ui/component");
+const { Class } = require("../core/heritage");
+const { map, filter, object, reduce, keys, symbols,
+ pairs, values, each, some, isEvery, count } = require("../util/sequence");
+const { loadModule } = require("framescript/manager");
+const { Cu, Cc, Ci } = require("chrome");
+const prefs = require("sdk/preferences/service");
+
+const globalMessageManager = Cc["@mozilla.org/globalmessagemanager;1"]
+ .getService(Ci.nsIMessageListenerManager);
+const preferencesService = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefService).
+ getBranch(null);
+
+
+const readTable = Symbol("context-menu/read-table");
+const nameTable = Symbol("context-menu/name-table");
+const onContext = Symbol("context-menu/on-context");
+const isMatching = Symbol("context-menu/matching-handler?");
+
+exports.onContext = onContext;
+exports.readTable = readTable;
+exports.nameTable = nameTable;
+
+
+const propagateOnContext = (item, data) =>
+ each(child => child[onContext](data), item.state.children);
+
+const isContextMatch = item => !item[isMatching] || item[isMatching]();
+
+// For whatever reason addWeakMessageListener does not seems to work as our
+// instance seems to dropped even though it's alive. This is simple workaround
+// to avoid dead object excetptions.
+const WeakMessageListener = function(receiver, handler="receiveMessage") {
+ this.receiver = receiver
+ this.handler = handler
+};
+WeakMessageListener.prototype = {
+ constructor: WeakMessageListener,
+ receiveMessage(message) {
+ if (Cu.isDeadWrapper(this.receiver)) {
+ message.target.messageManager.removeMessageListener(message.name, this);
+ }
+ else {
+ this.receiver[this.handler](message);
+ }
+ }
+};
+
+const OVERFLOW_THRESH = "extensions.addon-sdk.context-menu.overflowThreshold";
+const onMessage = Symbol("context-menu/message-listener");
+const onPreferceChange = Symbol("context-menu/preference-change");
+const ContextMenuExtension = Class({
+ extends: Component,
+ initialize: Component,
+ setup() {
+ const messageListener = new WeakMessageListener(this, onMessage);
+ loadModule(globalMessageManager, "framescript/context-menu", true, "onContentFrame");
+ globalMessageManager.addMessageListener("sdk/context-menu/read", messageListener);
+ globalMessageManager.addMessageListener("sdk/context-menu/readers?", messageListener);
+
+ preferencesService.addObserver(OVERFLOW_THRESH, this, false);
+ },
+ observe(_, __, name) {
+ if (name === OVERFLOW_THRESH) {
+ const overflowThreshold = prefs.get(OVERFLOW_THRESH, 10);
+ this[Component.patch]({overflowThreshold});
+ }
+ },
+ [onMessage]({name, data, target}) {
+ if (name === "sdk/context-menu/read")
+ this[onContext]({target, data});
+ if (name === "sdk/context-menu/readers?")
+ target.messageManager.sendAsyncMessage("sdk/context-menu/readers",
+ JSON.parse(JSON.stringify(this.state.readers)));
+ },
+ [Component.initial](options={}, children) {
+ const element = options.element || null;
+ const target = options.target || null;
+ const readers = Object.create(null);
+ const users = Object.create(null);
+ const registry = new WeakSet();
+ const overflowThreshold = prefs.get(OVERFLOW_THRESH, 10);
+
+ return { target, children: [], readers, users, element,
+ registry, overflowThreshold };
+ },
+ [Component.isUpdated](before, after) {
+ // Update only if target changed, since there is no point in re-rendering
+ // when children are. Also new items added won't be in sync with a latest
+ // context target so we should really just render before drawing context
+ // menu.
+ return before.target !== after.target;
+ },
+ [Component.render]({element, children, overflowThreshold}) {
+ if (!element) return null;
+
+ const items = children.filter(isContextMatch);
+ const body = items.length === 0 ? items :
+ items.length < overflowThreshold ? [new Separator(),
+ ...items] :
+ [{tagName: "menu",
+ className: "sdk-context-menu-overflow-menu",
+ label: "Add-ons",
+ accesskey: "A",
+ children: [{tagName: "menupopup",
+ children: items}]}];
+ return {
+ element: element,
+ tagName: "menugroup",
+ style: "-moz-box-orient: vertical;",
+ className: "sdk-context-menu-extension",
+ children: body
+ }
+ },
+ // Adds / remove child to it's own list.
+ add(item) {
+ this[Component.patch]({children: this.state.children.concat(item)});
+ },
+ remove(item) {
+ this[Component.patch]({
+ children: this.state.children.filter(x => x !== item)
+ });
+ },
+ register(item) {
+ const { users, registry } = this.state;
+ if (registry.has(item)) return;
+ registry.add(item);
+
+ // Each (ContextHandler) item has a readTable that is a
+ // map of keys to readers extracting them from the content.
+ // During the registraction we update intrnal record of unique
+ // readers and users per reader. Most context will have a reader
+ // shared across all instances there for map of users per reader
+ // is stored separately from the reader so that removing reader
+ // will occur only when no users remain.
+ const table = item[readTable];
+ // Context readers store data in private symbols so we need to
+ // collect both table keys and private symbols.
+ const names = [...keys(table), ...symbols(table)];
+ const readers = map(name => table[name], names);
+ // Create delta for registered readers that will be merged into
+ // internal readers table.
+ const added = filter(x => !users[x.id], readers);
+ const delta = object(...map(x => [x.id, x], added));
+
+ const update = reduce((update, reader) => {
+ const n = update[reader.id] || 0;
+ update[reader.id] = n + 1;
+ return update;
+ }, Object.assign({}, users), readers);
+
+ // Patch current state with a changes that registered item caused.
+ this[Component.patch]({users: update,
+ readers: Object.assign(this.state.readers, delta)});
+
+ if (count(added)) {
+ globalMessageManager.broadcastAsyncMessage("sdk/context-menu/readers",
+ JSON.parse(JSON.stringify(delta)));
+ }
+ },
+ unregister(item) {
+ const { users, registry } = this.state;
+ if (!registry.has(item)) return;
+ registry.delete(item);
+
+ const table = item[readTable];
+ const names = [...keys(table), ...symbols(table)];
+ const readers = map(name => table[name], names);
+ const update = reduce((update, reader) => {
+ update[reader.id] = update[reader.id] - 1;
+ return update;
+ }, Object.assign({}, users), readers);
+ const removed = filter(id => !update[id], keys(update));
+ const delta = object(...map(x => [x, null], removed));
+
+ this[Component.patch]({users: update,
+ readers: Object.assign(this.state.readers, delta)});
+
+ if (count(removed)) {
+ globalMessageManager.broadcastAsyncMessage("sdk/context-menu/readers",
+ JSON.parse(JSON.stringify(delta)));
+ }
+ },
+
+ [onContext]({data, target}) {
+ propagateOnContext(this, data);
+ const document = target.ownerDocument;
+ const element = document.getElementById("contentAreaContextMenu");
+
+ this[Component.patch]({target: data, element: element});
+ }
+});this,
+exports.ContextMenuExtension = ContextMenuExtension;
+
+// Takes an item options and
+const makeReadTable = ({context, read}) => {
+ // Result of this function is a tuple of all readers &
+ // name, reader id pairs.
+
+ // Filter down to contexts that have a reader associated.
+ const contexts = filter(context => context.read, context);
+ // Merge all contexts read maps to a single hash, note that there should be
+ // no name collisions as context implementations expect to use private
+ // symbols for storing it's read data.
+ return Object.assign({}, ...map(({read}) => read, contexts), read);
+}
+
+const readTarget = (nameTable, data) =>
+ object(...map(([name, id]) => [name, data[id]], nameTable))
+
+const ContextHandler = Class({
+ extends: Component,
+ initialize: Component,
+ get context() {
+ return this.state.options.context;
+ },
+ get read() {
+ return this.state.options.read;
+ },
+ [Component.initial](options) {
+ return {
+ table: makeReadTable(options),
+ requiredContext: filter(context => context.isRequired, options.context),
+ optionalContext: filter(context => !context.isRequired, options.context)
+ }
+ },
+ [isMatching]() {
+ const {target, requiredContext, optionalContext} = this.state;
+ return isEvery(context => context.isCurrent(target), requiredContext) &&
+ (count(optionalContext) === 0 ||
+ some(context => context.isCurrent(target), optionalContext));
+ },
+ setup() {
+ const table = makeReadTable(this.state.options);
+ this[readTable] = table;
+ this[nameTable] = [...map(symbol => [symbol, table[symbol].id], symbols(table)),
+ ...map(name => [name, table[name].id], keys(table))];
+
+
+ contextMenu.register(this);
+
+ each(child => contextMenu.remove(child), this.state.children);
+ contextMenu.add(this);
+ },
+ dispose() {
+ contextMenu.remove(this);
+
+ each(child => contextMenu.unregister(child), this.state.children);
+ contextMenu.unregister(this);
+ },
+ // Internal `Symbol("onContext")` method is invoked when "contextmenu" event
+ // occurs in content process. Context handles with children delegate to each
+ // child and patch it's internal state to reflect new contextmenu target.
+ [onContext](data) {
+ propagateOnContext(this, data);
+ this[Component.patch]({target: readTarget(this[nameTable], data)});
+ }
+});
+const isContextHandler = item => item instanceof ContextHandler;
+
+exports.ContextHandler = ContextHandler;
+
+const Menu = Class({
+ extends: ContextHandler,
+ [isMatching]() {
+ return ContextHandler.prototype[isMatching].call(this) &&
+ this.state.children.filter(isContextHandler)
+ .some(isContextMatch);
+ },
+ [Component.render]({children, options}) {
+ const items = children.filter(isContextMatch);
+ return {tagName: "menu",
+ className: "sdk-context-menu menu-iconic",
+ label: options.label,
+ accesskey: options.accesskey,
+ image: options.icon,
+ children: [{tagName: "menupopup",
+ children: items}]};
+ }
+});
+exports.Menu = Menu;
+
+const onCommand = Symbol("context-menu/item/onCommand");
+const Item = Class({
+ extends: ContextHandler,
+ get onClick() {
+ return this.state.options.onClick;
+ },
+ [Component.render]({options}) {
+ const {label, icon, accesskey} = options;
+ return {tagName: "menuitem",
+ className: "sdk-context-menu-item menuitem-iconic",
+ label,
+ accesskey,
+ image: icon,
+ oncommand: this};
+ },
+ handleEvent(event) {
+ if (this.onClick)
+ this.onClick(this.state.target);
+ }
+});
+exports.Item = Item;
+
+var Separator = Class({
+ extends: Component,
+ initialize: Component,
+ [Component.render]() {
+ return {tagName: "menuseparator",
+ className: "sdk-context-menu-separator"}
+ },
+ [onContext]() {
+
+ }
+});
+exports.Separator = Separator;
+
+exports.Contexts = Contexts;
+exports.Readers = Readers;
+
+const createElement = (vnode, {document}) => {
+ const node = vnode.namespace ?
+ document.createElementNS(vnode.namespace, vnode.tagName) :
+ document.createElement(vnode.tagName);
+
+ node.setAttribute("data-component-path", vnode[Component.path]);
+
+ each(([key, value]) => {
+ if (key === "tagName") {
+ return;
+ }
+ if (key === "children") {
+ return;
+ }
+
+ if (key.startsWith("on")) {
+ node.addEventListener(key.substr(2), value)
+ return;
+ }
+
+ if (typeof(value) !== "object" &&
+ typeof(value) !== "function" &&
+ value !== void(0) &&
+ value !== null)
+ {
+ if (key === "className") {
+ node[key] = value;
+ }
+ else {
+ node.setAttribute(key, value);
+ }
+ return;
+ }
+ }, pairs(vnode));
+
+ each(child => node.appendChild(createElement(child, {document})), vnode.children);
+ return node;
+};
+
+const htmlWriter = tree => {
+ if (tree !== null) {
+ const root = tree.element;
+ const node = createElement(tree, {document: root.ownerDocument});
+ const before = root.querySelector("[data-component-path='/']");
+ if (before) {
+ root.replaceChild(node, before);
+ } else {
+ root.appendChild(node);
+ }
+ }
+};
+
+
+const contextMenu = ContextMenuExtension();
+exports.contextMenu = contextMenu;
+Component.mount(contextMenu, htmlWriter);
diff --git a/toolkit/jetpack/sdk/context-menu/readers.js b/toolkit/jetpack/sdk/context-menu/readers.js
new file mode 100644
index 000000000..5078f8f29
--- /dev/null
+++ b/toolkit/jetpack/sdk/context-menu/readers.js
@@ -0,0 +1,112 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+const { Class } = require("../core/heritage");
+const { extend } = require("../util/object");
+const { memoize, method, identity } = require("../lang/functional");
+
+const serializeCategory = ({type}) => ({ category: `reader/${type}()` });
+
+const Reader = Class({
+ initialize() {
+ this.id = `reader/${this.type}()`
+ },
+ toJSON() {
+ return serializeCategory(this);
+ }
+});
+
+
+const MediaTypeReader = Class({ extends: Reader, type: "MediaType" });
+exports.MediaType = MediaTypeReader;
+
+const LinkURLReader = Class({ extends: Reader, type: "LinkURL" });
+exports.LinkURL = LinkURLReader;
+
+const SelectionReader = Class({ extends: Reader, type: "Selection" });
+exports.Selection = SelectionReader;
+
+const isPageReader = Class({ extends: Reader, type: "isPage" });
+exports.isPage = isPageReader;
+
+const isFrameReader = Class({ extends: Reader, type: "isFrame" });
+exports.isFrame = isFrameReader;
+
+const isEditable = Class({ extends: Reader, type: "isEditable"});
+exports.isEditable = isEditable;
+
+
+
+const ParameterizedReader = Class({
+ extends: Reader,
+ readParameter: function(value) {
+ return value;
+ },
+ toJSON: function() {
+ var json = serializeCategory(this);
+ json[this.parameter] = this[this.parameter];
+ return json;
+ },
+ initialize(...params) {
+ if (params.length) {
+ this[this.parameter] = this.readParameter(...params);
+ }
+ this.id = `reader/${this.type}(${JSON.stringify(this[this.parameter])})`;
+ }
+});
+exports.ParameterizedReader = ParameterizedReader;
+
+
+const QueryReader = Class({
+ extends: ParameterizedReader,
+ type: "Query",
+ parameter: "path"
+});
+exports.Query = QueryReader;
+
+
+const AttributeReader = Class({
+ extends: ParameterizedReader,
+ type: "Attribute",
+ parameter: "name"
+});
+exports.Attribute = AttributeReader;
+
+const SrcURLReader = Class({
+ extends: AttributeReader,
+ name: "src",
+});
+exports.SrcURL = SrcURLReader;
+
+const PageURLReader = Class({
+ extends: QueryReader,
+ path: "ownerDocument.URL",
+});
+exports.PageURL = PageURLReader;
+
+const SelectorMatchReader = Class({
+ extends: ParameterizedReader,
+ type: "SelectorMatch",
+ parameter: "selector"
+});
+exports.SelectorMatch = SelectorMatchReader;
+
+const extractors = new WeakMap();
+extractors.id = 0;
+
+
+var Extractor = Class({
+ extends: ParameterizedReader,
+ type: "Extractor",
+ parameter: "source",
+ initialize: function(f) {
+ this[this.parameter] = String(f);
+ if (!extractors.has(f)) {
+ extractors.id = extractors.id + 1;
+ extractors.set(f, extractors.id);
+ }
+
+ this.id = `reader/${this.type}.for(${extractors.get(f)})`
+ }
+});
+exports.Extractor = Extractor;
diff --git a/toolkit/jetpack/sdk/context-menu@2.js b/toolkit/jetpack/sdk/context-menu@2.js
new file mode 100644
index 000000000..45ad804e9
--- /dev/null
+++ b/toolkit/jetpack/sdk/context-menu@2.js
@@ -0,0 +1,32 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const shared = require("toolkit/require");
+const { Item, Separator, Menu, Contexts, Readers } = shared.require("sdk/context-menu/core");
+const { setupDisposable, disposeDisposable, Disposable } = require("sdk/core/disposable")
+const { Class } = require("sdk/core/heritage")
+
+const makeDisposable = Type => Class({
+ extends: Type,
+ implements: [Disposable],
+ initialize: Type.prototype.initialize,
+ setup(...params) {
+ Type.prototype.setup.call(this, ...params);
+ setupDisposable(this);
+ },
+ dispose(...params) {
+ disposeDisposable(this);
+ Type.prototype.dispose.call(this, ...params);
+ }
+});
+
+exports.Separator = Separator;
+exports.Contexts = Contexts;
+exports.Readers = Readers;
+
+// Subclass Item & Menu shared classes so their items
+// will be unloaded when add-on is unloaded.
+exports.Item = makeDisposable(Item);
+exports.Menu = makeDisposable(Menu);
diff --git a/toolkit/jetpack/sdk/core/disposable.js b/toolkit/jetpack/sdk/core/disposable.js
new file mode 100644
index 000000000..19f7eaa9f
--- /dev/null
+++ b/toolkit/jetpack/sdk/core/disposable.js
@@ -0,0 +1,186 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Class } = require("./heritage");
+const { Observer, subscribe, unsubscribe, observe } = require("./observer");
+const { isWeak } = require("./reference");
+const SDKWeakSet = require("../lang/weak-set");
+
+const method = require("../../method/core");
+
+const unloadSubject = require('@loader/unload');
+const addonUnloadTopic = "sdk:loader:destroy";
+
+const uninstall = method("disposable/uninstall");
+exports.uninstall = uninstall;
+
+const shutdown = method("disposable/shutdown");
+exports.shutdown = shutdown;
+
+const disable = method("disposable/disable");
+exports.disable = disable;
+
+const upgrade = method("disposable/upgrade");
+exports.upgrade = upgrade;
+
+const downgrade = method("disposable/downgrade");
+exports.downgrade = downgrade;
+
+const unload = method("disposable/unload");
+exports.unload = unload;
+
+const dispose = method("disposable/dispose");
+exports.dispose = dispose;
+dispose.define(Object, object => object.dispose());
+
+const setup = method("disposable/setup");
+exports.setup = setup;
+setup.define(Object, (object, ...args) => object.setup(...args));
+
+// DisposablesUnloadObserver is the class which subscribe the
+// Observer Service to be notified when the add-on loader is
+// unloading to be able to dispose all the existent disposables.
+const DisposablesUnloadObserver = Class({
+ implements: [Observer],
+ initialize: function(...args) {
+ // Set of the non-weak disposables registered to be disposed.
+ this.disposables = new Set();
+ // Target of the weak disposables registered to be disposed
+ // (and tracked on this target using the SDK weak-set module).
+ this.weakDisposables = {};
+ },
+ subscribe(disposable) {
+ if (isWeak(disposable)) {
+ SDKWeakSet.add(this.weakDisposables, disposable);
+ } else {
+ this.disposables.add(disposable);
+ }
+ },
+ unsubscribe(disposable) {
+ if (isWeak(disposable)) {
+ SDKWeakSet.remove(this.weakDisposables, disposable);
+ } else {
+ this.disposables.delete(disposable);
+ }
+ },
+ tryUnloadDisposable(disposable) {
+ try {
+ if (disposable) {
+ unload(disposable);
+ }
+ } catch(e) {
+ console.error("Error unloading a",
+ isWeak(disposable) ? "weak disposable" : "disposable",
+ disposable, e);
+ }
+ },
+ unloadAll() {
+ // Remove all the subscribed disposables.
+ for (let disposable of this.disposables) {
+ this.tryUnloadDisposable(disposable);
+ }
+
+ this.disposables.clear();
+
+ // Remove all the subscribed weak disposables.
+ for (let disposable of SDKWeakSet.iterator(this.weakDisposables)) {
+ this.tryUnloadDisposable(disposable);
+ }
+
+ SDKWeakSet.clear(this.weakDisposables);
+ }
+});
+const disposablesUnloadObserver = new DisposablesUnloadObserver();
+
+// The DisposablesUnloadObserver instance is the only object which subscribes
+// the Observer Service directly, it observes add-on unload notifications in
+// order to trigger `unload` on all its subscribed disposables.
+observe.define(DisposablesUnloadObserver, (obj, subject, topic, data) => {
+ const isUnloadTopic = topic === addonUnloadTopic;
+ const isUnloadSubject = subject.wrappedJSObject === unloadSubject;
+ if (isUnloadTopic && isUnloadSubject) {
+ unsubscribe(disposablesUnloadObserver, addonUnloadTopic);
+ disposablesUnloadObserver.unloadAll();
+ }
+});
+
+subscribe(disposablesUnloadObserver, addonUnloadTopic, false);
+
+// Set's up disposable instance.
+const setupDisposable = disposable => {
+ disposablesUnloadObserver.subscribe(disposable);
+};
+exports.setupDisposable = setupDisposable;
+
+// Tears down disposable instance.
+const disposeDisposable = disposable => {
+ disposablesUnloadObserver.unsubscribe(disposable);
+};
+exports.disposeDisposable = disposeDisposable;
+
+// Base type that takes care of disposing it's instances on add-on unload.
+// Also makes sure to remove unload listener if it's already being disposed.
+const Disposable = Class({
+ initialize: function(...args) {
+ // First setup instance before initializing it's disposal. If instance
+ // fails to initialize then there is no instance to be disposed at the
+ // unload.
+ setup(this, ...args);
+ setupDisposable(this);
+ },
+ destroy: function(reason) {
+ // Destroying disposable removes unload handler so that attempt to dispose
+ // won't be made at unload & delegates to dispose.
+ disposeDisposable(this);
+ unload(this, reason);
+ },
+ setup: function() {
+ // Implement your initialize logic here.
+ },
+ dispose: function() {
+ // Implement your cleanup logic here.
+ }
+});
+exports.Disposable = Disposable;
+
+const unloaders = {
+ destroy: dispose,
+ uninstall: uninstall,
+ shutdown: shutdown,
+ disable: disable,
+ upgrade: upgrade,
+ downgrade: downgrade
+};
+
+const unloaded = new WeakMap();
+unload.define(Disposable, (disposable, reason) => {
+ if (!unloaded.get(disposable)) {
+ unloaded.set(disposable, true);
+ // Pick an unload handler associated with an unload
+ // reason (falling back to destroy if not found) and
+ // delegate unloading to it.
+ const unload = unloaders[reason] || unloaders.destroy;
+ unload(disposable);
+ }
+});
+
+// If add-on is disabled manually, it's being upgraded, downgraded
+// or uninstalled `dispose` is invoked to undo any changes that
+// has being done by it in this session.
+disable.define(Disposable, dispose);
+downgrade.define(Disposable, dispose);
+upgrade.define(Disposable, dispose);
+uninstall.define(Disposable, dispose);
+
+// If application is shut down no dispose is invoked as undo-ing
+// changes made by instance is likely to just waste of resources &
+// increase shutdown time. Although specefic components may choose
+// to implement shutdown handler that does something better.
+shutdown.define(Disposable, disposable => {});
diff --git a/toolkit/jetpack/sdk/core/heritage.js b/toolkit/jetpack/sdk/core/heritage.js
new file mode 100644
index 000000000..fc87ba1f5
--- /dev/null
+++ b/toolkit/jetpack/sdk/core/heritage.js
@@ -0,0 +1,184 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+var getPrototypeOf = Object.getPrototypeOf;
+var getNames = x => [...Object.getOwnPropertyNames(x),
+ ...Object.getOwnPropertySymbols(x)];
+var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
+var create = Object.create;
+var freeze = Object.freeze;
+var unbind = Function.call.bind(Function.bind, Function.call);
+
+// This shortcut makes sure that we do perform desired operations, even if
+// associated methods have being overridden on the used object.
+var owns = unbind(Object.prototype.hasOwnProperty);
+var apply = unbind(Function.prototype.apply);
+var slice = Array.slice || unbind(Array.prototype.slice);
+var reduce = Array.reduce || unbind(Array.prototype.reduce);
+var map = Array.map || unbind(Array.prototype.map);
+var concat = Array.concat || unbind(Array.prototype.concat);
+
+// Utility function to get own properties descriptor map.
+function getOwnPropertyDescriptors(object) {
+ return reduce(getNames(object), function(descriptor, name) {
+ descriptor[name] = getOwnPropertyDescriptor(object, name);
+ return descriptor;
+ }, {});
+}
+
+function isDataProperty(property) {
+ var value = property.value;
+ var type = typeof(property.value);
+ return "value" in property &&
+ (type !== "object" || value === null) &&
+ type !== "function";
+}
+
+function getDataProperties(object) {
+ var properties = getOwnPropertyDescriptors(object);
+ return getNames(properties).reduce(function(result, name) {
+ var property = properties[name];
+ if (isDataProperty(property)) {
+ result[name] = {
+ value: property.value,
+ writable: true,
+ configurable: true,
+ enumerable: false
+ };
+ }
+ return result;
+ }, {})
+}
+
+/**
+ * Takes `source` object as an argument and returns identical object
+ * with the difference that all own properties will be non-enumerable
+ */
+function obscure(source) {
+ var descriptor = reduce(getNames(source), function(descriptor, name) {
+ var property = getOwnPropertyDescriptor(source, name);
+ property.enumerable = false;
+ descriptor[name] = property;
+ return descriptor;
+ }, {});
+ return create(getPrototypeOf(source), descriptor);
+}
+exports.obscure = obscure;
+
+/**
+ * Takes arbitrary number of source objects and returns fresh one, that
+ * inherits from the same prototype as a first argument and implements all
+ * own properties of all argument objects. If two or more argument objects
+ * have own properties with the same name, the property is overridden, with
+ * precedence from right to left, implying, that properties of the object on
+ * the left are overridden by a same named property of the object on the right.
+ */
+var mix = function(source) {
+ var descriptor = reduce(slice(arguments), function(descriptor, source) {
+ return reduce(getNames(source), function(descriptor, name) {
+ descriptor[name] = getOwnPropertyDescriptor(source, name);
+ return descriptor;
+ }, descriptor);
+ }, {});
+
+ return create(getPrototypeOf(source), descriptor);
+};
+exports.mix = mix;
+
+/**
+ * Returns a frozen object with that inherits from the given `prototype` and
+ * implements all own properties of the given `properties` object.
+ */
+function extend(prototype, properties) {
+ return create(prototype, getOwnPropertyDescriptors(properties));
+}
+exports.extend = extend;
+
+/**
+ * Returns a constructor function with a proper `prototype` setup. Returned
+ * constructor's `prototype` inherits from a given `options.extends` or
+ * `Class.prototype` if omitted and implements all the properties of the
+ * given `option`. If `options.implemens` array is passed, it's elements
+ * will be mixed into prototype as well. Also, `options.extends` can be
+ * a function or a prototype. If function than it's prototype is used as
+ * an ancestor of the prototype, if it's an object that it's used directly.
+ * Also `options.implements` may contain functions or objects, in case of
+ * functions their prototypes are used for mixing.
+ */
+var Class = new function() {
+ function prototypeOf(input) {
+ return typeof(input) === 'function' ? input.prototype : input;
+ }
+ var none = freeze([]);
+
+ return function Class(options) {
+ // Create descriptor with normalized `options.extends` and
+ // `options.implements`.
+ var descriptor = {
+ // Normalize extends property of `options.extends` to a prototype object
+ // in case it's constructor. If property is missing that fallback to
+ // `Type.prototype`.
+ extends: owns(options, 'extends') ?
+ prototypeOf(options.extends) : Class.prototype,
+ // Normalize `options.implements` to make sure that it's array of
+ // prototype objects instead of constructor functions.
+ implements: owns(options, 'implements') ?
+ freeze(map(options.implements, prototypeOf)) : none
+ };
+
+ // Create array of property descriptors who's properties will be defined
+ // on the resulting prototype. Note: Using reflection `concat` instead of
+ // method as it may be overridden.
+ var descriptors = concat(descriptor.implements, options, descriptor, {
+ constructor: constructor
+ });
+
+ // Note: we use reflection `apply` in the constructor instead of method
+ // call since later may be overridden.
+ function constructor() {
+ var instance = create(prototype, attributes);
+ if (initialize) apply(initialize, instance, arguments);
+ return instance;
+ }
+ // Create `prototype` that inherits from given ancestor passed as
+ // `options.extends`, falling back to `Type.prototype`, implementing all
+ // properties of given `options.implements` and `options` itself.
+ var prototype = extend(descriptor.extends, mix.apply(mix, descriptors));
+ var initialize = prototype.initialize;
+
+ // Combine ancestor attributes with prototype's attributes so that
+ // ancestors attributes also become initializeable.
+ var attributes = mix(descriptor.extends.constructor.attributes || {},
+ getDataProperties(prototype));
+
+ constructor.attributes = attributes;
+ Object.defineProperty(constructor, 'prototype', {
+ configurable: false,
+ writable: false,
+ value: prototype
+ });
+ return constructor;
+ };
+}
+Class.prototype = extend(null, obscure({
+ constructor: function constructor() {
+ this.initialize.apply(this, arguments);
+ return this;
+ },
+ initialize: function initialize() {
+ // Do your initialization logic here
+ },
+ // Copy useful properties from `Object.prototype`.
+ toString: Object.prototype.toString,
+ toLocaleString: Object.prototype.toLocaleString,
+ toSource: Object.prototype.toSource,
+ valueOf: Object.prototype.valueOf,
+ isPrototypeOf: Object.prototype.isPrototypeOf
+}));
+exports.Class = freeze(Class);
diff --git a/toolkit/jetpack/sdk/core/namespace.js b/toolkit/jetpack/sdk/core/namespace.js
new file mode 100644
index 000000000..3ceb73b72
--- /dev/null
+++ b/toolkit/jetpack/sdk/core/namespace.js
@@ -0,0 +1,43 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const create = Object.create;
+const prototypeOf = Object.getPrototypeOf;
+
+/**
+ * Returns a new namespace, function that may can be used to access an
+ * namespaced object of the argument argument. Namespaced object are associated
+ * with owner objects via weak references. Namespaced objects inherit from the
+ * owners ancestor namespaced object. If owner's ancestor is `null` then
+ * namespaced object inherits from given `prototype`. Namespaces can be used
+ * to define internal APIs that can be shared via enclosing `namespace`
+ * function.
+ * @examples
+ * const internals = ns();
+ * internals(object).secret = secret;
+ */
+function ns() {
+ const map = new WeakMap();
+ return function namespace(target) {
+ if (!target) // If `target` is not an object return `target` itself.
+ return target;
+ // If target has no namespaced object yet, create one that inherits from
+ // the target prototype's namespaced object.
+ if (!map.has(target))
+ map.set(target, create(namespace(prototypeOf(target) || null)));
+
+ return map.get(target);
+ };
+};
+
+// `Namespace` is a e4x function in the scope, so we export the function also as
+// `ns` as alias to avoid clashing.
+exports.ns = ns;
+exports.Namespace = ns;
diff --git a/toolkit/jetpack/sdk/core/observer.js b/toolkit/jetpack/sdk/core/observer.js
new file mode 100644
index 000000000..7e11bf8f9
--- /dev/null
+++ b/toolkit/jetpack/sdk/core/observer.js
@@ -0,0 +1,89 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+
+const { Cc, Ci, Cr, Cu } = require("chrome");
+const { Class } = require("./heritage");
+const { isWeak } = require("./reference");
+const method = require("../../method/core");
+
+const observerService = Cc['@mozilla.org/observer-service;1'].
+ getService(Ci.nsIObserverService);
+
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+const addObserver = ShimWaiver.getProperty(observerService, "addObserver");
+const removeObserver = ShimWaiver.getProperty(observerService, "removeObserver");
+
+// This is a method that will be invoked when notification observer
+// subscribed to occurs.
+const observe = method("observer/observe");
+exports.observe = observe;
+
+// Method to subscribe to the observer notification.
+const subscribe = method("observe/subscribe");
+exports.subscribe = subscribe;
+
+
+// Method to unsubscribe from the observer notifications.
+const unsubscribe = method("observer/unsubscribe");
+exports.unsubscribe = unsubscribe;
+
+
+// This is wrapper class that takes a `delegate` and produces
+// instance of `nsIObserver` which will delegate to a given
+// object when observer notification occurs.
+const ObserverDelegee = Class({
+ initialize: function(delegate) {
+ this.delegate = delegate;
+ },
+ QueryInterface: function(iid) {
+ if (!iid.equals(Ci.nsIObserver) &&
+ !iid.equals(Ci.nsISupportsWeakReference) &&
+ !iid.equals(Ci.nsISupports))
+ throw Cr.NS_ERROR_NO_INTERFACE;
+
+ return this;
+ },
+ observe: function(subject, topic, data) {
+ observe(this.delegate, subject, topic, data);
+ }
+});
+
+
+// Class that can be either mixed in or inherited from in
+// order to subscribe / unsubscribe for observer notifications.
+const Observer = Class({});
+exports.Observer = Observer;
+
+// Weak maps that associates instance of `ObserverDelegee` with
+// an actual observer. It ensures that `ObserverDelegee` instance
+// won't be GC-ed until given `observer` is.
+const subscribers = new WeakMap();
+
+// Implementation of `subscribe` for `Observer` type just registers
+// observer for an observer service. If `isWeak(observer)` is `true`
+// observer service won't hold strong reference to a given `observer`.
+subscribe.define(Observer, (observer, topic) => {
+ if (!subscribers.has(observer)) {
+ const delegee = new ObserverDelegee(observer);
+ subscribers.set(observer, delegee);
+ addObserver(delegee, topic, isWeak(observer));
+ }
+});
+
+// Unsubscribes `observer` from observer notifications for the
+// given `topic`.
+unsubscribe.define(Observer, (observer, topic) => {
+ const delegee = subscribers.get(observer);
+ if (delegee) {
+ subscribers.delete(observer);
+ removeObserver(delegee, topic);
+ }
+});
diff --git a/toolkit/jetpack/sdk/core/promise.js b/toolkit/jetpack/sdk/core/promise.js
new file mode 100644
index 000000000..f4bd7b0f5
--- /dev/null
+++ b/toolkit/jetpack/sdk/core/promise.js
@@ -0,0 +1,118 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+/*
+ * Uses `Promise.jsm` as a core implementation, with additional sugar
+ * from previous implementation, with inspiration from `Q` and `when`
+ *
+ * https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm
+ * https://github.com/cujojs/when
+ * https://github.com/kriskowal/q
+ */
+const PROMISE_URI = 'resource://gre/modules/Promise.jsm';
+
+getEnvironment.call(this, function ({ require, exports, module, Cu }) {
+
+const Promise = Cu.import(PROMISE_URI, {}).Promise;
+const { Debugging, defer, resolve, all, reject, race } = Promise;
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+var promised = (function() {
+ // Note: Define shortcuts and utility functions here in order to avoid
+ // slower property accesses and unnecessary closure creations on each
+ // call of this popular function.
+
+ var call = Function.call;
+ var concat = Array.prototype.concat;
+
+ // Utility function that does following:
+ // execute([ f, self, args...]) => f.apply(self, args)
+ function execute (args) {
+ return call.apply(call, args);
+ }
+
+ // Utility function that takes promise of `a` array and maybe promise `b`
+ // as arguments and returns promise for `a.concat(b)`.
+ function promisedConcat(promises, unknown) {
+ return promises.then(function (values) {
+ return resolve(unknown)
+ .then(value => values.concat([value]));
+ });
+ }
+
+ return function promised(f, prototype) {
+ /**
+ Returns a wrapped `f`, which when called returns a promise that resolves to
+ `f(...)` passing all the given arguments to it, which by the way may be
+ promises. Optionally second `prototype` argument may be provided to be used
+ a prototype for a returned promise.
+
+ ## Example
+
+ var promise = promised(Array)(1, promise(2), promise(3))
+ promise.then(console.log) // => [ 1, 2, 3 ]
+ **/
+
+ return function promised(...args) {
+ // create array of [ f, this, args... ]
+ return [f, this, ...args].
+ // reduce it via `promisedConcat` to get promised array of fulfillments
+ reduce(promisedConcat, resolve([], prototype)).
+ // finally map that to promise of `f.apply(this, args...)`
+ then(execute);
+ };
+ };
+})();
+
+exports.promised = promised;
+exports.all = all;
+exports.defer = defer;
+exports.resolve = resolve;
+exports.reject = reject;
+exports.race = race;
+exports.Promise = Promise;
+exports.Debugging = Debugging;
+});
+
+function getEnvironment (callback) {
+ let Cu, _exports, _module, _require;
+
+ // CommonJS / SDK
+ if (typeof(require) === 'function') {
+ Cu = require('chrome').Cu;
+ _exports = exports;
+ _module = module;
+ _require = require;
+ }
+ // JSM
+ else if (String(this).indexOf('BackstagePass') >= 0) {
+ Cu = this['Components'].utils;
+ _exports = this.Promise = {};
+ _module = { uri: __URI__, id: 'promise/core' };
+ _require = uri => {
+ let imports = {};
+ Cu.import(uri, imports);
+ return imports;
+ };
+ this.EXPORTED_SYMBOLS = ['Promise'];
+ // mozIJSSubScriptLoader.loadSubscript
+ } else if (~String(this).indexOf('Sandbox')) {
+ Cu = this['Components'].utils;
+ _exports = this;
+ _module = { id: 'promise/core' };
+ _require = uri => {};
+ }
+
+ callback({
+ Cu: Cu,
+ exports: _exports,
+ module: _module,
+ require: _require
+ });
+}
+
diff --git a/toolkit/jetpack/sdk/core/reference.js b/toolkit/jetpack/sdk/core/reference.js
new file mode 100644
index 000000000..04549cd0f
--- /dev/null
+++ b/toolkit/jetpack/sdk/core/reference.js
@@ -0,0 +1,29 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const method = require("../../method/core");
+const { Class } = require("./heritage");
+
+// Object that inherit or mix WeakRefence inn will register
+// weak observes for system notifications.
+const WeakReference = Class({});
+exports.WeakReference = WeakReference;
+
+
+// If `isWeak(object)` is `true` observer installed
+// for such `object` will be weak, meaning that it will
+// be GC-ed if nothing else but observer is observing it.
+// By default everything except `WeakReference` will return
+// `false`.
+const isWeak = method("reference/weak?");
+exports.isWeak = isWeak;
+
+isWeak.define(Object, _ => false);
+isWeak.define(WeakReference, _ => true);
diff --git a/toolkit/jetpack/sdk/deprecated/api-utils.js b/toolkit/jetpack/sdk/deprecated/api-utils.js
new file mode 100644
index 000000000..856fc50cb
--- /dev/null
+++ b/toolkit/jetpack/sdk/deprecated/api-utils.js
@@ -0,0 +1,197 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "deprecated"
+};
+
+const { merge } = require("../util/object");
+const { union } = require("../util/array");
+const { isNil, isRegExp } = require("../lang/type");
+
+// The possible return values of getTypeOf.
+const VALID_TYPES = [
+ "array",
+ "boolean",
+ "function",
+ "null",
+ "number",
+ "object",
+ "string",
+ "undefined",
+ "regexp"
+];
+
+const { isArray } = Array;
+
+/**
+ * Returns a validated options dictionary given some requirements. If any of
+ * the requirements are not met, an exception is thrown.
+ *
+ * @param options
+ * An object, the options dictionary to validate. It's not modified.
+ * If it's null or otherwise falsey, an empty object is assumed.
+ * @param requirements
+ * An object whose keys are the expected keys in options. Any key in
+ * options that is not present in requirements is ignored. Each value
+ * in requirements is itself an object describing the requirements of
+ * its key. There are four optional keys in this object:
+ * map: A function that's passed the value of the key in options.
+ * map's return value is taken as the key's value in the final
+ * validated options, is, and ok. If map throws an exception
+ * it's caught and discarded, and the key's value is its value in
+ * options.
+ * is: An array containing any number of the typeof type names. If
+ * the key's value is none of these types, it fails validation.
+ * Arrays, null and regexps are identified by the special type names
+ * "array", "null", "regexp"; "object" will not match either. No type
+ * coercion is done.
+ * ok: A function that's passed the key's value. If it returns
+ * false, the value fails validation.
+ * msg: If the key's value fails validation, an exception is thrown.
+ * This string will be used as its message. If undefined, a
+ * generic message is used, unless is is defined, in which case
+ * the message will state that the value needs to be one of the
+ * given types.
+ * @return An object whose keys are those keys in requirements that are also in
+ * options and whose values are the corresponding return values of map
+ * or the corresponding values in options. Note that any keys not
+ * shared by both requirements and options are not in the returned
+ * object.
+ */
+exports.validateOptions = function validateOptions(options, requirements) {
+ options = options || {};
+ let validatedOptions = {};
+
+ for (let key in requirements) {
+ let isOptional = false;
+ let mapThrew = false;
+ let req = requirements[key];
+ let [optsVal, keyInOpts] = (key in options) ?
+ [options[key], true] :
+ [undefined, false];
+ if (req.map) {
+ try {
+ optsVal = req.map(optsVal);
+ }
+ catch (err) {
+ if (err instanceof RequirementError)
+ throw err;
+
+ mapThrew = true;
+ }
+ }
+ if (req.is) {
+ let types = req.is;
+
+ if (!isArray(types) && isArray(types.is))
+ types = types.is;
+
+ if (isArray(types)) {
+ isOptional = ['undefined', 'null'].every(v => ~types.indexOf(v));
+
+ // Sanity check the caller's type names.
+ types.forEach(function (typ) {
+ if (VALID_TYPES.indexOf(typ) < 0) {
+ let msg = 'Internal error: invalid requirement type "' + typ + '".';
+ throw new Error(msg);
+ }
+ });
+ if (types.indexOf(getTypeOf(optsVal)) < 0)
+ throw new RequirementError(key, req);
+ }
+ }
+
+ if (req.ok && ((!isOptional || !isNil(optsVal)) && !req.ok(optsVal)))
+ throw new RequirementError(key, req);
+
+ if (keyInOpts || (req.map && !mapThrew && optsVal !== undefined))
+ validatedOptions[key] = optsVal;
+ }
+
+ return validatedOptions;
+};
+
+exports.addIterator = function addIterator(obj, keysValsGenerator) {
+ obj.__iterator__ = function(keysOnly, keysVals) {
+ let keysValsIterator = keysValsGenerator.call(this);
+
+ // "for (.. in ..)" gets only keys, "for each (.. in ..)" gets values,
+ // and "for (.. in Iterator(..))" gets [key, value] pairs.
+ let index = keysOnly ? 0 : 1;
+ while (true)
+ yield keysVals ? keysValsIterator.next() : keysValsIterator.next()[index];
+ };
+};
+
+// Similar to typeof, except arrays, null and regexps are identified by "array" and
+// "null" and "regexp", not "object".
+var getTypeOf = exports.getTypeOf = function getTypeOf(val) {
+ let typ = typeof(val);
+ if (typ === "object") {
+ if (!val)
+ return "null";
+ if (isArray(val))
+ return "array";
+ if (isRegExp(val))
+ return "regexp";
+ }
+ return typ;
+}
+
+function RequirementError(key, requirement) {
+ Error.call(this);
+
+ this.name = "RequirementError";
+
+ let msg = requirement.msg;
+ if (!msg) {
+ msg = 'The option "' + key + '" ';
+ msg += requirement.is ?
+ "must be one of the following types: " + requirement.is.join(", ") :
+ "is invalid.";
+ }
+
+ this.message = msg;
+}
+RequirementError.prototype = Object.create(Error.prototype);
+
+var string = { is: ['string', 'undefined', 'null'] };
+exports.string = string;
+
+var number = { is: ['number', 'undefined', 'null'] };
+exports.number = number;
+
+var boolean = { is: ['boolean', 'undefined', 'null'] };
+exports.boolean = boolean;
+
+var object = { is: ['object', 'undefined', 'null'] };
+exports.object = object;
+
+var array = { is: ['array', 'undefined', 'null'] };
+exports.array = array;
+
+var isTruthyType = type => !(type === 'undefined' || type === 'null');
+var findTypes = v => { while (!isArray(v) && v.is) v = v.is; return v };
+
+function required(req) {
+ let types = (findTypes(req) || VALID_TYPES).filter(isTruthyType);
+
+ return merge({}, req, {is: types});
+}
+exports.required = required;
+
+function optional(req) {
+ req = merge({is: []}, req);
+ req.is = findTypes(req).filter(isTruthyType).concat('undefined', 'null');
+
+ return req;
+}
+exports.optional = optional;
+
+function either(...types) {
+ return union.apply(null, types.map(findTypes));
+}
+exports.either = either;
diff --git a/toolkit/jetpack/sdk/deprecated/events/assembler.js b/toolkit/jetpack/sdk/deprecated/events/assembler.js
new file mode 100644
index 000000000..bb297c24f
--- /dev/null
+++ b/toolkit/jetpack/sdk/deprecated/events/assembler.js
@@ -0,0 +1,54 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Class } = require("../../core/heritage");
+const { removeListener, on } = require("../../dom/events");
+
+/**
+ * Event targets
+ * can be added / removed by calling `observe / ignore` methods. Composer should
+ * provide array of event types it wishes to handle as property
+ * `supportedEventsTypes` and function for handling all those events as
+ * `handleEvent` property.
+ */
+exports.DOMEventAssembler = Class({
+ /**
+ * Function that is supposed to handle all the supported events (that are
+ * present in the `supportedEventsTypes`) from all the observed
+ * `eventTargets`.
+ * @param {Event} event
+ * Event being dispatched.
+ */
+ handleEvent() {
+ throw new TypeError("Instance of DOMEventAssembler must implement `handleEvent` method");
+ },
+ /**
+ * Array of supported event names.
+ * @type {String[]}
+ */
+ get supportedEventsTypes() {
+ throw new TypeError("Instance of DOMEventAssembler must implement `handleEvent` field");
+ },
+ /**
+ * Adds `eventTarget` to the list of observed `eventTarget`s. Listeners for
+ * supported events will be registered on the given `eventTarget`.
+ * @param {EventTarget} eventTarget
+ */
+ observe: function observe(eventTarget) {
+ this.supportedEventsTypes.forEach(function(eventType) {
+ on(eventTarget, eventType, this);
+ }, this);
+ },
+ /**
+ * Removes `eventTarget` from the list of observed `eventTarget`s. Listeners
+ * for all supported events will be unregistered from the given `eventTarget`.
+ * @param {EventTarget} eventTarget
+ */
+ ignore: function ignore(eventTarget) {
+ this.supportedEventsTypes.forEach(function(eventType) {
+ removeListener(eventTarget, eventType, this);
+ }, this);
+ }
+});
diff --git a/toolkit/jetpack/sdk/deprecated/sync-worker.js b/toolkit/jetpack/sdk/deprecated/sync-worker.js
new file mode 100644
index 000000000..71cadac36
--- /dev/null
+++ b/toolkit/jetpack/sdk/deprecated/sync-worker.js
@@ -0,0 +1,288 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ *
+ * `deprecated/sync-worker` was previously `content/worker`, that was
+ * incompatible with e10s. we are in the process of switching to the new
+ * asynchronous `Worker`, which behaves slightly differently in some edge
+ * cases, so we are keeping this one around for a short period.
+ * try to switch to the new one as soon as possible..
+ *
+ */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Class } = require('../core/heritage');
+const { EventTarget } = require('../event/target');
+const { on, off, emit, setListeners } = require('../event/core');
+const {
+ attach, detach, destroy
+} = require('../content/utils');
+const { method } = require('../lang/functional');
+const { Ci, Cu, Cc } = require('chrome');
+const unload = require('../system/unload');
+const events = require('../system/events');
+const { getInnerId } = require("../window/utils");
+const { WorkerSandbox } = require('../content/sandbox');
+const { isPrivate } = require('../private-browsing/utils');
+
+// A weak map of workers to hold private attributes that
+// should not be exposed
+const workers = new WeakMap();
+
+var modelFor = (worker) => workers.get(worker);
+
+const ERR_DESTROYED =
+ "Couldn't find the worker to receive this message. " +
+ "The script may not be initialized yet, or may already have been unloaded.";
+
+const ERR_FROZEN = "The page is currently hidden and can no longer be used " +
+ "until it is visible again.";
+
+/**
+ * Message-passing facility for communication between code running
+ * in the content and add-on process.
+ * @see https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/content_worker
+ */
+const Worker = Class({
+ implements: [EventTarget],
+ initialize: function WorkerConstructor (options) {
+ // Save model in weak map to not expose properties
+ let model = createModel();
+ workers.set(this, model);
+
+ options = options || {};
+
+ if ('contentScriptFile' in options)
+ this.contentScriptFile = options.contentScriptFile;
+ if ('contentScriptOptions' in options)
+ this.contentScriptOptions = options.contentScriptOptions;
+ if ('contentScript' in options)
+ this.contentScript = options.contentScript;
+ if ('injectInDocument' in options)
+ this.injectInDocument = !!options.injectInDocument;
+
+ setListeners(this, options);
+
+ unload.ensure(this, "destroy");
+
+ // Ensure that worker.port is initialized for contentWorker to be able
+ // to send events during worker initialization.
+ this.port = createPort(this);
+
+ model.documentUnload = documentUnload.bind(this);
+ model.pageShow = pageShow.bind(this);
+ model.pageHide = pageHide.bind(this);
+
+ if ('window' in options)
+ attach(this, options.window);
+ },
+
+ /**
+ * Sends a message to the worker's global scope. Method takes single
+ * argument, which represents data to be sent to the worker. The data may
+ * be any primitive type value or `JSON`. Call of this method asynchronously
+ * emits `message` event with data value in the global scope of this
+ * worker.
+ *
+ * `message` event listeners can be set either by calling
+ * `self.on` with a first argument string `"message"` or by
+ * implementing `onMessage` function in the global scope of this worker.
+ * @param {Number|String|JSON} data
+ */
+ postMessage: function (...data) {
+ let model = modelFor(this);
+ let args = ['message'].concat(data);
+ if (!model.inited) {
+ model.earlyEvents.push(args);
+ return;
+ }
+ processMessage.apply(null, [this].concat(args));
+ },
+
+ get url () {
+ let model = modelFor(this);
+ // model.window will be null after detach
+ return model.window ? model.window.document.location.href : null;
+ },
+
+ get contentURL () {
+ let model = modelFor(this);
+ return model.window ? model.window.document.URL : null;
+ },
+
+ // Implemented to provide some of the previous features of exposing sandbox
+ // so that Worker can be extended
+ getSandbox: function () {
+ return modelFor(this).contentWorker;
+ },
+
+ toString: function () { return '[object Worker]'; },
+ attach: method(attach),
+ detach: method(detach),
+ destroy: method(destroy)
+});
+exports.Worker = Worker;
+
+attach.define(Worker, function (worker, window) {
+ let model = modelFor(worker);
+ model.window = window;
+ // Track document unload to destroy this worker.
+ // We can't watch for unload event on page's window object as it
+ // prevents bfcache from working:
+ // https://developer.mozilla.org/En/Working_with_BFCache
+ model.windowID = getInnerId(model.window);
+ events.on("inner-window-destroyed", model.documentUnload);
+
+ // will set model.contentWorker pointing to the private API:
+ model.contentWorker = WorkerSandbox(worker, model.window);
+
+ // Listen to pagehide event in order to freeze the content script
+ // while the document is frozen in bfcache:
+ model.window.addEventListener("pageshow", model.pageShow, true);
+ model.window.addEventListener("pagehide", model.pageHide, true);
+
+ // Mainly enable worker.port.emit to send event to the content worker
+ model.inited = true;
+ model.frozen = false;
+
+ // Fire off `attach` event
+ emit(worker, 'attach', window);
+
+ // Process all events and messages that were fired before the
+ // worker was initialized.
+ model.earlyEvents.forEach(args => processMessage.apply(null, [worker].concat(args)));
+});
+
+/**
+ * Remove all internal references to the attached document
+ * Tells _port to unload itself and removes all the references from itself.
+ */
+detach.define(Worker, function (worker, reason) {
+ let model = modelFor(worker);
+
+ // maybe unloaded before content side is created
+ if (model.contentWorker) {
+ model.contentWorker.destroy(reason);
+ }
+
+ model.contentWorker = null;
+ if (model.window) {
+ model.window.removeEventListener("pageshow", model.pageShow, true);
+ model.window.removeEventListener("pagehide", model.pageHide, true);
+ }
+ model.window = null;
+ // This method may be called multiple times,
+ // avoid dispatching `detach` event more than once
+ if (model.windowID) {
+ model.windowID = null;
+ events.off("inner-window-destroyed", model.documentUnload);
+ model.earlyEvents.length = 0;
+ emit(worker, 'detach');
+ }
+ model.inited = false;
+});
+
+isPrivate.define(Worker, ({ tab }) => isPrivate(tab));
+
+/**
+ * Tells content worker to unload itself and
+ * removes all the references from itself.
+ */
+destroy.define(Worker, function (worker, reason) {
+ detach(worker, reason);
+ modelFor(worker).inited = true;
+ // Specifying no type or listener removes all listeners
+ // from target
+ off(worker);
+ off(worker.port);
+});
+
+/**
+ * Events fired by workers
+ */
+function documentUnload ({ subject, data }) {
+ let model = modelFor(this);
+ let innerWinID = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
+ if (innerWinID != model.windowID) return false;
+ detach(this);
+ return true;
+}
+
+function pageShow () {
+ let model = modelFor(this);
+ model.contentWorker.emitSync('pageshow');
+ emit(this, 'pageshow');
+ model.frozen = false;
+}
+
+function pageHide () {
+ let model = modelFor(this);
+ model.contentWorker.emitSync('pagehide');
+ emit(this, 'pagehide');
+ model.frozen = true;
+}
+
+/**
+ * Fired from postMessage and emitEventToContent, or from the earlyMessage
+ * queue when fired before the content is loaded. Sends arguments to
+ * contentWorker if able
+ */
+
+function processMessage (worker, ...args) {
+ let model = modelFor(worker) || {};
+ if (!model.contentWorker)
+ throw new Error(ERR_DESTROYED);
+ if (model.frozen)
+ throw new Error(ERR_FROZEN);
+ model.contentWorker.emit.apply(null, args);
+}
+
+function createModel () {
+ return {
+ // List of messages fired before worker is initialized
+ earlyEvents: [],
+ // Is worker connected to the content worker sandbox ?
+ inited: false,
+ // Is worker being frozen? i.e related document is frozen in bfcache.
+ // Content script should not be reachable if frozen.
+ frozen: true,
+ /**
+ * Reference to the content side of the worker.
+ * @type {WorkerGlobalScope}
+ */
+ contentWorker: null,
+ /**
+ * Reference to the window that is accessible from
+ * the content scripts.
+ * @type {Object}
+ */
+ window: null
+ };
+}
+
+function createPort (worker) {
+ let port = EventTarget();
+ port.emit = emitEventToContent.bind(null, worker);
+ return port;
+}
+
+/**
+ * Emit a custom event to the content script,
+ * i.e. emit this event on `self.port`
+ */
+function emitEventToContent (worker, ...eventArgs) {
+ let model = modelFor(worker);
+ let args = ['event'].concat(eventArgs);
+ if (!model.inited) {
+ model.earlyEvents.push(args);
+ return;
+ }
+ processMessage.apply(null, [worker].concat(args));
+}
diff --git a/toolkit/jetpack/sdk/deprecated/unit-test-finder.js b/toolkit/jetpack/sdk/deprecated/unit-test-finder.js
new file mode 100644
index 000000000..e38629f45
--- /dev/null
+++ b/toolkit/jetpack/sdk/deprecated/unit-test-finder.js
@@ -0,0 +1,199 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "deprecated"
+};
+
+const file = require("../io/file");
+const { Loader } = require("../test/loader");
+
+const { isNative } = require('@loader/options');
+
+const cuddlefish = isNative ? require("toolkit/loader") : require("../loader/cuddlefish");
+
+const { defer, resolve } = require("../core/promise");
+const { getAddon } = require("../addon/installer");
+const { id } = require("sdk/self");
+const { newURI } = require('sdk/url/utils');
+const { getZipReader } = require("../zip/utils");
+
+const { Cc, Ci, Cu } = require("chrome");
+const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm", {});
+var ios = Cc['@mozilla.org/network/io-service;1']
+ .getService(Ci.nsIIOService);
+
+const CFX_TEST_REGEX = /(([^\/]+\/)(?:lib\/)?)?(tests?\/test-[^\.\/]+)\.js$/;
+const JPM_TEST_REGEX = /^()(tests?\/test-[^\.\/]+)\.js$/;
+
+const { mapcat, map, filter, fromEnumerator } = require("sdk/util/sequence");
+
+const toFile = x => x.QueryInterface(Ci.nsIFile);
+const isTestFile = ({leafName}) => leafName.substr(0, 5) == "test-" && leafName.substr(-3, 3) == ".js";
+const getFileURI = x => ios.newFileURI(x).spec;
+
+const getDirectoryEntries = file => map(toFile, fromEnumerator(_ => file.directoryEntries));
+const getTestFiles = directory => filter(isTestFile, getDirectoryEntries(directory));
+const getTestURIs = directory => map(getFileURI, getTestFiles(directory));
+
+const isDirectory = x => x.isDirectory();
+const getTestEntries = directory => mapcat(entry =>
+ /^tests?$/.test(entry.leafName) ? getTestURIs(entry) : getTestEntries(entry),
+ filter(isDirectory, getDirectoryEntries(directory)));
+
+const removeDups = (array) => array.reduce((result, value) => {
+ if (value != result[result.length - 1]) {
+ result.push(value);
+ }
+ return result;
+}, []);
+
+const getSuites = function getSuites({ id, filter }) {
+ const TEST_REGEX = isNative ? JPM_TEST_REGEX : CFX_TEST_REGEX;
+
+ return getAddon(id).then(addon => {
+ let fileURI = addon.getResourceURI("tests/");
+ let isPacked = fileURI.scheme == "jar";
+ let xpiURI = addon.getResourceURI();
+ let file = xpiURI.QueryInterface(Ci.nsIFileURL).file;
+ let suites = [];
+ let addEntry = (entry) => {
+ if (filter(entry) && TEST_REGEX.test(entry)) {
+ let suite = (isNative ? "./" : "") + (RegExp.$2 || "") + RegExp.$3;
+ suites.push(suite);
+ }
+ }
+
+ if (isPacked) {
+ return getZipReader(file).then(zip => {
+ let entries = zip.findEntries(null);
+ while (entries.hasMore()) {
+ let entry = entries.getNext();
+ addEntry(entry);
+ }
+ zip.close();
+
+ // sort and remove dups
+ suites = removeDups(suites.sort());
+ return suites;
+ })
+ }
+ else {
+ let tests = [...getTestEntries(file)];
+ let rootURI = addon.getResourceURI("/");
+ tests.forEach((entry) => {
+ addEntry(entry.replace(rootURI.spec, ""));
+ });
+ }
+
+ // sort and remove dups
+ suites = removeDups(suites.sort());
+ return suites;
+ });
+}
+exports.getSuites = getSuites;
+
+const makeFilters = function makeFilters(options) {
+ options = options || {};
+
+ // A filter string is {fileNameRegex}[:{testNameRegex}] - ie, a colon
+ // optionally separates a regex for the test fileName from a regex for the
+ // testName.
+ if (options.filter) {
+ let colonPos = options.filter.indexOf(':');
+ let filterFileRegex, filterNameRegex;
+
+ if (colonPos === -1) {
+ filterFileRegex = new RegExp(options.filter);
+ filterNameRegex = { test: () => true }
+ }
+ else {
+ filterFileRegex = new RegExp(options.filter.substr(0, colonPos));
+ filterNameRegex = new RegExp(options.filter.substr(colonPos + 1));
+ }
+
+ return {
+ fileFilter: (name) => filterFileRegex.test(name),
+ testFilter: (name) => filterNameRegex.test(name)
+ }
+ }
+
+ return {
+ fileFilter: () => true,
+ testFilter: () => true
+ };
+}
+exports.makeFilters = makeFilters;
+
+var loader = Loader(module);
+const NOT_TESTS = ['setup', 'teardown'];
+
+var TestFinder = exports.TestFinder = function TestFinder(options) {
+ this.filter = options.filter;
+ this.testInProcess = options.testInProcess === false ? false : true;
+ this.testOutOfProcess = options.testOutOfProcess === true ? true : false;
+};
+
+TestFinder.prototype = {
+ findTests: function findTests() {
+ let { fileFilter, testFilter } = makeFilters({ filter: this.filter });
+
+ return getSuites({ id: id, filter: fileFilter }).then(suites => {
+ let testsRemaining = [];
+
+ let getNextTest = () => {
+ if (testsRemaining.length) {
+ return testsRemaining.shift();
+ }
+
+ if (!suites.length) {
+ return null;
+ }
+
+ let suite = suites.shift();
+
+ // Load each test file as a main module in its own loader instance
+ // `suite` is defined by cuddlefish/manifest.py:ManifestBuilder.build
+ let suiteModule;
+
+ try {
+ suiteModule = cuddlefish.main(loader, suite);
+ }
+ catch (e) {
+ if (/Unsupported Application/i.test(e.message)) {
+ // If `Unsupported Application` error thrown during test,
+ // skip the test suite
+ suiteModule = {
+ 'test suite skipped': assert => assert.pass(e.message)
+ };
+ }
+ else {
+ console.exception(e);
+ throw e;
+ }
+ }
+
+ if (this.testInProcess) {
+ for (let name of Object.keys(suiteModule).sort()) {
+ if (NOT_TESTS.indexOf(name) === -1 && testFilter(name)) {
+ testsRemaining.push({
+ setup: suiteModule.setup,
+ teardown: suiteModule.teardown,
+ testFunction: suiteModule[name],
+ name: suite + "." + name
+ });
+ }
+ }
+ }
+
+ return getNextTest();
+ };
+
+ return {
+ getNext: () => resolve(getNextTest())
+ };
+ });
+ }
+};
diff --git a/toolkit/jetpack/sdk/deprecated/unit-test.js b/toolkit/jetpack/sdk/deprecated/unit-test.js
new file mode 100644
index 000000000..32bba8f6b
--- /dev/null
+++ b/toolkit/jetpack/sdk/deprecated/unit-test.js
@@ -0,0 +1,584 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "deprecated"
+};
+
+const timer = require("../timers");
+const cfxArgs = require("../test/options");
+const { getTabs, closeTab, getURI, getTabId, getSelectedTab } = require("../tabs/utils");
+const { windows, isBrowser, getMostRecentBrowserWindow } = require("../window/utils");
+const { defer, all, Debugging: PromiseDebugging, resolve } = require("../core/promise");
+const { getInnerId } = require("../window/utils");
+const { cleanUI } = require("../test/utils");
+
+const findAndRunTests = function findAndRunTests(options) {
+ var TestFinder = require("./unit-test-finder").TestFinder;
+ var finder = new TestFinder({
+ filter: options.filter,
+ testInProcess: options.testInProcess,
+ testOutOfProcess: options.testOutOfProcess
+ });
+ var runner = new TestRunner({fs: options.fs});
+ finder.findTests().then(tests => {
+ runner.startMany({
+ tests: tests,
+ stopOnError: options.stopOnError,
+ onDone: options.onDone
+ });
+ });
+};
+exports.findAndRunTests = findAndRunTests;
+
+var runnerWindows = new WeakMap();
+var runnerTabs = new WeakMap();
+
+const TestRunner = function TestRunner(options) {
+ options = options || {};
+
+ // remember the id's for the open window and tab
+ let window = getMostRecentBrowserWindow();
+ runnerWindows.set(this, getInnerId(window));
+ runnerTabs.set(this, getTabId(getSelectedTab(window)));
+
+ this.fs = options.fs;
+ this.console = options.console || console;
+ this.passed = 0;
+ this.failed = 0;
+ this.testRunSummary = [];
+ this.expectFailNesting = 0;
+ this.done = TestRunner.prototype.done.bind(this);
+};
+
+TestRunner.prototype = {
+ toString: function toString() {
+ return "[object TestRunner]";
+ },
+
+ DEFAULT_PAUSE_TIMEOUT: (cfxArgs.parseable ? 300000 : 15000), //Five minutes (5*60*1000ms)
+ PAUSE_DELAY: 500,
+
+ _logTestFailed: function _logTestFailed(why) {
+ if (!(why in this.test.errors))
+ this.test.errors[why] = 0;
+ this.test.errors[why]++;
+ },
+
+ _uncaughtErrorObserver: function({message, date, fileName, stack, lineNumber}) {
+ this.fail("There was an uncaught Promise rejection: " + message + " @ " +
+ fileName + ":" + lineNumber + "\n" + stack);
+ },
+
+ pass: function pass(message) {
+ if(!this.expectFailure) {
+ if ("testMessage" in this.console)
+ this.console.testMessage(true, true, this.test.name, message);
+ else
+ this.console.info("pass:", message);
+ this.passed++;
+ this.test.passed++;
+ this.test.last = message;
+ }
+ else {
+ this.expectFailure = false;
+ this._logTestFailed("failure");
+ if ("testMessage" in this.console) {
+ this.console.testMessage(true, false, this.test.name, message);
+ }
+ else {
+ this.console.error("fail:", 'Failure Expected: ' + message)
+ this.console.trace();
+ }
+ this.failed++;
+ this.test.failed++;
+ }
+ },
+
+ fail: function fail(message) {
+ if(!this.expectFailure) {
+ this._logTestFailed("failure");
+ if ("testMessage" in this.console) {
+ this.console.testMessage(false, false, this.test.name, message);
+ }
+ else {
+ this.console.error("fail:", message)
+ this.console.trace();
+ }
+ this.failed++;
+ this.test.failed++;
+ }
+ else {
+ this.expectFailure = false;
+ if ("testMessage" in this.console)
+ this.console.testMessage(false, true, this.test.name, message);
+ else
+ this.console.info("pass:", message);
+ this.passed++;
+ this.test.passed++;
+ this.test.last = message;
+ }
+ },
+
+ expectFail: function(callback) {
+ this.expectFailure = true;
+ callback();
+ this.expectFailure = false;
+ },
+
+ exception: function exception(e) {
+ this._logTestFailed("exception");
+ if (cfxArgs.parseable)
+ this.console.print("TEST-UNEXPECTED-FAIL | " + this.test.name + " | " + e + "\n");
+ this.console.exception(e);
+ this.failed++;
+ this.test.failed++;
+ },
+
+ assertMatches: function assertMatches(string, regexp, message) {
+ if (regexp.test(string)) {
+ if (!message)
+ message = uneval(string) + " matches " + uneval(regexp);
+ this.pass(message);
+ } else {
+ var no = uneval(string) + " doesn't match " + uneval(regexp);
+ if (!message)
+ message = no;
+ else
+ message = message + " (" + no + ")";
+ this.fail(message);
+ }
+ },
+
+ assertRaises: function assertRaises(func, predicate, message) {
+ try {
+ func();
+ if (message)
+ this.fail(message + " (no exception thrown)");
+ else
+ this.fail("function failed to throw exception");
+ } catch (e) {
+ var errorMessage;
+ if (typeof(e) == "string")
+ errorMessage = e;
+ else
+ errorMessage = e.message;
+ if (typeof(predicate) == "string")
+ this.assertEqual(errorMessage, predicate, message);
+ else
+ this.assertMatches(errorMessage, predicate, message);
+ }
+ },
+
+ assert: function assert(a, message) {
+ if (!a) {
+ if (!message)
+ message = "assertion failed, value is " + a;
+ this.fail(message);
+ } else
+ this.pass(message || "assertion successful");
+ },
+
+ assertNotEqual: function assertNotEqual(a, b, message) {
+ if (a != b) {
+ if (!message)
+ message = "a != b != " + uneval(a);
+ this.pass(message);
+ } else {
+ var equality = uneval(a) + " == " + uneval(b);
+ if (!message)
+ message = equality;
+ else
+ message += " (" + equality + ")";
+ this.fail(message);
+ }
+ },
+
+ assertEqual: function assertEqual(a, b, message) {
+ if (a == b) {
+ if (!message)
+ message = "a == b == " + uneval(a);
+ this.pass(message);
+ } else {
+ var inequality = uneval(a) + " != " + uneval(b);
+ if (!message)
+ message = inequality;
+ else
+ message += " (" + inequality + ")";
+ this.fail(message);
+ }
+ },
+
+ assertNotStrictEqual: function assertNotStrictEqual(a, b, message) {
+ if (a !== b) {
+ if (!message)
+ message = "a !== b !== " + uneval(a);
+ this.pass(message);
+ } else {
+ var equality = uneval(a) + " === " + uneval(b);
+ if (!message)
+ message = equality;
+ else
+ message += " (" + equality + ")";
+ this.fail(message);
+ }
+ },
+
+ assertStrictEqual: function assertStrictEqual(a, b, message) {
+ if (a === b) {
+ if (!message)
+ message = "a === b === " + uneval(a);
+ this.pass(message);
+ } else {
+ var inequality = uneval(a) + " !== " + uneval(b);
+ if (!message)
+ message = inequality;
+ else
+ message += " (" + inequality + ")";
+ this.fail(message);
+ }
+ },
+
+ assertFunction: function assertFunction(a, message) {
+ this.assertStrictEqual('function', typeof a, message);
+ },
+
+ assertUndefined: function(a, message) {
+ this.assertStrictEqual('undefined', typeof a, message);
+ },
+
+ assertNotUndefined: function(a, message) {
+ this.assertNotStrictEqual('undefined', typeof a, message);
+ },
+
+ assertNull: function(a, message) {
+ this.assertStrictEqual(null, a, message);
+ },
+
+ assertNotNull: function(a, message) {
+ this.assertNotStrictEqual(null, a, message);
+ },
+
+ assertObject: function(a, message) {
+ this.assertStrictEqual('[object Object]', Object.prototype.toString.apply(a), message);
+ },
+
+ assertString: function(a, message) {
+ this.assertStrictEqual('[object String]', Object.prototype.toString.apply(a), message);
+ },
+
+ assertArray: function(a, message) {
+ this.assertStrictEqual('[object Array]', Object.prototype.toString.apply(a), message);
+ },
+
+ assertNumber: function(a, message) {
+ this.assertStrictEqual('[object Number]', Object.prototype.toString.apply(a), message);
+ },
+
+ done: function done() {
+ if (this.isDone) {
+ return resolve();
+ }
+
+ this.isDone = true;
+ this.pass("This test is done.");
+
+ if (this.test.teardown) {
+ this.test.teardown(this);
+ }
+
+ if (this.waitTimeout !== null) {
+ timer.clearTimeout(this.waitTimeout);
+ this.waitTimeout = null;
+ }
+
+ // Do not leave any callback set when calling to `waitUntil`
+ this.waitUntilCallback = null;
+ if (this.test.passed == 0 && this.test.failed == 0) {
+ this._logTestFailed("empty test");
+
+ if ("testMessage" in this.console) {
+ this.console.testMessage(false, false, this.test.name, "Empty test");
+ }
+ else {
+ this.console.error("fail:", "Empty test")
+ }
+
+ this.failed++;
+ this.test.failed++;
+ }
+
+ let wins = windows(null, { includePrivate: true });
+ let winPromises = wins.map(win => {
+ return new Promise(resolve => {
+ if (["interactive", "complete"].indexOf(win.document.readyState) >= 0) {
+ resolve()
+ }
+ else {
+ win.addEventListener("DOMContentLoaded", function onLoad() {
+ win.removeEventListener("DOMContentLoaded", onLoad, false);
+ resolve();
+ }, false);
+ }
+ });
+ });
+
+ PromiseDebugging.flushUncaughtErrors();
+ PromiseDebugging.removeUncaughtErrorObserver(this._uncaughtErrorObserver);
+
+
+ return all(winPromises).then(() => {
+ let browserWins = wins.filter(isBrowser);
+ let tabs = browserWins.reduce((tabs, window) => tabs.concat(getTabs(window)), []);
+ let newTabID = getTabId(getSelectedTab(wins[0]));
+ let oldTabID = runnerTabs.get(this);
+ let hasMoreTabsOpen = browserWins.length && tabs.length != 1;
+ let failure = false;
+
+ if (wins.length != 1 || getInnerId(wins[0]) !== runnerWindows.get(this)) {
+ failure = true;
+ this.fail("Should not be any unexpected windows open");
+ }
+ else if (hasMoreTabsOpen) {
+ failure = true;
+ this.fail("Should not be any unexpected tabs open");
+ }
+ else if (oldTabID != newTabID) {
+ failure = true;
+ runnerTabs.set(this, newTabID);
+ this.fail("Should not be any new tabs left open, old id: " + oldTabID + " new id: " + newTabID);
+ }
+
+ if (failure) {
+ console.log("Windows open:");
+ for (let win of wins) {
+ if (isBrowser(win)) {
+ tabs = getTabs(win);
+ console.log(win.location + " - " + tabs.map(getURI).join(", "));
+ }
+ else {
+ console.log(win.location);
+ }
+ }
+ }
+
+ return failure;
+ }).
+ then(failure => {
+ if (!failure) {
+ this.pass("There was a clean UI.");
+ return null;
+ }
+ return cleanUI().then(() => {
+ this.pass("There is a clean UI.");
+ });
+ }).
+ then(() => {
+ this.testRunSummary.push({
+ name: this.test.name,
+ passed: this.test.passed,
+ failed: this.test.failed,
+ errors: Object.keys(this.test.errors).join(", ")
+ });
+
+ if (this.onDone !== null) {
+ let onDone = this.onDone;
+ this.onDone = null;
+ timer.setTimeout(_ => onDone(this));
+ }
+ }).
+ catch(console.exception);
+ },
+
+ // Set of assertion functions to wait for an assertion to become true
+ // These functions take the same arguments as the TestRunner.assert* methods.
+ waitUntil: function waitUntil() {
+ return this._waitUntil(this.assert, arguments);
+ },
+
+ waitUntilNotEqual: function waitUntilNotEqual() {
+ return this._waitUntil(this.assertNotEqual, arguments);
+ },
+
+ waitUntilEqual: function waitUntilEqual() {
+ return this._waitUntil(this.assertEqual, arguments);
+ },
+
+ waitUntilMatches: function waitUntilMatches() {
+ return this._waitUntil(this.assertMatches, arguments);
+ },
+
+ /**
+ * Internal function that waits for an assertion to become true.
+ * @param {Function} assertionMethod
+ * Reference to a TestRunner assertion method like test.assert,
+ * test.assertEqual, ...
+ * @param {Array} args
+ * List of arguments to give to the previous assertion method.
+ * All functions in this list are going to be called to retrieve current
+ * assertion values.
+ */
+ _waitUntil: function waitUntil(assertionMethod, args) {
+ let { promise, resolve } = defer();
+ let count = 0;
+ let maxCount = this.DEFAULT_PAUSE_TIMEOUT / this.PAUSE_DELAY;
+
+ // We need to ensure that test is asynchronous
+ if (!this.waitTimeout)
+ this.waitUntilDone(this.DEFAULT_PAUSE_TIMEOUT);
+
+ let finished = false;
+ let test = this;
+
+ // capture a traceback before we go async.
+ let traceback = require("../console/traceback");
+ let stack = traceback.get();
+ stack.splice(-2, 2);
+ let currentWaitStack = traceback.format(stack);
+ let timeout = null;
+
+ function loop(stopIt) {
+ timeout = null;
+
+ // Build a mockup object to fake TestRunner API and intercept calls to
+ // pass and fail methods, in order to retrieve nice error messages
+ // and assertion result
+ let mock = {
+ pass: function (msg) {
+ test.pass(msg);
+ test.waitUntilCallback = null;
+ if (!stopIt)
+ resolve();
+ },
+ fail: function (msg) {
+ // If we are called on test timeout, we stop the loop
+ // and print which test keeps failing:
+ if (stopIt) {
+ test.console.error("test assertion never became true:\n",
+ msg + "\n",
+ currentWaitStack);
+ if (timeout)
+ timer.clearTimeout(timeout);
+ return;
+ }
+ timeout = timer.setTimeout(loop, test.PAUSE_DELAY);
+ }
+ };
+
+ // Automatically call args closures in order to build arguments for
+ // assertion function
+ let appliedArgs = [];
+ for (let i = 0, l = args.length; i < l; i++) {
+ let a = args[i];
+ if (typeof a == "function") {
+ try {
+ a = a();
+ }
+ catch(e) {
+ test.fail("Exception when calling asynchronous assertion: " + e +
+ "\n" + e.stack);
+ return resolve();
+ }
+ }
+ appliedArgs.push(a);
+ }
+
+ // Finally call assertion function with current assertion values
+ assertionMethod.apply(mock, appliedArgs);
+ }
+ loop();
+ this.waitUntilCallback = loop;
+
+ return promise;
+ },
+
+ waitUntilDone: function waitUntilDone(ms) {
+ if (ms === undefined)
+ ms = this.DEFAULT_PAUSE_TIMEOUT;
+
+ var self = this;
+
+ function tiredOfWaiting() {
+ self._logTestFailed("timed out");
+ if ("testMessage" in self.console) {
+ self.console.testMessage(false, false, self.test.name,
+ `Test timed out (after: ${self.test.last})`);
+ }
+ else {
+ self.console.error("fail:", `Timed out (after: ${self.test.last})`)
+ }
+ if (self.waitUntilCallback) {
+ self.waitUntilCallback(true);
+ self.waitUntilCallback = null;
+ }
+ self.failed++;
+ self.test.failed++;
+ self.done();
+ }
+
+ // We may already have registered a timeout callback
+ if (this.waitTimeout)
+ timer.clearTimeout(this.waitTimeout);
+
+ this.waitTimeout = timer.setTimeout(tiredOfWaiting, ms);
+ },
+
+ startMany: function startMany(options) {
+ function runNextTest(self) {
+ let { tests, onDone } = options;
+
+ return tests.getNext().then((test) => {
+ if (options.stopOnError && self.test && self.test.failed) {
+ self.console.error("aborted: test failed and --stop-on-error was specified");
+ onDone(self);
+ }
+ else if (test) {
+ self.start({test: test, onDone: runNextTest});
+ }
+ else {
+ onDone(self);
+ }
+ });
+ }
+
+ return runNextTest(this).catch(console.exception);
+ },
+
+ start: function start(options) {
+ this.test = options.test;
+ this.test.passed = 0;
+ this.test.failed = 0;
+ this.test.errors = {};
+ this.test.last = 'START';
+ PromiseDebugging.clearUncaughtErrorObservers();
+ this._uncaughtErrorObserver = this._uncaughtErrorObserver.bind(this);
+ PromiseDebugging.addUncaughtErrorObserver(this._uncaughtErrorObserver);
+
+ this.isDone = false;
+ this.onDone = function(self) {
+ if (cfxArgs.parseable)
+ self.console.print("TEST-END | " + self.test.name + "\n");
+ options.onDone(self);
+ }
+ this.waitTimeout = null;
+
+ try {
+ if (cfxArgs.parseable)
+ this.console.print("TEST-START | " + this.test.name + "\n");
+ else
+ this.console.info("executing '" + this.test.name + "'");
+
+ if(this.test.setup) {
+ this.test.setup(this);
+ }
+ this.test.testFunction(this);
+ } catch (e) {
+ this.exception(e);
+ }
+ if (this.waitTimeout === null)
+ this.done();
+ }
+};
+exports.TestRunner = TestRunner;
diff --git a/toolkit/jetpack/sdk/deprecated/window-utils.js b/toolkit/jetpack/sdk/deprecated/window-utils.js
new file mode 100644
index 000000000..93c0ab7b8
--- /dev/null
+++ b/toolkit/jetpack/sdk/deprecated/window-utils.js
@@ -0,0 +1,193 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'deprecated'
+};
+
+const { Cc, Ci } = require('chrome');
+const events = require('../system/events');
+const { getInnerId, getOuterId, windows, isDocumentLoaded, isBrowser,
+ getMostRecentBrowserWindow, getToplevelWindow, getMostRecentWindow } = require('../window/utils');
+const { deprecateFunction } = require('../util/deprecate');
+const { ignoreWindow } = require('sdk/private-browsing/utils');
+const { isPrivateBrowsingSupported } = require('../self');
+
+const windowWatcher = Cc['@mozilla.org/embedcomp/window-watcher;1'].
+ getService(Ci.nsIWindowWatcher);
+const appShellService = Cc['@mozilla.org/appshell/appShellService;1'].
+ getService(Ci.nsIAppShellService);
+
+// Bug 834961: ignore private windows when they are not supported
+function getWindows() {
+ return windows(null, { includePrivate: isPrivateBrowsingSupported });
+}
+
+/**
+ * An iterator for XUL windows currently in the application.
+ *
+ * @return A generator that yields XUL windows exposing the
+ * nsIDOMWindow interface.
+ */
+function windowIterator() {
+ // Bug 752631: We only pass already loaded window in order to avoid
+ // breaking XUL windows DOM. DOM is broken when some JS code try
+ // to access DOM during "uninitialized" state of the related document.
+ let list = getWindows().filter(isDocumentLoaded);
+ for (let i = 0, l = list.length; i < l; i++) {
+ yield list[i];
+ }
+};
+exports.windowIterator = windowIterator;
+
+/**
+ * An iterator for browser windows currently open in the application.
+ * @returns {Function}
+ * A generator that yields browser windows exposing the `nsIDOMWindow`
+ * interface.
+ */
+function browserWindowIterator() {
+ for (let window of windowIterator()) {
+ if (isBrowser(window))
+ yield window;
+ }
+}
+exports.browserWindowIterator = browserWindowIterator;
+
+function WindowTracker(delegate) {
+ if (!(this instanceof WindowTracker)) {
+ return new WindowTracker(delegate);
+ }
+
+ this._delegate = delegate;
+
+ for (let window of getWindows())
+ this._regWindow(window);
+ windowWatcher.registerNotification(this);
+ this._onToplevelWindowReady = this._onToplevelWindowReady.bind(this);
+ events.on('toplevel-window-ready', this._onToplevelWindowReady);
+
+ require('../system/unload').ensure(this);
+
+ return this;
+};
+
+WindowTracker.prototype = {
+ _regLoadingWindow: function _regLoadingWindow(window) {
+ // Bug 834961: ignore private windows when they are not supported
+ if (ignoreWindow(window))
+ return;
+
+ window.addEventListener('load', this, true);
+ },
+
+ _unregLoadingWindow: function _unregLoadingWindow(window) {
+ // This may have no effect if we ignored the window in _regLoadingWindow().
+ window.removeEventListener('load', this, true);
+ },
+
+ _regWindow: function _regWindow(window) {
+ // Bug 834961: ignore private windows when they are not supported
+ if (ignoreWindow(window))
+ return;
+
+ if (window.document.readyState == 'complete') {
+ this._unregLoadingWindow(window);
+ this._delegate.onTrack(window);
+ } else
+ this._regLoadingWindow(window);
+ },
+
+ _unregWindow: function _unregWindow(window) {
+ if (window.document.readyState == 'complete') {
+ if (this._delegate.onUntrack)
+ this._delegate.onUntrack(window);
+ } else {
+ this._unregLoadingWindow(window);
+ }
+ },
+
+ unload: function unload() {
+ windowWatcher.unregisterNotification(this);
+ events.off('toplevel-window-ready', this._onToplevelWindowReady);
+ for (let window of getWindows())
+ this._unregWindow(window);
+ },
+
+ handleEvent: function handleEvent(event) {
+ try {
+ if (event.type == 'load' && event.target) {
+ var window = event.target.defaultView;
+ if (window)
+ this._regWindow(getToplevelWindow(window));
+ }
+ }
+ catch(e) {
+ console.exception(e);
+ }
+ },
+
+ _onToplevelWindowReady: function _onToplevelWindowReady({subject}) {
+ let window = getToplevelWindow(subject);
+ // ignore private windows if they are not supported
+ if (ignoreWindow(window))
+ return;
+ this._regWindow(window);
+ },
+
+ observe: function observe(subject, topic, data) {
+ try {
+ var window = subject.QueryInterface(Ci.nsIDOMWindow);
+ // ignore private windows if they are not supported
+ if (ignoreWindow(window))
+ return;
+ if (topic == 'domwindowclosed')
+ this._unregWindow(window);
+ }
+ catch(e) {
+ console.exception(e);
+ }
+ }
+};
+exports.WindowTracker = WindowTracker;
+
+Object.defineProperties(exports, {
+ activeWindow: {
+ enumerable: true,
+ get: function() {
+ return getMostRecentWindow(null);
+ },
+ set: function(window) {
+ try {
+ window.focus();
+ } catch (e) {}
+ }
+ },
+ activeBrowserWindow: {
+ enumerable: true,
+ get: getMostRecentBrowserWindow
+ }
+});
+
+
+/**
+ * Returns the ID of the window's current inner window.
+ */
+exports.getInnerId = deprecateFunction(getInnerId,
+ 'require("window-utils").getInnerId is deprecated, ' +
+ 'please use require("sdk/window/utils").getInnerId instead'
+);
+
+exports.getOuterId = deprecateFunction(getOuterId,
+ 'require("window-utils").getOuterId is deprecated, ' +
+ 'please use require("sdk/window/utils").getOuterId instead'
+);
+
+exports.isBrowser = deprecateFunction(isBrowser,
+ 'require("window-utils").isBrowser is deprecated, ' +
+ 'please use require("sdk/window/utils").isBrowser instead'
+);
+
+exports.hiddenWindow = appShellService.hiddenDOMWindow;
diff --git a/toolkit/jetpack/sdk/dom/events-shimmed.js b/toolkit/jetpack/sdk/dom/events-shimmed.js
new file mode 100644
index 000000000..7a1727681
--- /dev/null
+++ b/toolkit/jetpack/sdk/dom/events-shimmed.js
@@ -0,0 +1,18 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+const events = require('./events.js');
+
+exports.emit = (element, type, obj) => events.emit(element, type, obj, true);
+exports.on = (element, type, listener, capture) => events.on(element, type, listener, capture, true);
+exports.once = (element, type, listener, capture) => events.once(element, type, listener, capture, true);
+exports.removeListener = (element, type, listener, capture) => events.removeListener(element, type, listener, capture, true);
+exports.removed = events.removed;
+exports.when = (element, eventName, capture) => events.when(element, eventName, capture ? capture : false, true);
diff --git a/toolkit/jetpack/sdk/dom/events.js b/toolkit/jetpack/sdk/dom/events.js
new file mode 100644
index 000000000..502d2350f
--- /dev/null
+++ b/toolkit/jetpack/sdk/dom/events.js
@@ -0,0 +1,192 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cu } = require("chrome");
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+
+// Utility function that returns copy of the given `text` with last character
+// removed if it is `"s"`.
+function singularify(text) {
+ return text[text.length - 1] === "s" ? text.substr(0, text.length - 1) : text;
+}
+
+// Utility function that takes event type, argument is passed to
+// `document.createEvent` and returns name of the initializer method of the
+// given event. Please note that there are some event types whose initializer
+// methods can't be guessed by this function. For more details see following
+// link: https://developer.mozilla.org/En/DOM/Document.createEvent
+function getInitializerName(category) {
+ return "init" + singularify(category);
+}
+
+/**
+ * Registers an event `listener` on a given `element`, that will be called
+ * when events of specified `type` is dispatched on the `element`.
+ * @param {Element} element
+ * Dom element to register listener on.
+ * @param {String} type
+ * A string representing the
+ * [event type](https://developer.mozilla.org/en/DOM/event.type) to
+ * listen for.
+ * @param {Function} listener
+ * Function that is called whenever an event of the specified `type`
+ * occurs.
+ * @param {Boolean} capture
+ * If true, indicates that the user wishes to initiate capture. After
+ * initiating capture, all events of the specified type will be dispatched
+ * to the registered listener before being dispatched to any `EventTarget`s
+ * beneath it in the DOM tree. Events which are bubbling upward through
+ * the tree will not trigger a listener designated to use capture.
+ * See [DOM Level 3 Events](http://www.w3.org/TR/DOM-Level-3-Events/#event-flow)
+ * for a detailed explanation.
+ */
+function on(element, type, listener, capture, shimmed = false) {
+ // `capture` defaults to `false`.
+ capture = capture || false;
+ if (shimmed) {
+ element.addEventListener(type, listener, capture);
+ } else {
+ ShimWaiver.getProperty(element, "addEventListener")(type, listener, capture);
+ }
+}
+exports.on = on;
+
+/**
+ * Registers an event `listener` on a given `element`, that will be called
+ * only once, next time event of specified `type` is dispatched on the
+ * `element`.
+ * @param {Element} element
+ * Dom element to register listener on.
+ * @param {String} type
+ * A string representing the
+ * [event type](https://developer.mozilla.org/en/DOM/event.type) to
+ * listen for.
+ * @param {Function} listener
+ * Function that is called whenever an event of the specified `type`
+ * occurs.
+ * @param {Boolean} capture
+ * If true, indicates that the user wishes to initiate capture. After
+ * initiating capture, all events of the specified type will be dispatched
+ * to the registered listener before being dispatched to any `EventTarget`s
+ * beneath it in the DOM tree. Events which are bubbling upward through
+ * the tree will not trigger a listener designated to use capture.
+ * See [DOM Level 3 Events](http://www.w3.org/TR/DOM-Level-3-Events/#event-flow)
+ * for a detailed explanation.
+ */
+function once(element, type, listener, capture, shimmed = false) {
+ on(element, type, function selfRemovableListener(event) {
+ removeListener(element, type, selfRemovableListener, capture, shimmed);
+ listener.apply(this, arguments);
+ }, capture, shimmed);
+}
+exports.once = once;
+
+/**
+ * Unregisters an event `listener` on a given `element` for the events of the
+ * specified `type`.
+ *
+ * @param {Element} element
+ * Dom element to unregister listener from.
+ * @param {String} type
+ * A string representing the
+ * [event type](https://developer.mozilla.org/en/DOM/event.type) to
+ * listen for.
+ * @param {Function} listener
+ * Function that is called whenever an event of the specified `type`
+ * occurs.
+ * @param {Boolean} capture
+ * If true, indicates that the user wishes to initiate capture. After
+ * initiating capture, all events of the specified type will be dispatched
+ * to the registered listener before being dispatched to any `EventTarget`s
+ * beneath it in the DOM tree. Events which are bubbling upward through
+ * the tree will not trigger a listener designated to use capture.
+ * See [DOM Level 3 Events](http://www.w3.org/TR/DOM-Level-3-Events/#event-flow)
+ * for a detailed explanation.
+ */
+function removeListener(element, type, listener, capture, shimmed = false) {
+ if (shimmed) {
+ element.removeEventListener(type, listener, capture);
+ } else {
+ ShimWaiver.getProperty(element, "removeEventListener")(type, listener, capture);
+ }
+}
+exports.removeListener = removeListener;
+
+/**
+ * Emits event of the specified `type` and `category` on the given `element`.
+ * Specified `settings` are used to initialize event before dispatching it.
+ * @param {Element} element
+ * Dom element to dispatch event on.
+ * @param {String} type
+ * A string representing the
+ * [event type](https://developer.mozilla.org/en/DOM/event.type).
+ * @param {Object} options
+ * Options object containing following properties:
+ * - `category`: String passed to the `document.createEvent`. Option is
+ * optional and defaults to "UIEvents".
+ * - `initializer`: If passed it will be used as name of the method used
+ * to initialize event. If omitted name will be generated from the
+ * `category` field by prefixing it with `"init"` and removing last
+ * character if it matches `"s"`.
+ * - `settings`: Array of settings that are forwarded to the event
+ * initializer after firs `type` argument.
+ * @see https://developer.mozilla.org/En/DOM/Document.createEvent
+ */
+function emit(element, type, { category, initializer, settings }, shimmed = false) {
+ category = category || "UIEvents";
+ initializer = initializer || getInitializerName(category);
+ let document = element.ownerDocument;
+ let event = document.createEvent(category);
+ event[initializer].apply(event, [type].concat(settings));
+ if (shimmed) {
+ element.dispatchEvent(event);
+ } else {
+ ShimWaiver.getProperty(element, "dispatchEvent")(event);
+ }
+};
+exports.emit = emit;
+
+// Takes DOM `element` and returns promise which is resolved
+// when given element is removed from it's parent node.
+const removed = element => {
+ return new Promise(resolve => {
+ const { MutationObserver } = element.ownerDocument.defaultView;
+ const observer = new MutationObserver(mutations => {
+ for (let mutation of mutations) {
+ for (let node of mutation.removedNodes || []) {
+ if (node === element) {
+ observer.disconnect();
+ resolve(element);
+ }
+ }
+ }
+ });
+ observer.observe(element.parentNode, {childList: true});
+ });
+};
+exports.removed = removed;
+
+const when = (element, eventName, capture=false, shimmed=false) => new Promise(resolve => {
+ const listener = event => {
+ if (shimmed) {
+ element.removeEventListener(eventName, listener, capture);
+ } else {
+ ShimWaiver.getProperty(element, "removeEventListener")(eventName, listener, capture);
+ }
+ resolve(event);
+ };
+
+ if (shimmed) {
+ element.addEventListener(eventName, listener, capture);
+ } else {
+ ShimWaiver.getProperty(element, "addEventListener")(eventName, listener, capture);
+ }
+});
+exports.when = when;
diff --git a/toolkit/jetpack/sdk/dom/events/keys.js b/toolkit/jetpack/sdk/dom/events/keys.js
new file mode 100644
index 000000000..e6f1483a2
--- /dev/null
+++ b/toolkit/jetpack/sdk/dom/events/keys.js
@@ -0,0 +1,63 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { emit } = require("../events");
+const { getCodeForKey, toJSON } = require("../../keyboard/utils");
+const { has } = require("../../util/array");
+const { isString } = require("../../lang/type");
+
+const INITIALIZER = "initKeyEvent";
+const CATEGORY = "KeyboardEvent";
+
+function Options(options) {
+ if (!isString(options))
+ return options;
+
+ var { key, modifiers } = toJSON(options);
+ return {
+ key: key,
+ control: has(modifiers, "control"),
+ alt: has(modifiers, "alt"),
+ shift: has(modifiers, "shift"),
+ meta: has(modifiers, "meta")
+ };
+}
+
+var keyEvent = exports.keyEvent = function keyEvent(element, type, options) {
+
+ emit(element, type, {
+ initializer: INITIALIZER,
+ category: CATEGORY,
+ settings: [
+ !("bubbles" in options) || options.bubbles !== false,
+ !("cancelable" in options) || options.cancelable !== false,
+ "window" in options && options.window ? options.window : null,
+ "control" in options && !!options.control,
+ "alt" in options && !!options.alt,
+ "shift" in options && !!options.shift,
+ "meta" in options && !!options.meta,
+ getCodeForKey(options.key) || 0,
+ options.key.length === 1 ? options.key.charCodeAt(0) : 0
+ ]
+ });
+}
+
+exports.keyDown = function keyDown(element, options) {
+ keyEvent(element, "keydown", Options(options));
+};
+
+exports.keyUp = function keyUp(element, options) {
+ keyEvent(element, "keyup", Options(options));
+};
+
+exports.keyPress = function keyPress(element, options) {
+ keyEvent(element, "keypress", Options(options));
+};
+
diff --git a/toolkit/jetpack/sdk/event/chrome.js b/toolkit/jetpack/sdk/event/chrome.js
new file mode 100644
index 000000000..9044fef99
--- /dev/null
+++ b/toolkit/jetpack/sdk/event/chrome.js
@@ -0,0 +1,65 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci, Cr, Cu } = require("chrome");
+const { emit, on, off } = require("./core");
+var observerService = Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService);
+
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+const addObserver = ShimWaiver.getProperty(observerService, "addObserver");
+const removeObserver = ShimWaiver.getProperty(observerService, "removeObserver");
+
+const { when: unload } = require("../system/unload");
+
+// Simple class that can be used to instantiate event channel that
+// implements `nsIObserver` interface. It's will is used by `observe`
+// function as observer + event target. It basically proxies observer
+// notifications as to it's registered listeners.
+function ObserverChannel() {}
+Object.freeze(Object.defineProperties(ObserverChannel.prototype, {
+ QueryInterface: {
+ value: function(iid) {
+ if (!iid.equals(Ci.nsIObserver) &&
+ !iid.equals(Ci.nsISupportsWeakReference) &&
+ !iid.equals(Ci.nsISupports))
+ throw Cr.NS_ERROR_NO_INTERFACE;
+ return this;
+ }
+ },
+ observe: {
+ value: function(subject, topic, data) {
+ emit(this, "data", {
+ type: topic,
+ target: subject,
+ data: data
+ });
+ }
+ }
+}));
+
+function observe(topic) {
+ let observerChannel = new ObserverChannel();
+
+ // Note: `nsIObserverService` will not hold a weak reference to a
+ // observerChannel (since third argument is `true`). There for if it
+ // will be GC-ed with all it's event listeners once no other references
+ // will be held.
+ addObserver(observerChannel, topic, true);
+
+ // We need to remove any observer added once the add-on is unloaded;
+ // otherwise we'll get a "dead object" exception.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1001833
+ unload(() => removeObserver(observerChannel, topic));
+
+ return observerChannel;
+}
+
+exports.observe = observe;
diff --git a/toolkit/jetpack/sdk/event/core.js b/toolkit/jetpack/sdk/event/core.js
new file mode 100644
index 000000000..c16dd2df5
--- /dev/null
+++ b/toolkit/jetpack/sdk/event/core.js
@@ -0,0 +1,193 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const UNCAUGHT_ERROR = 'An error event was emitted for which there was no listener.';
+const BAD_LISTENER = 'The event listener must be a function.';
+
+const { ns } = require('../core/namespace');
+
+const event = ns();
+
+const EVENT_TYPE_PATTERN = /^on([A-Z]\w+$)/;
+exports.EVENT_TYPE_PATTERN = EVENT_TYPE_PATTERN;
+
+// Utility function to access given event `target` object's event listeners for
+// the specific event `type`. If listeners for this type does not exists they
+// will be created.
+const observers = function observers(target, type) {
+ if (!target) throw TypeError("Event target must be an object");
+ let listeners = event(target);
+ return type in listeners ? listeners[type] : listeners[type] = [];
+};
+
+/**
+ * Registers an event `listener` that is called every time events of
+ * specified `type` is emitted on the given event `target`.
+ * @param {Object} target
+ * Event target object.
+ * @param {String} type
+ * The type of event.
+ * @param {Function} listener
+ * The listener function that processes the event.
+ */
+function on(target, type, listener) {
+ if (typeof(listener) !== 'function')
+ throw new Error(BAD_LISTENER);
+
+ let listeners = observers(target, type);
+ if (!~listeners.indexOf(listener))
+ listeners.push(listener);
+}
+exports.on = on;
+
+
+var onceWeakMap = new WeakMap();
+
+
+/**
+ * Registers an event `listener` that is called only the next time an event
+ * of the specified `type` is emitted on the given event `target`.
+ * @param {Object} target
+ * Event target object.
+ * @param {String} type
+ * The type of the event.
+ * @param {Function} listener
+ * The listener function that processes the event.
+ */
+function once(target, type, listener) {
+ let replacement = function observer(...args) {
+ off(target, type, observer);
+ onceWeakMap.delete(listener);
+ listener.apply(target, args);
+ };
+ onceWeakMap.set(listener, replacement);
+ on(target, type, replacement);
+}
+exports.once = once;
+
+/**
+ * Execute each of the listeners in order with the supplied arguments.
+ * All the exceptions that are thrown by listeners during the emit
+ * are caught and can be handled by listeners of 'error' event. Thrown
+ * exceptions are passed as an argument to an 'error' event listener.
+ * If no 'error' listener is registered exception will be logged into an
+ * error console.
+ * @param {Object} target
+ * Event target object.
+ * @param {String} type
+ * The type of event.
+ * @params {Object|Number|String|Boolean} args
+ * Arguments that will be passed to listeners.
+ */
+function emit (target, type, ...args) {
+ emitOnObject(target, type, target, ...args);
+}
+exports.emit = emit;
+
+/**
+ * A variant of emit that allows setting the this property for event listeners
+ */
+function emitOnObject(target, type, thisArg, ...args) {
+ let all = observers(target, '*').length;
+ let state = observers(target, type);
+ let listeners = state.slice();
+ let count = listeners.length;
+ let index = 0;
+
+ // If error event and there are no handlers (explicit or catch-all)
+ // then print error message to the console.
+ if (count === 0 && type === 'error' && all === 0)
+ console.exception(args[0]);
+ while (index < count) {
+ try {
+ let listener = listeners[index];
+ // Dispatch only if listener is still registered.
+ if (~state.indexOf(listener))
+ listener.apply(thisArg, args);
+ }
+ catch (error) {
+ // If exception is not thrown by a error listener and error listener is
+ // registered emit `error` event. Otherwise dump exception to the console.
+ if (type !== 'error') emit(target, 'error', error);
+ else console.exception(error);
+ }
+ index++;
+ }
+ // Also emit on `"*"` so that one could listen for all events.
+ if (type !== '*') emit(target, '*', type, ...args);
+}
+exports.emitOnObject = emitOnObject;
+
+/**
+ * Removes an event `listener` for the given event `type` on the given event
+ * `target`. If no `listener` is passed removes all listeners of the given
+ * `type`. If `type` is not passed removes all the listeners of the given
+ * event `target`.
+ * @param {Object} target
+ * The event target object.
+ * @param {String} type
+ * The type of event.
+ * @param {Function} listener
+ * The listener function that processes the event.
+ */
+function off(target, type, listener) {
+ let length = arguments.length;
+ if (length === 3) {
+ if (onceWeakMap.has(listener)) {
+ listener = onceWeakMap.get(listener);
+ onceWeakMap.delete(listener);
+ }
+
+ let listeners = observers(target, type);
+ let index = listeners.indexOf(listener);
+ if (~index)
+ listeners.splice(index, 1);
+ }
+ else if (length === 2) {
+ observers(target, type).splice(0);
+ }
+ else if (length === 1) {
+ let listeners = event(target);
+ Object.keys(listeners).forEach(type => delete listeners[type]);
+ }
+}
+exports.off = off;
+
+/**
+ * Returns a number of event listeners registered for the given event `type`
+ * on the given event `target`.
+ */
+function count(target, type) {
+ return observers(target, type).length;
+}
+exports.count = count;
+
+/**
+ * Registers listeners on the given event `target` from the given `listeners`
+ * dictionary. Iterates over the listeners and if property name matches name
+ * pattern `onEventType` and property is a function, then registers it as
+ * an `eventType` listener on `target`.
+ *
+ * @param {Object} target
+ * The type of event.
+ * @param {Object} listeners
+ * Dictionary of listeners.
+ */
+function setListeners(target, listeners) {
+ Object.keys(listeners || {}).forEach(key => {
+ let match = EVENT_TYPE_PATTERN.exec(key);
+ let type = match && match[1].toLowerCase();
+ if (!type) return;
+
+ let listener = listeners[key];
+ if (typeof(listener) === 'function')
+ on(target, type, listener);
+ });
+}
+exports.setListeners = setListeners;
diff --git a/toolkit/jetpack/sdk/event/dom.js b/toolkit/jetpack/sdk/event/dom.js
new file mode 100644
index 000000000..da99dec7a
--- /dev/null
+++ b/toolkit/jetpack/sdk/event/dom.js
@@ -0,0 +1,78 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Ci } = require("chrome");
+
+var { emit } = require("./core");
+var { when: unload } = require("../system/unload");
+var listeners = new WeakMap();
+
+const { Cu } = require("chrome");
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+const { ThreadSafeChromeUtils } = Cu.import("resource://gre/modules/Services.jsm", {});
+
+var getWindowFrom = x =>
+ x instanceof Ci.nsIDOMWindow ? x :
+ x instanceof Ci.nsIDOMDocument ? x.defaultView :
+ x instanceof Ci.nsIDOMNode ? x.ownerDocument.defaultView :
+ null;
+
+function removeFromListeners() {
+ ShimWaiver.getProperty(this, "removeEventListener")("DOMWindowClose", removeFromListeners);
+ for (let cleaner of listeners.get(this))
+ cleaner();
+
+ listeners.delete(this);
+}
+
+// Simple utility function takes event target, event type and optional
+// `options.capture` and returns node style event stream that emits "data"
+// events every time event of that type occurs on the given `target`.
+function open(target, type, options) {
+ let output = {};
+ let capture = options && options.capture ? true : false;
+ let listener = (event) => emit(output, "data", event);
+
+ // `open` is currently used only on DOM Window objects, however it was made
+ // to be used to any kind of `target` that supports `addEventListener`,
+ // therefore is safer get the `window` from the `target` instead assuming
+ // that `target` is the `window`.
+ let window = getWindowFrom(target);
+
+ // If we're not able to get a `window` from `target`, there is something
+ // wrong. We cannot add listeners that can leak later, or results in
+ // "dead object" exception.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1001833
+ if (!window)
+ throw new Error("Unable to obtain the owner window from the target given.");
+
+ let cleaners = listeners.get(window);
+ if (!cleaners) {
+ cleaners = [];
+ listeners.set(window, cleaners);
+
+ // We need to remove from our map the `window` once is closed, to prevent
+ // memory leak
+ ShimWaiver.getProperty(window, "addEventListener")("DOMWindowClose", removeFromListeners);
+ }
+
+ cleaners.push(() => ShimWaiver.getProperty(target, "removeEventListener")(type, listener, capture));
+ ShimWaiver.getProperty(target, "addEventListener")(type, listener, capture);
+
+ return output;
+}
+
+unload(() => {
+ let keys = ThreadSafeChromeUtils.nondeterministicGetWeakMapKeys(listeners)
+ for (let window of keys)
+ removeFromListeners.call(window);
+});
+
+exports.open = open;
diff --git a/toolkit/jetpack/sdk/event/target.js b/toolkit/jetpack/sdk/event/target.js
new file mode 100644
index 000000000..3a1f5e5f0
--- /dev/null
+++ b/toolkit/jetpack/sdk/event/target.js
@@ -0,0 +1,74 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { on, once, off, setListeners } = require('./core');
+const { method, chainable } = require('../lang/functional/core');
+const { Class } = require('../core/heritage');
+
+/**
+ * `EventTarget` is an exemplar for creating an objects that can be used to
+ * add / remove event listeners on them. Events on these objects may be emitted
+ * via `emit` function exported by 'event/core' module.
+ */
+const EventTarget = Class({
+ /**
+ * Method initializes `this` event source. It goes through properties of a
+ * given `options` and registers listeners for the ones that look like an
+ * event listeners.
+ */
+ /**
+ * Method initializes `this` event source. It goes through properties of a
+ * given `options` and registers listeners for the ones that look like an
+ * event listeners.
+ */
+ initialize: function initialize(options) {
+ setListeners(this, options);
+ },
+ /**
+ * Registers an event `listener` that is called every time events of
+ * specified `type` are emitted.
+ * @param {String} type
+ * The type of event.
+ * @param {Function} listener
+ * The listener function that processes the event.
+ * @example
+ * worker.on('message', function (data) {
+ * console.log('data received: ' + data)
+ * })
+ */
+ on: chainable(method(on)),
+ /**
+ * Registers an event `listener` that is called once the next time an event
+ * of the specified `type` is emitted.
+ * @param {String} type
+ * The type of the event.
+ * @param {Function} listener
+ * The listener function that processes the event.
+ */
+ once: chainable(method(once)),
+ /**
+ * Removes an event `listener` for the given event `type`.
+ * @param {String} type
+ * The type of event.
+ * @param {Function} listener
+ * The listener function that processes the event.
+ */
+ removeListener: function removeListener(type, listener) {
+ // Note: We can't just wrap `off` in `method` as we do it for other methods
+ // cause skipping a second or third argument will behave very differently
+ // than intended. This way we make sure all arguments are passed and only
+ // one listener is removed at most.
+ off(this, type, listener);
+ return this;
+ },
+ // but we can wrap `off` here, as the semantics are the same
+ off: chainable(method(off))
+
+});
+exports.EventTarget = EventTarget;
diff --git a/toolkit/jetpack/sdk/event/utils.js b/toolkit/jetpack/sdk/event/utils.js
new file mode 100644
index 000000000..f193b6785
--- /dev/null
+++ b/toolkit/jetpack/sdk/event/utils.js
@@ -0,0 +1,328 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+var { emit, on, once, off, EVENT_TYPE_PATTERN } = require("./core");
+const { Cu } = require("chrome");
+
+// This module provides set of high order function for working with event
+// streams (streams in a NodeJS style that dispatch data, end and error
+// events).
+
+// Function takes a `target` object and returns set of implicit references
+// (non property references) it keeps. This basically allows defining
+// references between objects without storing the explicitly. See transform for
+// more details.
+var refs = (function() {
+ let refSets = new WeakMap();
+ return function refs(target) {
+ if (!refSets.has(target)) refSets.set(target, new Set());
+ return refSets.get(target);
+ };
+})();
+
+function transform(input, f) {
+ let output = new Output();
+
+ // Since event listeners don't prevent `input` to be GC-ed we wanna presrve
+ // it until `output` can be GC-ed. There for we add implicit reference which
+ // is removed once `input` ends.
+ refs(output).add(input);
+
+ const next = data => receive(output, data);
+ once(output, "start", () => start(input));
+ on(input, "error", error => emit(output, "error", error));
+ on(input, "end", function() {
+ refs(output).delete(input);
+ end(output);
+ });
+ on(input, "data", data => f(data, next));
+ return output;
+}
+
+// High order event transformation function that takes `input` event channel
+// and returns transformation containing only events on which `p` predicate
+// returns `true`.
+function filter(input, predicate) {
+ return transform(input, function(data, next) {
+ if (predicate(data))
+ next(data);
+ });
+}
+exports.filter = filter;
+
+// High order function that takes `input` and returns input of it's values
+// mapped via given `f` function.
+const map = (input, f) => transform(input, (data, next) => next(f(data)));
+exports.map = map;
+
+// High order function that takes `input` stream of streams and merges them
+// into single event stream. Like flatten but time based rather than order
+// based.
+function merge(inputs) {
+ let output = new Output();
+ let open = 1;
+ let state = [];
+ output.state = state;
+ refs(output).add(inputs);
+
+ function end(input) {
+ open = open - 1;
+ refs(output).delete(input);
+ if (open === 0) emit(output, "end");
+ }
+ const error = e => emit(output, "error", e);
+ function forward(input) {
+ state.push(input);
+ open = open + 1;
+ on(input, "end", () => end(input));
+ on(input, "error", error);
+ on(input, "data", data => emit(output, "data", data));
+ }
+
+ // If `inputs` is an array treat it as a stream.
+ if (Array.isArray(inputs)) {
+ inputs.forEach(forward);
+ end(inputs);
+ }
+ else {
+ on(inputs, "end", () => end(inputs));
+ on(inputs, "error", error);
+ on(inputs, "data", forward);
+ }
+
+ return output;
+}
+exports.merge = merge;
+
+const expand = (inputs, f) => merge(map(inputs, f));
+exports.expand = expand;
+
+const pipe = (from, to) => on(from, "*", emit.bind(emit, to));
+exports.pipe = pipe;
+
+
+// Shim signal APIs so other modules can be used as is.
+const receive = (input, message) => {
+ if (input[receive])
+ input[receive](input, message);
+ else
+ emit(input, "data", message);
+
+ // Ideally our input will extend Input and already provide a weak value
+ // getter. If not, opportunistically shim the weak value getter on
+ // other types passed as the input.
+ if (!("value" in input)) {
+ Object.defineProperty(input, "value", WeakValueGetterSetter);
+ }
+ input.value = message;
+};
+receive.toString = () => "@@receive";
+exports.receive = receive;
+exports.send = receive;
+
+const end = input => {
+ if (input[end])
+ input[end](input);
+ else
+ emit(input, "end", input);
+};
+end.toString = () => "@@end";
+exports.end = end;
+
+const stop = input => {
+ if (input[stop])
+ input[stop](input);
+ else
+ emit(input, "stop", input);
+};
+stop.toString = () => "@@stop";
+exports.stop = stop;
+
+const start = input => {
+ if (input[start])
+ input[start](input);
+ else
+ emit(input, "start", input);
+};
+start.toString = () => "@@start";
+exports.start = start;
+
+const lift = (step, ...inputs) => {
+ let args = null;
+ let opened = inputs.length;
+ let started = false;
+ const output = new Output();
+ const init = () => {
+ args = [...inputs.map(input => input.value)];
+ output.value = step(...args);
+ };
+
+ inputs.forEach((input, index) => {
+ on(input, "data", data => {
+ args[index] = data;
+ receive(output, step(...args));
+ });
+ on(input, "end", () => {
+ opened = opened - 1;
+ if (opened <= 0)
+ end(output);
+ });
+ });
+
+ once(output, "start", () => {
+ inputs.forEach(start);
+ init();
+ });
+
+ init();
+
+ return output;
+};
+exports.lift = lift;
+
+const merges = inputs => {
+ let opened = inputs.length;
+ let output = new Output();
+ output.value = inputs[0].value;
+ inputs.forEach((input, index) => {
+ on(input, "data", data => receive(output, data));
+ on(input, "end", () => {
+ opened = opened - 1;
+ if (opened <= 0)
+ end(output);
+ });
+ });
+
+ once(output, "start", () => {
+ inputs.forEach(start);
+ output.value = inputs[0].value;
+ });
+
+ return output;
+};
+exports.merges = merges;
+
+const foldp = (step, initial, input) => {
+ let output = map(input, x => step(output.value, x));
+ output.value = initial;
+ return output;
+};
+exports.foldp = foldp;
+
+const keepIf = (p, base, input) => {
+ let output = filter(input, p);
+ output.value = base;
+ return output;
+};
+exports.keepIf = keepIf;
+
+function Input() {}
+Input.start = input => emit(input, "start", input);
+Input.prototype.start = Input.start;
+
+Input.end = input => {
+ emit(input, "end", input);
+ stop(input);
+};
+Input.prototype[end] = Input.end;
+
+// The event channel system caches the last event seen as input.value.
+// Unfortunately, if the last event is a DOM object this is a great way
+// leak windows. Mitigate this by storing input.value using a weak
+// reference. This allows the system to work for normal event processing
+// while also allowing the objects to be reclaimed. It means, however,
+// input.value cannot be accessed long after the event was dispatched.
+const WeakValueGetterSetter = {
+ get: function() {
+ return this._weakValue ? this._weakValue.get() : this._simpleValue
+ },
+ set: function(v) {
+ if (v && typeof v === "object") {
+ try {
+ // Try to set a weak reference. This can throw for some values.
+ // For example, if the value is a native object that does not
+ // implement nsISupportsWeakReference.
+ this._weakValue = Cu.getWeakReference(v)
+ this._simpleValue = undefined;
+ return;
+ } catch (e) {
+ // Do nothing. Fall through to setting _simpleValue below.
+ }
+ }
+ this._simpleValue = v;
+ this._weakValue = undefined;
+ },
+}
+Object.defineProperty(Input.prototype, "value", WeakValueGetterSetter);
+
+exports.Input = Input;
+
+// Define an Output type with a weak value getter for the transformation
+// functions that produce new channels.
+function Output() { }
+Object.defineProperty(Output.prototype, "value", WeakValueGetterSetter);
+exports.Output = Output;
+
+const $source = "@@source";
+const $outputs = "@@outputs";
+exports.outputs = $outputs;
+
+// NOTE: Passing DOM objects through a Reactor can cause them to leak
+// when they get cached in this.value. We cannot use a weak reference
+// in this case because the Reactor design expects to always have both the
+// past and present value. If we allow past values to be collected the
+// system breaks.
+
+function Reactor(options={}) {
+ const {onStep, onStart, onEnd} = options;
+ if (onStep)
+ this.onStep = onStep;
+ if (onStart)
+ this.onStart = onStart;
+ if (onEnd)
+ this.onEnd = onEnd;
+}
+Reactor.prototype.onStep = _ => void(0);
+Reactor.prototype.onStart = _ => void(0);
+Reactor.prototype.onEnd = _ => void(0);
+Reactor.prototype.onNext = function(present, past) {
+ this.value = present;
+ this.onStep(present, past);
+};
+Reactor.prototype.run = function(input) {
+ on(input, "data", message => this.onNext(message, input.value));
+ on(input, "end", () => this.onEnd(input.value));
+ start(input);
+ this.value = input.value;
+ this.onStart(input.value);
+};
+exports.Reactor = Reactor;
+
+/**
+ * Takes an object used as options with potential keys like 'onMessage',
+ * used to be called `require('sdk/event/core').setListeners` on.
+ * This strips all keys that would trigger a listener to be set.
+ *
+ * @params {Object} object
+ * @return {Object}
+ */
+
+function stripListeners (object) {
+ return Object.keys(object || {}).reduce((agg, key) => {
+ if (!EVENT_TYPE_PATTERN.test(key))
+ agg[key] = object[key];
+ return agg;
+ }, {});
+}
+exports.stripListeners = stripListeners;
+
+const when = (target, type) => new Promise(resolve => {
+ once(target, type, resolve);
+});
+exports.when = when;
diff --git a/toolkit/jetpack/sdk/frame/hidden-frame.js b/toolkit/jetpack/sdk/frame/hidden-frame.js
new file mode 100644
index 000000000..97e0b7974
--- /dev/null
+++ b/toolkit/jetpack/sdk/frame/hidden-frame.js
@@ -0,0 +1,115 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci } = require("chrome");
+const { Class } = require("../core/heritage");
+const { List, addListItem, removeListItem } = require("../util/list");
+const { EventTarget } = require("../event/target");
+const { emit } = require("../event/core");
+const { create: makeFrame } = require("./utils");
+const { defer } = require("../core/promise");
+const { when: unload } = require("../system/unload");
+const { validateOptions, getTypeOf } = require("../deprecated/api-utils");
+const { window } = require("../addon/window");
+const { fromIterator } = require("../util/array");
+
+// This cache is used to access friend properties between functions
+// without exposing them on the public API.
+var cache = new Set();
+var elements = new WeakMap();
+
+function contentLoaded(target) {
+ var deferred = defer();
+ target.addEventListener("DOMContentLoaded", function DOMContentLoaded(event) {
+ // "DOMContentLoaded" events from nested frames propagate up to target,
+ // ignore events unless it's DOMContentLoaded for the given target.
+ if (event.target === target || event.target === target.contentDocument) {
+ target.removeEventListener("DOMContentLoaded", DOMContentLoaded, false);
+ deferred.resolve(target);
+ }
+ }, false);
+ return deferred.promise;
+}
+
+function FrameOptions(options) {
+ options = options || {}
+ return validateOptions(options, FrameOptions.validator);
+}
+FrameOptions.validator = {
+ onReady: {
+ is: ["undefined", "function", "array"],
+ ok: function(v) {
+ if (getTypeOf(v) === "array") {
+ // make sure every item is a function
+ return v.every(item => typeof(item) === "function")
+ }
+ return true;
+ }
+ },
+ onUnload: {
+ is: ["undefined", "function"]
+ }
+};
+
+var HiddenFrame = Class({
+ extends: EventTarget,
+ initialize: function initialize(options) {
+ options = FrameOptions(options);
+ EventTarget.prototype.initialize.call(this, options);
+ },
+ get element() {
+ return elements.get(this);
+ },
+ toString: function toString() {
+ return "[object Frame]"
+ }
+});
+exports.HiddenFrame = HiddenFrame
+
+function addHidenFrame(frame) {
+ if (!(frame instanceof HiddenFrame))
+ throw Error("The object to be added must be a HiddenFrame.");
+
+ // This instance was already added.
+ if (cache.has(frame)) return frame;
+ else cache.add(frame);
+
+ let element = makeFrame(window.document, {
+ nodeName: "iframe",
+ type: "content",
+ allowJavascript: true,
+ allowPlugins: true,
+ allowAuth: true,
+ });
+ elements.set(frame, element);
+
+ contentLoaded(element).then(function onFrameReady(element) {
+ emit(frame, "ready");
+ }, console.exception);
+
+ return frame;
+}
+exports.add = addHidenFrame
+
+function removeHiddenFrame(frame) {
+ if (!(frame instanceof HiddenFrame))
+ throw Error("The object to be removed must be a HiddenFrame.");
+
+ if (!cache.has(frame)) return;
+
+ // Remove from cache before calling in order to avoid loop
+ cache.delete(frame);
+ emit(frame, "unload")
+ let element = frame.element
+ if (element) element.parentNode.removeChild(element)
+}
+exports.remove = removeHiddenFrame;
+
+unload(() => fromIterator(cache).forEach(removeHiddenFrame));
diff --git a/toolkit/jetpack/sdk/frame/utils.js b/toolkit/jetpack/sdk/frame/utils.js
new file mode 100644
index 000000000..d9fccec4d
--- /dev/null
+++ b/toolkit/jetpack/sdk/frame/utils.js
@@ -0,0 +1,94 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Ci } = require("chrome");
+const XUL = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
+
+function eventTarget(frame) {
+ return getDocShell(frame).chromeEventHandler;
+}
+exports.eventTarget = eventTarget;
+
+function getDocShell(frame) {
+ let { frameLoader } = frame.QueryInterface(Ci.nsIFrameLoaderOwner);
+ return frameLoader && frameLoader.docShell;
+}
+exports.getDocShell = getDocShell;
+
+/**
+ * Creates a XUL `browser` element in a privileged document.
+ * @params {nsIDOMDocument} document
+ * @params {String} options.type
+ * By default is 'content' for possible values see:
+ * https://developer.mozilla.org/en/XUL/iframe#a-browser.type
+ * @params {String} options.uri
+ * URI of the document to be loaded into created frame.
+ * @params {Boolean} options.remote
+ * If `true` separate process will be used for this frame, also in such
+ * case all the following options are ignored.
+ * @params {Boolean} options.allowAuth
+ * Whether to allow auth dialogs. Defaults to `false`.
+ * @params {Boolean} options.allowJavascript
+ * Whether to allow Javascript execution. Defaults to `false`.
+ * @params {Boolean} options.allowPlugins
+ * Whether to allow plugin execution. Defaults to `false`.
+ */
+function create(target, options) {
+ target = target instanceof Ci.nsIDOMDocument ? target.documentElement :
+ target instanceof Ci.nsIDOMWindow ? target.document.documentElement :
+ target;
+ options = options || {};
+ let remote = options.remote || false;
+ let namespaceURI = options.namespaceURI || XUL;
+ let isXUL = namespaceURI === XUL;
+ let nodeName = isXUL && options.browser ? 'browser' : 'iframe';
+ let document = target.ownerDocument;
+
+ let frame = document.createElementNS(namespaceURI, nodeName);
+ // Type="content" is mandatory to enable stuff here:
+ // http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsFrameLoader.cpp#1776
+ frame.setAttribute('type', options.type || 'content');
+ frame.setAttribute('src', options.uri || 'about:blank');
+
+ // Must set the remote attribute before attaching the frame to the document
+ if (remote && isXUL) {
+ // We remove XBL binding to avoid execution of code that is not going to
+ // work because browser has no docShell attribute in remote mode
+ // (for example)
+ frame.setAttribute('style', '-moz-binding: none;');
+ frame.setAttribute('remote', 'true');
+ }
+
+ target.appendChild(frame);
+
+ // Load in separate process if `options.remote` is `true`.
+ // http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsFrameLoader.cpp#1347
+ if (remote && !isXUL) {
+ frame.QueryInterface(Ci.nsIMozBrowserFrame);
+ frame.createRemoteFrameLoader(null);
+ }
+
+ // If browser is remote it won't have a `docShell`.
+ if (!remote) {
+ let docShell = getDocShell(frame);
+ docShell.allowAuth = options.allowAuth || false;
+ docShell.allowJavascript = options.allowJavascript || false;
+ docShell.allowPlugins = options.allowPlugins || false;
+ docShell.allowWindowControl = options.allowWindowControl || false;
+ }
+
+ return frame;
+}
+exports.create = create;
+
+function swapFrameLoaders(from, to) {
+ return from.QueryInterface(Ci.nsIFrameLoaderOwner).swapFrameLoaders(to);
+}
+exports.swapFrameLoaders = swapFrameLoaders;
diff --git a/toolkit/jetpack/sdk/fs/path.js b/toolkit/jetpack/sdk/fs/path.js
new file mode 100644
index 000000000..4474b2b4a
--- /dev/null
+++ b/toolkit/jetpack/sdk/fs/path.js
@@ -0,0 +1,500 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// Adapted version of:
+// https://github.com/joyent/node/blob/v0.11.3/lib/path.js
+
+// Shim process global from node.
+var process = Object.create(require('../system'));
+process.cwd = process.pathFor.bind(process, 'CurProcD');
+
+// Update original check in node `process.platform === 'win32'` since in SDK it's `winnt`.
+var isWindows = process.platform.indexOf('win') === 0;
+
+
+
+// resolves . and .. elements in a path array with directory names there
+// must be no slashes, empty elements, or device names (c:\) in the array
+// (so also no leading and trailing slashes - it does not distinguish
+// relative and absolute paths)
+function normalizeArray(parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+
+ return parts;
+}
+
+
+if (isWindows) {
+ // Regex to split a windows path into three parts: [*, device, slash,
+ // tail] windows-only
+ var splitDeviceRe =
+ /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
+
+ // Regex to split the tail part of the above into [*, dir, basename, ext]
+ var splitTailRe =
+ /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
+
+ // Function to split a filename into [root, dir, basename, ext]
+ // windows version
+ var splitPath = function(filename) {
+ // Separate device+slash from tail
+ var result = splitDeviceRe.exec(filename),
+ device = (result[1] || '') + (result[2] || ''),
+ tail = result[3] || '';
+ // Split the tail into dir, basename and extension
+ var result2 = splitTailRe.exec(tail),
+ dir = result2[1],
+ basename = result2[2],
+ ext = result2[3];
+ return [device, dir, basename, ext];
+ };
+
+ var normalizeUNCRoot = function(device) {
+ return '\\\\' + device.replace(/^[\\\/]+/, '').replace(/[\\\/]+/g, '\\');
+ };
+
+ // path.resolve([from ...], to)
+ // windows version
+ exports.resolve = function() {
+ var resolvedDevice = '',
+ resolvedTail = '',
+ resolvedAbsolute = false;
+
+ for (var i = arguments.length - 1; i >= -1; i--) {
+ var path;
+ if (i >= 0) {
+ path = arguments[i];
+ } else if (!resolvedDevice) {
+ path = process.cwd();
+ } else {
+ // Windows has the concept of drive-specific current working
+ // directories. If we've resolved a drive letter but not yet an
+ // absolute path, get cwd for that drive. We're sure the device is not
+ // an unc path at this points, because unc paths are always absolute.
+ path = process.env['=' + resolvedDevice];
+ // Verify that a drive-local cwd was found and that it actually points
+ // to our drive. If not, default to the drive's root.
+ if (!path || path.substr(0, 3).toLowerCase() !==
+ resolvedDevice.toLowerCase() + '\\') {
+ path = resolvedDevice + '\\';
+ }
+ }
+
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+
+ var result = splitDeviceRe.exec(path),
+ device = result[1] || '',
+ isUnc = device && device.charAt(1) !== ':',
+ isAbsolute = exports.isAbsolute(path),
+ tail = result[3];
+
+ if (device &&
+ resolvedDevice &&
+ device.toLowerCase() !== resolvedDevice.toLowerCase()) {
+ // This path points to another device so it is not applicable
+ continue;
+ }
+
+ if (!resolvedDevice) {
+ resolvedDevice = device;
+ }
+ if (!resolvedAbsolute) {
+ resolvedTail = tail + '\\' + resolvedTail;
+ resolvedAbsolute = isAbsolute;
+ }
+
+ if (resolvedDevice && resolvedAbsolute) {
+ break;
+ }
+ }
+
+ // Convert slashes to backslashes when `resolvedDevice` points to an UNC
+ // root. Also squash multiple slashes into a single one where appropriate.
+ if (isUnc) {
+ resolvedDevice = normalizeUNCRoot(resolvedDevice);
+ }
+
+ // At this point the path should be resolved to a full absolute path,
+ // but handle relative paths to be safe (might happen when process.cwd()
+ // fails)
+
+ // Normalize the tail path
+
+ function f(p) {
+ return !!p;
+ }
+
+ resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f),
+ !resolvedAbsolute).join('\\');
+
+ return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
+ '.';
+ };
+
+ // windows version
+ exports.normalize = function(path) {
+ var result = splitDeviceRe.exec(path),
+ device = result[1] || '',
+ isUnc = device && device.charAt(1) !== ':',
+ isAbsolute = exports.isAbsolute(path),
+ tail = result[3],
+ trailingSlash = /[\\\/]$/.test(tail);
+
+ // If device is a drive letter, we'll normalize to lower case.
+ if (device && device.charAt(1) === ':') {
+ device = device[0].toLowerCase() + device.substr(1);
+ }
+
+ // Normalize the tail path
+ tail = normalizeArray(tail.split(/[\\\/]+/).filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('\\');
+
+ if (!tail && !isAbsolute) {
+ tail = '.';
+ }
+ if (tail && trailingSlash) {
+ tail += '\\';
+ }
+
+ // Convert slashes to backslashes when `device` points to an UNC root.
+ // Also squash multiple slashes into a single one where appropriate.
+ if (isUnc) {
+ device = normalizeUNCRoot(device);
+ }
+
+ return device + (isAbsolute ? '\\' : '') + tail;
+ };
+
+ // windows version
+ exports.isAbsolute = function(path) {
+ var result = splitDeviceRe.exec(path),
+ device = result[1] || '',
+ isUnc = device && device.charAt(1) !== ':';
+ // UNC paths are always absolute
+ return !!result[2] || isUnc;
+ };
+
+ // windows version
+ exports.join = function() {
+ function f(p) {
+ if (typeof p !== 'string') {
+ throw new TypeError('Arguments to path.join must be strings');
+ }
+ return p;
+ }
+
+ var paths = Array.prototype.filter.call(arguments, f);
+ var joined = paths.join('\\');
+
+ // Make sure that the joined path doesn't start with two slashes, because
+ // normalize() will mistake it for an UNC path then.
+ //
+ // This step is skipped when it is very clear that the user actually
+ // intended to point at an UNC path. This is assumed when the first
+ // non-empty string arguments starts with exactly two slashes followed by
+ // at least one more non-slash character.
+ //
+ // Note that for normalize() to treat a path as an UNC path it needs to
+ // have at least 2 components, so we don't filter for that here.
+ // This means that the user can use join to construct UNC paths from
+ // a server name and a share name; for example:
+ // path.join('//server', 'share') -> '\\\\server\\share\')
+ if (!/^[\\\/]{2}[^\\\/]/.test(paths[0])) {
+ joined = joined.replace(/^[\\\/]{2,}/, '\\');
+ }
+
+ return exports.normalize(joined);
+ };
+
+ // path.relative(from, to)
+ // it will solve the relative path from 'from' to 'to', for instance:
+ // from = 'C:\\orandea\\test\\aaa'
+ // to = 'C:\\orandea\\impl\\bbb'
+ // The output of the function should be: '..\\..\\impl\\bbb'
+ // windows version
+ exports.relative = function(from, to) {
+ from = exports.resolve(from);
+ to = exports.resolve(to);
+
+ // windows is not case sensitive
+ var lowerFrom = from.toLowerCase();
+ var lowerTo = to.toLowerCase();
+
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+
+ var toParts = trim(to.split('\\'));
+
+ var lowerFromParts = trim(lowerFrom.split('\\'));
+ var lowerToParts = trim(lowerTo.split('\\'));
+
+ var length = Math.min(lowerFromParts.length, lowerToParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (lowerFromParts[i] !== lowerToParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+
+ if (samePartsLength == 0) {
+ return to;
+ }
+
+ var outputParts = [];
+ for (var i = samePartsLength; i < lowerFromParts.length; i++) {
+ outputParts.push('..');
+ }
+
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+
+ return outputParts.join('\\');
+ };
+
+ exports.sep = '\\';
+ exports.delimiter = ';';
+
+} else /* posix */ {
+
+ // Split a filename into [root, dir, basename, ext], unix version
+ // 'root' is just a slash, or nothing.
+ var splitPathRe =
+ /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ var splitPath = function(filename) {
+ return splitPathRe.exec(filename).slice(1);
+ };
+
+ // path.resolve([from ...], to)
+ // posix version
+ exports.resolve = function() {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : process.cwd();
+
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+
+ // Normalize the path
+ resolvedPath = normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ };
+
+ // path.normalize(path)
+ // posix version
+ exports.normalize = function(path) {
+ var isAbsolute = exports.isAbsolute(path),
+ trailingSlash = path.substr(-1) === '/';
+
+ // Normalize the path
+ path = normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+
+ return (isAbsolute ? '/' : '') + path;
+ };
+
+ // posix version
+ exports.isAbsolute = function(path) {
+ return path.charAt(0) === '/';
+ };
+
+ // posix version
+ exports.join = function() {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return exports.normalize(paths.filter(function(p, index) {
+ if (typeof p !== 'string') {
+ throw new TypeError('Arguments to path.join must be strings');
+ }
+ return p;
+ }).join('/'));
+ };
+
+
+ // path.relative(from, to)
+ // posix version
+ exports.relative = function(from, to) {
+ from = exports.resolve(from).substr(1);
+ to = exports.resolve(to).substr(1);
+
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+
+ return outputParts.join('/');
+ };
+
+ exports.sep = '/';
+ exports.delimiter = ':';
+}
+
+exports.dirname = function(path) {
+ var result = splitPath(path),
+ root = result[0],
+ dir = result[1];
+
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+
+ return root + dir;
+};
+
+
+exports.basename = function(path, ext) {
+ var f = splitPath(path)[2];
+ // TODO: make this comparison case-insensitive on windows?
+ if (ext && f.substr(-1 * ext.length) === ext) {
+ f = f.substr(0, f.length - ext.length);
+ }
+ return f;
+};
+
+
+exports.extname = function(path) {
+ return splitPath(path)[3];
+};
+
+if (isWindows) {
+ exports._makeLong = function(path) {
+ // Note: this will *probably* throw somewhere.
+ if (typeof path !== 'string')
+ return path;
+
+ if (!path) {
+ return '';
+ }
+
+ var resolvedPath = exports.resolve(path);
+
+ if (/^[a-zA-Z]\:\\/.test(resolvedPath)) {
+ // path is local filesystem path, which needs to be converted
+ // to long UNC path.
+ return '\\\\?\\' + resolvedPath;
+ } else if (/^\\\\[^?.]/.test(resolvedPath)) {
+ // path is network UNC path, which needs to be converted
+ // to long UNC path.
+ return '\\\\?\\UNC\\' + resolvedPath.substring(2);
+ }
+
+ return path;
+ };
+} else {
+ exports._makeLong = function(path) {
+ return path;
+ };
+} \ No newline at end of file
diff --git a/toolkit/jetpack/sdk/hotkeys.js b/toolkit/jetpack/sdk/hotkeys.js
new file mode 100644
index 000000000..00081455e
--- /dev/null
+++ b/toolkit/jetpack/sdk/hotkeys.js
@@ -0,0 +1,40 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const INVALID_HOTKEY = "Hotkey must have at least one modifier.";
+
+const { toJSON: jsonify, toString: stringify,
+ isFunctionKey } = require("./keyboard/utils");
+const { register, unregister } = require("./keyboard/hotkeys");
+
+const Hotkey = exports.Hotkey = function Hotkey(options) {
+ if (!(this instanceof Hotkey))
+ return new Hotkey(options);
+
+ // Parsing key combination string.
+ let hotkey = jsonify(options.combo);
+ if (!isFunctionKey(hotkey.key) && !hotkey.modifiers.length) {
+ throw new TypeError(INVALID_HOTKEY);
+ }
+
+ this.onPress = options.onPress && options.onPress.bind(this);
+ this.toString = stringify.bind(null, hotkey);
+ // Registering listener on keyboard combination enclosed by this hotkey.
+ // Please note that `this.toString()` is a normalized version of
+ // `options.combination` where order of modifiers is sorted and `accel` is
+ // replaced with platform specific key.
+ register(this.toString(), this.onPress);
+ // We freeze instance before returning it in order to make it's properties
+ // read-only.
+ return Object.freeze(this);
+};
+Hotkey.prototype.destroy = function destroy() {
+ unregister(this.toString(), this.onPress);
+};
diff --git a/toolkit/jetpack/sdk/indexed-db.js b/toolkit/jetpack/sdk/indexed-db.js
new file mode 100644
index 000000000..d4d166c02
--- /dev/null
+++ b/toolkit/jetpack/sdk/indexed-db.js
@@ -0,0 +1,79 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci } = require("chrome");
+const { id } = require("./self");
+
+// placeholder, copied from bootstrap.js
+var sanitizeId = function(id){
+ let uuidRe =
+ /^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/;
+
+ let domain = id.
+ toLowerCase().
+ replace(/@/g, "-at-").
+ replace(/\./g, "-dot-").
+ replace(uuidRe, "$1");
+
+ return domain
+};
+
+const PSEUDOURI = "indexeddb://" + sanitizeId(id) // https://bugzilla.mozilla.org/show_bug.cgi?id=779197
+
+// Use XPCOM because `require("./url").URL` doesn't expose the raw uri object.
+var principaluri = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService).
+ newURI(PSEUDOURI, null, null);
+
+var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
+ .getService(Ci.nsIScriptSecurityManager);
+var principal = ssm.createCodebasePrincipal(principaluri, {});
+
+function toArray(args) {
+ return Array.prototype.slice.call(args);
+}
+
+function openInternal(args, forPrincipal, deleting) {
+ if (forPrincipal) {
+ args = toArray(args);
+ } else {
+ args = [principal].concat(toArray(args));
+ }
+ if (args.length == 2) {
+ args.push({ storage: "persistent" });
+ } else if (!deleting && args.length >= 3 && typeof args[2] === "number") {
+ args[2] = { version: args[2], storage: "persistent" };
+ }
+
+ if (deleting) {
+ return indexedDB.deleteForPrincipal.apply(indexedDB, args);
+ }
+
+ return indexedDB.openForPrincipal.apply(indexedDB, args);
+}
+
+exports.indexedDB = Object.freeze({
+ open: function () {
+ return openInternal(arguments, false, false);
+ },
+ deleteDatabase: function () {
+ return openInternal(arguments, false, true);
+ },
+ openForPrincipal: function () {
+ return openInternal(arguments, true, false);
+ },
+ deleteForPrincipal: function () {
+ return openInternal(arguments, true, true);
+ },
+ cmp: indexedDB.cmp.bind(indexedDB)
+});
+
+exports.IDBKeyRange = IDBKeyRange;
+exports.DOMException = Ci.nsIDOMDOMException;
diff --git a/toolkit/jetpack/sdk/input/browser.js b/toolkit/jetpack/sdk/input/browser.js
new file mode 100644
index 000000000..daea875bf
--- /dev/null
+++ b/toolkit/jetpack/sdk/input/browser.js
@@ -0,0 +1,73 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { windows, isBrowser, isInteractive, isDocumentLoaded,
+ getOuterId } = require("../window/utils");
+const { InputPort } = require("./system");
+const { lift, merges, foldp, keepIf, start, Input } = require("../event/utils");
+const { patch } = require("diffpatcher/index");
+const { Sequence, seq, filter, object, pairs } = require("../util/sequence");
+
+
+// Create lazy iterators from the regular arrays, although
+// once https://github.com/mozilla/addon-sdk/pull/1314 lands
+// `windows` will be transforme to lazy iterators.
+// When iterated over belowe sequences items will represent
+// state of windows at the time of iteration.
+const opened = seq(function*() {
+ const items = windows("navigator:browser", {includePrivate: true});
+ for (let item of items) {
+ yield [getOuterId(item), item];
+ }
+});
+const interactive = filter(([_, window]) => isInteractive(window), opened);
+const loaded = filter(([_, window]) => isDocumentLoaded(window), opened);
+
+// Helper function that converts given argument to a delta.
+const Update = window => window && object([getOuterId(window), window]);
+const Delete = window => window && object([getOuterId(window), null]);
+
+
+// Signal represents delta for last top level window close.
+const LastClosed = lift(Delete,
+ keepIf(isBrowser, null,
+ new InputPort({topic: "domwindowclosed"})));
+exports.LastClosed = LastClosed;
+
+const windowFor = document => document && document.defaultView;
+
+// Signal represent delta for last top level window document becoming interactive.
+const InteractiveDoc = new InputPort({topic: "chrome-document-interactive"});
+const InteractiveWin = lift(windowFor, InteractiveDoc);
+const LastInteractive = lift(Update, keepIf(isBrowser, null, InteractiveWin));
+exports.LastInteractive = LastInteractive;
+
+// Signal represent delta for last top level window loaded.
+const LoadedDoc = new InputPort({topic: "chrome-document-loaded"});
+const LoadedWin = lift(windowFor, LoadedDoc);
+const LastLoaded = lift(Update, keepIf(isBrowser, null, LoadedWin));
+exports.LastLoaded = LastLoaded;
+
+
+const initialize = input => {
+ if (!input.initialized) {
+ input.value = object(...input.value);
+ Input.start(input);
+ input.initialized = true;
+ }
+};
+
+// Signal represents set of top level interactive windows, updated any
+// time new window becomes interactive or one get's closed.
+const Interactive = foldp(patch, interactive, merges([LastInteractive,
+ LastClosed]));
+Interactive[start] = initialize;
+exports.Interactive = Interactive;
+
+// Signal represents set of top level loaded window, updated any time
+// new window becomes interactive or one get's closed.
+const Loaded = foldp(patch, loaded, merges([LastLoaded, LastClosed]));
+Loaded[start] = initialize;
+exports.Loaded = Loaded;
diff --git a/toolkit/jetpack/sdk/input/customizable-ui.js b/toolkit/jetpack/sdk/input/customizable-ui.js
new file mode 100644
index 000000000..a41d0971a
--- /dev/null
+++ b/toolkit/jetpack/sdk/input/customizable-ui.js
@@ -0,0 +1,28 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Cu } = require("chrome");
+const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
+const { receive } = require("../event/utils");
+const { InputPort } = require("./system");
+const { object} = require("../util/sequence");
+const { getOuterId } = require("../window/utils");
+
+const Input = function() {};
+Input.prototype = Object.create(InputPort.prototype);
+
+Input.prototype.onCustomizeStart = function (window) {
+ receive(this, object([getOuterId(window), true]));
+}
+
+Input.prototype.onCustomizeEnd = function (window) {
+ receive(this, object([getOuterId(window), null]));
+}
+
+Input.prototype.addListener = input => CustomizableUI.addListener(input);
+
+Input.prototype.removeListener = input => CustomizableUI.removeListener(input);
+
+exports.CustomizationInput = Input;
diff --git a/toolkit/jetpack/sdk/input/frame.js b/toolkit/jetpack/sdk/input/frame.js
new file mode 100644
index 000000000..50efaa745
--- /dev/null
+++ b/toolkit/jetpack/sdk/input/frame.js
@@ -0,0 +1,85 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Ci } = require("chrome");
+const { InputPort } = require("./system");
+const { getFrameElement, getOuterId,
+ getOwnerBrowserWindow } = require("../window/utils");
+const { isnt } = require("../lang/functional");
+const { foldp, lift, merges, keepIf } = require("../event/utils");
+const { object } = require("../util/sequence");
+const { compose } = require("../lang/functional");
+const { LastClosed } = require("./browser");
+const { patch } = require("diffpatcher/index");
+
+const Document = Ci.nsIDOMDocument;
+
+const isntNull = isnt(null);
+
+const frameID = frame => frame.id;
+const browserID = compose(getOuterId, getOwnerBrowserWindow);
+
+const isInnerFrame = frame =>
+ frame && frame.hasAttribute("data-is-sdk-inner-frame");
+
+// Utility function that given content window loaded in our frame views returns
+// an actual frame. This basically takes care of fact that actual frame document
+// is loaded in the nested iframe. If content window is not loaded in the nested
+// frame of the frame view it returs null.
+const getFrame = document =>
+ document && document.defaultView && getFrameElement(document.defaultView);
+
+const FrameInput = function(options) {
+ const input = keepIf(isInnerFrame, null,
+ lift(getFrame, new InputPort(options)));
+ return lift(frame => {
+ if (!frame) return frame;
+ const [id, owner] = [frameID(frame), browserID(frame)];
+ return object([id, {owners: object([owner, options.update])}]);
+ }, input);
+};
+
+const LastLoading = new FrameInput({topic: "document-element-inserted",
+ update: {readyState: "loading"}});
+exports.LastLoading = LastLoading;
+
+const LastInteractive = new FrameInput({topic: "content-document-interactive",
+ update: {readyState: "interactive"}});
+exports.LastInteractive = LastInteractive;
+
+const LastLoaded = new FrameInput({topic: "content-document-loaded",
+ update: {readyState: "complete"}});
+exports.LastLoaded = LastLoaded;
+
+const LastUnloaded = new FrameInput({topic: "content-page-hidden",
+ update: null});
+exports.LastUnloaded = LastUnloaded;
+
+// Represents state of SDK frames in form of data structure:
+// {"frame#1": {"id": "frame#1",
+// "inbox": {"data": "ping",
+// "target": {"id": "frame#1", "owner": "outerWindowID#2"},
+// "source": {"id": "frame#1"}}
+// "url": "resource://addon-1/data/index.html",
+// "owners": {"outerWindowID#1": {"readyState": "loading"},
+// "outerWindowID#2": {"readyState": "complete"}}
+//
+//
+// frame#2: {"id": "frame#2",
+// "url": "resource://addon-1/data/main.html",
+// "outbox": {"data": "pong",
+// "source": {"id": "frame#2", "owner": "outerWindowID#1"}
+// "target": {"id": "frame#2"}}
+// "owners": {outerWindowID#1: {readyState: "interacitve"}}}}
+const Frames = foldp(patch, {}, merges([
+ LastLoading,
+ LastInteractive,
+ LastLoaded,
+ LastUnloaded,
+ new InputPort({ id: "frame-mailbox" }),
+ new InputPort({ id: "frame-change" }),
+ new InputPort({ id: "frame-changed" })
+]));
+exports.Frames = Frames;
diff --git a/toolkit/jetpack/sdk/input/system.js b/toolkit/jetpack/sdk/input/system.js
new file mode 100644
index 000000000..66bc6daec
--- /dev/null
+++ b/toolkit/jetpack/sdk/input/system.js
@@ -0,0 +1,113 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Cc, Ci, Cr, Cu } = require("chrome");
+const { Input, start, stop, end, receive, outputs } = require("../event/utils");
+const { once, off } = require("../event/core");
+const { id: addonID } = require("../self");
+
+const unloadMessage = require("@loader/unload");
+const observerService = Cc['@mozilla.org/observer-service;1'].
+ getService(Ci.nsIObserverService);
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+const addObserver = ShimWaiver.getProperty(observerService, "addObserver");
+const removeObserver = ShimWaiver.getProperty(observerService, "removeObserver");
+
+
+const addonUnloadTopic = "sdk:loader:destroy";
+
+const isXrayWrapper = Cu.isXrayWrapper;
+// In the past SDK used to double-wrap notifications dispatched, which
+// made them awkward to use outside of SDK. At present they no longer
+// do that, although we still supported for legacy reasons.
+const isLegacyWrapper = x =>
+ x && x.wrappedJSObject &&
+ "observersModuleSubjectWrapper" in x.wrappedJSObject;
+
+const unwrapLegacy = x => x.wrappedJSObject.object;
+
+// `InputPort` provides a way to create a signal out of the observer
+// notification subject's for the given `topic`. If `options.initial`
+// is provided it is used as initial value otherwise `null` is used.
+// Constructor can be given `options.id` that will be used to create
+// a `topic` which is namespaced to an add-on (this avoids conflicts
+// when multiple add-on are used, although in a future host probably
+// should just be shared across add-ons). It is also possible to
+// specify a specific `topic` via `options.topic` which is used as
+// without namespacing. Created signal ends whenever add-on is
+// unloaded.
+const InputPort = function InputPort({id, topic, initial}) {
+ this.id = id || topic;
+ this.topic = topic || "sdk:" + addonID + ":" + id;
+ this.value = initial === void(0) ? null : initial;
+ this.observing = false;
+ this[outputs] = [];
+};
+
+// InputPort type implements `Input` signal interface.
+InputPort.prototype = new Input();
+InputPort.prototype.constructor = InputPort;
+
+// When port is started (which is when it's subgraph get's
+// first subscriber) actual observer is registered.
+InputPort.start = input => {
+ input.addListener(input);
+ // Also register add-on unload observer to end this signal
+ // when that happens.
+ addObserver(input, addonUnloadTopic, false);
+};
+InputPort.prototype[start] = InputPort.start;
+
+InputPort.addListener = input => addObserver(input, input.topic, false);
+InputPort.prototype.addListener = InputPort.addListener;
+
+// When port is stopped (which is when it's subgraph has no
+// no subcribers left) an actual observer unregistered.
+// Note that port stopped once it ends as well (which is when
+// add-on is unloaded).
+InputPort.stop = input => {
+ input.removeListener(input);
+ removeObserver(input, addonUnloadTopic);
+};
+InputPort.prototype[stop] = InputPort.stop;
+
+InputPort.removeListener = input => removeObserver(input, input.topic);
+InputPort.prototype.removeListener = InputPort.removeListener;
+
+// `InputPort` also implements `nsIObserver` interface and
+// `nsISupportsWeakReference` interfaces as it's going to be used as such.
+InputPort.prototype.QueryInterface = function(iid) {
+ if (!iid.equals(Ci.nsIObserver) && !iid.equals(Ci.nsISupportsWeakReference))
+ throw Cr.NS_ERROR_NO_INTERFACE;
+
+ return this;
+};
+
+// `InputPort` instances implement `observe` method, which is invoked when
+// observer notifications are dispatched. The `subject` of that notification
+// are received on this signal.
+InputPort.prototype.observe = function(subject, topic, data) {
+ // Unwrap message from the subject. SDK used to have it's own version of
+ // wrappedJSObjects which take precedence, if subject has `wrappedJSObject`
+ // and it's not an XrayWrapper use it as message. Otherwise use subject as
+ // is.
+ const message = subject === null ? null :
+ isLegacyWrapper(subject) ? unwrapLegacy(subject) :
+ isXrayWrapper(subject) ? subject :
+ subject.wrappedJSObject ? subject.wrappedJSObject :
+ subject;
+
+ // If observer topic matches topic of the input port receive a message.
+ if (topic === this.topic) {
+ receive(this, message);
+ }
+
+ // If observe topic is add-on unload topic we create an end message.
+ if (topic === addonUnloadTopic && message === unloadMessage) {
+ end(this);
+ }
+};
+
+exports.InputPort = InputPort;
diff --git a/toolkit/jetpack/sdk/io/buffer.js b/toolkit/jetpack/sdk/io/buffer.js
new file mode 100644
index 000000000..5ea169402
--- /dev/null
+++ b/toolkit/jetpack/sdk/io/buffer.js
@@ -0,0 +1,351 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental'
+};
+
+/*
+ * Encodings supported by TextEncoder/Decoder:
+ * utf-8, utf-16le, utf-16be
+ * http://encoding.spec.whatwg.org/#interface-textencoder
+ *
+ * Node however supports the following encodings:
+ * ascii, utf-8, utf-16le, usc2, base64, hex
+ */
+
+const { Cu } = require('chrome');
+const { isNumber } = require('sdk/lang/type');
+const { TextEncoder, TextDecoder } = Cu.import('resource://gre/modules/commonjs/toolkit/loader.js', {});
+
+exports.TextEncoder = TextEncoder;
+exports.TextDecoder = TextDecoder;
+
+/**
+ * Use WeakMaps to work around Bug 929146, which prevents us from adding
+ * getters or values to typed arrays
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=929146
+ */
+const parents = new WeakMap();
+const views = new WeakMap();
+
+function Buffer(subject, encoding /*, bufferLength */) {
+
+ // Allow invocation without `new` constructor
+ if (!(this instanceof Buffer))
+ return new Buffer(subject, encoding, arguments[2]);
+
+ var type = typeof(subject);
+
+ switch (type) {
+ case 'number':
+ // Create typed array of the given size if number.
+ try {
+ let buffer = new Uint8Array(subject > 0 ? Math.floor(subject) : 0);
+ return buffer;
+ } catch (e) {
+ if (/size and count too large/.test(e.message) ||
+ /invalid arguments/.test(e.message))
+ throw new RangeError('Could not instantiate buffer: size of buffer may be too large');
+ else
+ throw new Error('Could not instantiate buffer');
+ }
+ break;
+ case 'string':
+ // If string encode it and use buffer for the returned Uint8Array
+ // to create a local patched version that acts like node buffer.
+ encoding = encoding || 'utf8';
+ return new Uint8Array(new TextEncoder(encoding).encode(subject).buffer);
+ case 'object':
+ // This form of the constructor uses the form of
+ // new Uint8Array(buffer, offset, length);
+ // So we can instantiate a typed array within the constructor
+ // to inherit the appropriate properties, where both the
+ // `subject` and newly instantiated buffer share the same underlying
+ // data structure.
+ if (arguments.length === 3)
+ return new Uint8Array(subject, encoding, arguments[2]);
+ // If array or alike just make a copy with a local patched prototype.
+ else
+ return new Uint8Array(subject);
+ default:
+ throw new TypeError('must start with number, buffer, array or string');
+ }
+}
+exports.Buffer = Buffer;
+
+// Tests if `value` is a Buffer.
+Buffer.isBuffer = value => value instanceof Buffer
+
+// Returns true if the encoding is a valid encoding argument & false otherwise
+Buffer.isEncoding = function (encoding) {
+ if (!encoding) return false;
+ try {
+ new TextDecoder(encoding);
+ } catch(e) {
+ return false;
+ }
+ return true;
+}
+
+// Gives the actual byte length of a string. encoding defaults to 'utf8'.
+// This is not the same as String.prototype.length since that returns the
+// number of characters in a string.
+Buffer.byteLength = (value, encoding = 'utf8') =>
+ new TextEncoder(encoding).encode(value).byteLength
+
+// Direct copy of the nodejs's buffer implementation:
+// https://github.com/joyent/node/blob/b255f4c10a80343f9ce1cee56d0288361429e214/lib/buffer.js#L146-L177
+Buffer.concat = function(list, length) {
+ if (!Array.isArray(list))
+ throw new TypeError('Usage: Buffer.concat(list[, length])');
+
+ if (typeof length === 'undefined') {
+ length = 0;
+ for (var i = 0; i < list.length; i++)
+ length += list[i].length;
+ } else {
+ length = ~~length;
+ }
+
+ if (length < 0)
+ length = 0;
+
+ if (list.length === 0)
+ return new Buffer(0);
+ else if (list.length === 1)
+ return list[0];
+
+ if (length < 0)
+ throw new RangeError('length is not a positive number');
+
+ var buffer = new Buffer(length);
+ var pos = 0;
+ for (var i = 0; i < list.length; i++) {
+ var buf = list[i];
+ buf.copy(buffer, pos);
+ pos += buf.length;
+ }
+
+ return buffer;
+};
+
+// Node buffer is very much like Uint8Array although it has bunch of methods
+// that typically can be used in combination with `DataView` while preserving
+// access by index. Since in SDK each module has it's own set of bult-ins it
+// ok to patch ours to make it nodejs Buffer compatible.
+const Uint8ArraySet = Uint8Array.prototype.set
+Buffer.prototype = Uint8Array.prototype;
+Object.defineProperties(Buffer.prototype, {
+ parent: {
+ get: function() { return parents.get(this, undefined); }
+ },
+ view: {
+ get: function () {
+ let view = views.get(this, undefined);
+ if (view) return view;
+ view = new DataView(this.buffer);
+ views.set(this, view);
+ return view;
+ }
+ },
+ toString: {
+ value: function(encoding, start, end) {
+ encoding = !!encoding ? (encoding + '').toLowerCase() : 'utf8';
+ start = Math.max(0, ~~start);
+ end = Math.min(this.length, end === void(0) ? this.length : ~~end);
+ return new TextDecoder(encoding).decode(this.subarray(start, end));
+ }
+ },
+ toJSON: {
+ value: function() {
+ return { type: 'Buffer', data: Array.slice(this, 0) };
+ }
+ },
+ get: {
+ value: function(offset) {
+ return this[offset];
+ }
+ },
+ set: {
+ value: function(offset, value) { this[offset] = value; }
+ },
+ copy: {
+ value: function(target, offset, start, end) {
+ let length = this.length;
+ let targetLength = target.length;
+ offset = isNumber(offset) ? offset : 0;
+ start = isNumber(start) ? start : 0;
+
+ if (start < 0)
+ throw new RangeError('sourceStart is outside of valid range');
+ if (end < 0)
+ throw new RangeError('sourceEnd is outside of valid range');
+
+ // If sourceStart > sourceEnd, or targetStart > targetLength,
+ // zero bytes copied
+ if (start > end ||
+ offset > targetLength
+ )
+ return 0;
+
+ // If `end` is not defined, or if it is defined
+ // but would overflow `target`, redefine `end`
+ // so we can copy as much as we can
+ if (end - start > targetLength - offset ||
+ end == null) {
+ let remainingTarget = targetLength - offset;
+ let remainingSource = length - start;
+ if (remainingSource <= remainingTarget)
+ end = length;
+ else
+ end = start + remainingTarget;
+ }
+
+ Uint8ArraySet.call(target, this.subarray(start, end), offset);
+ return end - start;
+ }
+ },
+ slice: {
+ value: function(start, end) {
+ let length = this.length;
+ start = ~~start;
+ end = end != null ? end : length;
+
+ if (start < 0) {
+ start += length;
+ if (start < 0) start = 0;
+ } else if (start > length)
+ start = length;
+
+ if (end < 0) {
+ end += length;
+ if (end < 0) end = 0;
+ } else if (end > length)
+ end = length;
+
+ if (end < start)
+ end = start;
+
+ // This instantiation uses the new Uint8Array(buffer, offset, length) version
+ // of construction to share the same underling data structure
+ let buffer = new Buffer(this.buffer, start, end - start);
+
+ // If buffer has a value, assign its parent value to the
+ // buffer it shares its underlying structure with. If a slice of
+ // a slice, then use the root structure
+ if (buffer.length > 0)
+ parents.set(buffer, this.parent || this);
+
+ return buffer;
+ }
+ },
+ write: {
+ value: function(string, offset, length, encoding = 'utf8') {
+ // write(string, encoding);
+ if (typeof(offset) === 'string' && Number.isNaN(parseInt(offset))) {
+ [offset, length, encoding] = [0, null, offset];
+ }
+ // write(string, offset, encoding);
+ else if (typeof(length) === 'string')
+ [length, encoding] = [null, length];
+
+ if (offset < 0 || offset > this.length)
+ throw new RangeError('offset is outside of valid range');
+
+ offset = ~~offset;
+
+ // Clamp length if it would overflow buffer, or if its
+ // undefined
+ if (length == null || length + offset > this.length)
+ length = this.length - offset;
+
+ let buffer = new TextEncoder(encoding).encode(string);
+ let result = Math.min(buffer.length, length);
+ if (buffer.length !== length)
+ buffer = buffer.subarray(0, length);
+
+ Uint8ArraySet.call(this, buffer, offset);
+ return result;
+ }
+ },
+ fill: {
+ value: function fill(value, start, end) {
+ let length = this.length;
+ value = value || 0;
+ start = start || 0;
+ end = end || length;
+
+ if (typeof(value) === 'string')
+ value = value.charCodeAt(0);
+ if (typeof(value) !== 'number' || isNaN(value))
+ throw TypeError('value is not a number');
+ if (end < start)
+ throw new RangeError('end < start');
+
+ // Fill 0 bytes; we're done
+ if (end === start)
+ return 0;
+ if (length == 0)
+ return 0;
+
+ if (start < 0 || start >= length)
+ throw RangeError('start out of bounds');
+
+ if (end < 0 || end > length)
+ throw RangeError('end out of bounds');
+
+ let index = start;
+ while (index < end) this[index++] = value;
+ }
+ }
+});
+
+// Define nodejs Buffer's getter and setter functions that just proxy
+// to internal DataView's equivalent methods.
+
+// TODO do we need to check architecture to see if it's default big/little endian?
+[['readUInt16LE', 'getUint16', true],
+ ['readUInt16BE', 'getUint16', false],
+ ['readInt16LE', 'getInt16', true],
+ ['readInt16BE', 'getInt16', false],
+ ['readUInt32LE', 'getUint32', true],
+ ['readUInt32BE', 'getUint32', false],
+ ['readInt32LE', 'getInt32', true],
+ ['readInt32BE', 'getInt32', false],
+ ['readFloatLE', 'getFloat32', true],
+ ['readFloatBE', 'getFloat32', false],
+ ['readDoubleLE', 'getFloat64', true],
+ ['readDoubleBE', 'getFloat64', false],
+ ['readUInt8', 'getUint8'],
+ ['readInt8', 'getInt8']].forEach(([alias, name, littleEndian]) => {
+ Object.defineProperty(Buffer.prototype, alias, {
+ value: function(offset) {
+ return this.view[name](offset, littleEndian);
+ }
+ });
+});
+
+[['writeUInt16LE', 'setUint16', true],
+ ['writeUInt16BE', 'setUint16', false],
+ ['writeInt16LE', 'setInt16', true],
+ ['writeInt16BE', 'setInt16', false],
+ ['writeUInt32LE', 'setUint32', true],
+ ['writeUInt32BE', 'setUint32', false],
+ ['writeInt32LE', 'setInt32', true],
+ ['writeInt32BE', 'setInt32', false],
+ ['writeFloatLE', 'setFloat32', true],
+ ['writeFloatBE', 'setFloat32', false],
+ ['writeDoubleLE', 'setFloat64', true],
+ ['writeDoubleBE', 'setFloat64', false],
+ ['writeUInt8', 'setUint8'],
+ ['writeInt8', 'setInt8']].forEach(([alias, name, littleEndian]) => {
+ Object.defineProperty(Buffer.prototype, alias, {
+ value: function(value, offset) {
+ return this.view[name](offset, value, littleEndian);
+ }
+ });
+});
diff --git a/toolkit/jetpack/sdk/io/byte-streams.js b/toolkit/jetpack/sdk/io/byte-streams.js
new file mode 100644
index 000000000..6afab4369
--- /dev/null
+++ b/toolkit/jetpack/sdk/io/byte-streams.js
@@ -0,0 +1,104 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+exports.ByteReader = ByteReader;
+exports.ByteWriter = ByteWriter;
+
+const {Cc, Ci} = require("chrome");
+
+// This just controls the maximum number of bytes we read in at one time.
+const BUFFER_BYTE_LEN = 0x8000;
+
+function ByteReader(inputStream) {
+ const self = this;
+
+ let stream = Cc["@mozilla.org/binaryinputstream;1"].
+ createInstance(Ci.nsIBinaryInputStream);
+ stream.setInputStream(inputStream);
+
+ let manager = new StreamManager(this, stream);
+
+ this.read = function ByteReader_read(numBytes) {
+ manager.ensureOpened();
+ if (typeof(numBytes) !== "number")
+ numBytes = Infinity;
+
+ let data = "";
+ let read = 0;
+ try {
+ while (true) {
+ let avail = stream.available();
+ let toRead = Math.min(numBytes - read, avail, BUFFER_BYTE_LEN);
+ if (toRead <= 0)
+ break;
+ data += stream.readBytes(toRead);
+ read += toRead;
+ }
+ }
+ catch (err) {
+ throw new Error("Error reading from stream: " + err);
+ }
+
+ return data;
+ };
+}
+
+function ByteWriter(outputStream) {
+ const self = this;
+
+ let stream = Cc["@mozilla.org/binaryoutputstream;1"].
+ createInstance(Ci.nsIBinaryOutputStream);
+ stream.setOutputStream(outputStream);
+
+ let manager = new StreamManager(this, stream);
+
+ this.write = function ByteWriter_write(str) {
+ manager.ensureOpened();
+ try {
+ stream.writeBytes(str, str.length);
+ }
+ catch (err) {
+ throw new Error("Error writing to stream: " + err);
+ }
+ };
+}
+
+
+// This manages the lifetime of stream, a ByteReader or ByteWriter. It defines
+// closed and close() on stream and registers an unload listener that closes
+// rawStream if it's still opened. It also provides ensureOpened(), which
+// throws an exception if the stream is closed.
+function StreamManager(stream, rawStream) {
+ const self = this;
+ this.rawStream = rawStream;
+ this.opened = true;
+
+ stream.__defineGetter__("closed", function stream_closed() {
+ return !self.opened;
+ });
+
+ stream.close = function stream_close() {
+ self.ensureOpened();
+ self.unload();
+ };
+
+ require("../system/unload").ensure(this);
+}
+
+StreamManager.prototype = {
+ ensureOpened: function StreamManager_ensureOpened() {
+ if (!this.opened)
+ throw new Error("The stream is closed and cannot be used.");
+ },
+ unload: function StreamManager_unload() {
+ this.rawStream.close();
+ this.opened = false;
+ }
+};
diff --git a/toolkit/jetpack/sdk/io/file.js b/toolkit/jetpack/sdk/io/file.js
new file mode 100644
index 000000000..47467df87
--- /dev/null
+++ b/toolkit/jetpack/sdk/io/file.js
@@ -0,0 +1,196 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "deprecated"
+};
+
+const {Cc,Ci,Cr} = require("chrome");
+const byteStreams = require("./byte-streams");
+const textStreams = require("./text-streams");
+
+// Flags passed when opening a file. See nsprpub/pr/include/prio.h.
+const OPEN_FLAGS = {
+ RDONLY: parseInt("0x01"),
+ WRONLY: parseInt("0x02"),
+ CREATE_FILE: parseInt("0x08"),
+ APPEND: parseInt("0x10"),
+ TRUNCATE: parseInt("0x20"),
+ EXCL: parseInt("0x80")
+};
+
+var dirsvc = Cc["@mozilla.org/file/directory_service;1"]
+ .getService(Ci.nsIProperties);
+
+function MozFile(path) {
+ var file = Cc['@mozilla.org/file/local;1']
+ .createInstance(Ci.nsILocalFile);
+ file.initWithPath(path);
+ return file;
+}
+
+function ensureReadable(file) {
+ if (!file.isReadable())
+ throw new Error("path is not readable: " + file.path);
+}
+
+function ensureDir(file) {
+ ensureExists(file);
+ if (!file.isDirectory())
+ throw new Error("path is not a directory: " + file.path);
+}
+
+function ensureFile(file) {
+ ensureExists(file);
+ if (!file.isFile())
+ throw new Error("path is not a file: " + file.path);
+}
+
+function ensureExists(file) {
+ if (!file.exists())
+ throw friendlyError(Cr.NS_ERROR_FILE_NOT_FOUND, file.path);
+}
+
+function friendlyError(errOrResult, filename) {
+ var isResult = typeof(errOrResult) === "number";
+ var result = isResult ? errOrResult : errOrResult.result;
+ switch (result) {
+ case Cr.NS_ERROR_FILE_NOT_FOUND:
+ return new Error("path does not exist: " + filename);
+ }
+ return isResult ? new Error("XPCOM error code: " + errOrResult) : errOrResult;
+}
+
+exports.exists = function exists(filename) {
+ return MozFile(filename).exists();
+};
+
+exports.isFile = function isFile(filename) {
+ return MozFile(filename).isFile();
+};
+
+exports.read = function read(filename, mode) {
+ if (typeof(mode) !== "string")
+ mode = "";
+
+ // Ensure mode is read-only.
+ mode = /b/.test(mode) ? "b" : "";
+
+ var stream = exports.open(filename, mode);
+ try {
+ var str = stream.read();
+ }
+ finally {
+ stream.close();
+ }
+
+ return str;
+};
+
+exports.join = function join(base) {
+ if (arguments.length < 2)
+ throw new Error("need at least 2 args");
+ base = MozFile(base);
+ for (var i = 1; i < arguments.length; i++)
+ base.append(arguments[i]);
+ return base.path;
+};
+
+exports.dirname = function dirname(path) {
+ var parent = MozFile(path).parent;
+ return parent ? parent.path : "";
+};
+
+exports.basename = function basename(path) {
+ var leafName = MozFile(path).leafName;
+
+ // On Windows, leafName when the path is a volume letter and colon ("c:") is
+ // the path itself. But such a path has no basename, so we want the empty
+ // string.
+ return leafName == path ? "" : leafName;
+};
+
+exports.list = function list(path) {
+ var file = MozFile(path);
+ ensureDir(file);
+ ensureReadable(file);
+
+ var entries = file.directoryEntries;
+ var entryNames = [];
+ while(entries.hasMoreElements()) {
+ var entry = entries.getNext();
+ entry.QueryInterface(Ci.nsIFile);
+ entryNames.push(entry.leafName);
+ }
+ return entryNames;
+};
+
+exports.open = function open(filename, mode) {
+ var file = MozFile(filename);
+ if (typeof(mode) !== "string")
+ mode = "";
+
+ // File opened for write only.
+ if (/w/.test(mode)) {
+ if (file.exists())
+ ensureFile(file);
+ var stream = Cc['@mozilla.org/network/file-output-stream;1'].
+ createInstance(Ci.nsIFileOutputStream);
+ var openFlags = OPEN_FLAGS.WRONLY |
+ OPEN_FLAGS.CREATE_FILE |
+ OPEN_FLAGS.TRUNCATE;
+ var permFlags = 0o644; // u+rw go+r
+ try {
+ stream.init(file, openFlags, permFlags, 0);
+ }
+ catch (err) {
+ throw friendlyError(err, filename);
+ }
+ return /b/.test(mode) ?
+ new byteStreams.ByteWriter(stream) :
+ new textStreams.TextWriter(stream);
+ }
+
+ // File opened for read only, the default.
+ ensureFile(file);
+ stream = Cc['@mozilla.org/network/file-input-stream;1'].
+ createInstance(Ci.nsIFileInputStream);
+ try {
+ stream.init(file, OPEN_FLAGS.RDONLY, 0, 0);
+ }
+ catch (err) {
+ throw friendlyError(err, filename);
+ }
+ return /b/.test(mode) ?
+ new byteStreams.ByteReader(stream) :
+ new textStreams.TextReader(stream);
+};
+
+exports.remove = function remove(path) {
+ var file = MozFile(path);
+ ensureFile(file);
+ file.remove(false);
+};
+
+exports.mkpath = function mkpath(path) {
+ var file = MozFile(path);
+ if (!file.exists())
+ file.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755); // u+rwx go+rx
+ else if (!file.isDirectory())
+ throw new Error("The path already exists and is not a directory: " + path);
+};
+
+exports.rmdir = function rmdir(path) {
+ var file = MozFile(path);
+ ensureDir(file);
+ try {
+ file.remove(false);
+ }
+ catch (err) {
+ // Bug 566950 explains why we're not catching a specific exception here.
+ throw new Error("The directory is not empty: " + path);
+ }
+};
diff --git a/toolkit/jetpack/sdk/io/fs.js b/toolkit/jetpack/sdk/io/fs.js
new file mode 100644
index 000000000..860a884a5
--- /dev/null
+++ b/toolkit/jetpack/sdk/io/fs.js
@@ -0,0 +1,984 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci, CC } = require("chrome");
+
+const { setTimeout } = require("../timers");
+const { Stream, InputStream, OutputStream } = require("./stream");
+const { emit, on } = require("../event/core");
+const { Buffer } = require("./buffer");
+const { ns } = require("../core/namespace");
+const { Class } = require("../core/heritage");
+
+
+const nsILocalFile = CC("@mozilla.org/file/local;1", "nsILocalFile",
+ "initWithPath");
+const FileOutputStream = CC("@mozilla.org/network/file-output-stream;1",
+ "nsIFileOutputStream", "init");
+const FileInputStream = CC("@mozilla.org/network/file-input-stream;1",
+ "nsIFileInputStream", "init");
+const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
+ "nsIBinaryInputStream", "setInputStream");
+const BinaryOutputStream = CC("@mozilla.org/binaryoutputstream;1",
+ "nsIBinaryOutputStream", "setOutputStream");
+const StreamPump = CC("@mozilla.org/network/input-stream-pump;1",
+ "nsIInputStreamPump", "init");
+
+const { createOutputTransport, createInputTransport } =
+ Cc["@mozilla.org/network/stream-transport-service;1"].
+ getService(Ci.nsIStreamTransportService);
+
+const { OPEN_UNBUFFERED } = Ci.nsITransport;
+
+
+const { REOPEN_ON_REWIND, DEFER_OPEN } = Ci.nsIFileInputStream;
+const { DIRECTORY_TYPE, NORMAL_FILE_TYPE } = Ci.nsIFile;
+const { NS_SEEK_SET, NS_SEEK_CUR, NS_SEEK_END } = Ci.nsISeekableStream;
+
+const FILE_PERMISSION = 0o666;
+const PR_UINT32_MAX = 0xfffffff;
+// Values taken from:
+// http://mxr.mozilla.org/mozilla-central/source/nsprpub/pr/include/prio.h#615
+const PR_RDONLY = 0x01;
+const PR_WRONLY = 0x02;
+const PR_RDWR = 0x04;
+const PR_CREATE_FILE = 0x08;
+const PR_APPEND = 0x10;
+const PR_TRUNCATE = 0x20;
+const PR_SYNC = 0x40;
+const PR_EXCL = 0x80;
+
+const FLAGS = {
+ "r": PR_RDONLY,
+ "r+": PR_RDWR,
+ "w": PR_CREATE_FILE | PR_TRUNCATE | PR_WRONLY,
+ "w+": PR_CREATE_FILE | PR_TRUNCATE | PR_RDWR,
+ "a": PR_APPEND | PR_CREATE_FILE | PR_WRONLY,
+ "a+": PR_APPEND | PR_CREATE_FILE | PR_RDWR
+};
+
+function accessor() {
+ let map = new WeakMap();
+ return function(fd, value) {
+ if (value === null) map.delete(fd);
+ if (value !== undefined) map.set(fd, value);
+ return map.get(fd);
+ }
+}
+
+var nsIFile = accessor();
+var nsIFileInputStream = accessor();
+var nsIFileOutputStream = accessor();
+var nsIBinaryInputStream = accessor();
+var nsIBinaryOutputStream = accessor();
+
+// Just a contstant object used to signal that all of the file
+// needs to be read.
+const ALL = new String("Read all of the file");
+
+function isWritable(mode) {
+ return !!(mode & PR_WRONLY || mode & PR_RDWR);
+}
+function isReadable(mode) {
+ return !!(mode & PR_RDONLY || mode & PR_RDWR);
+}
+
+function isString(value) {
+ return typeof(value) === "string";
+}
+function isFunction(value) {
+ return typeof(value) === "function";
+}
+
+function toArray(enumerator) {
+ let value = [];
+ while(enumerator.hasMoreElements())
+ value.push(enumerator.getNext())
+ return value
+}
+
+function getFileName(file) {
+ return file.QueryInterface(Ci.nsIFile).leafName;
+}
+
+
+function remove(path, recursive) {
+ let fd = new nsILocalFile(path)
+ if (fd.exists()) {
+ fd.remove(recursive || false);
+ }
+ else {
+ throw FSError("remove", "ENOENT", 34, path);
+ }
+}
+
+/**
+ * Utility function to convert either an octal number or string
+ * into an octal number
+ * 0777 => 0o777
+ * "0644" => 0o644
+ */
+function Mode(mode, fallback) {
+ return isString(mode) ? parseInt(mode, 8) : mode || fallback;
+}
+function Flags(flag) {
+ return !isString(flag) ? flag :
+ FLAGS[flag] || Error("Unknown file open flag: " + flag);
+}
+
+
+function FSError(op, code, errno, path, file, line) {
+ let error = Error(code + ", " + op + " " + path, file, line);
+ error.code = code;
+ error.path = path;
+ error.errno = errno;
+ return error;
+}
+
+const ReadStream = Class({
+ extends: InputStream,
+ initialize: function initialize(path, options) {
+ this.position = -1;
+ this.length = -1;
+ this.flags = "r";
+ this.mode = FILE_PERMISSION;
+ this.bufferSize = 64 * 1024;
+
+ options = options || {};
+
+ if ("flags" in options && options.flags)
+ this.flags = options.flags;
+ if ("bufferSize" in options && options.bufferSize)
+ this.bufferSize = options.bufferSize;
+ if ("length" in options && options.length)
+ this.length = options.length;
+ if ("position" in options && options.position !== undefined)
+ this.position = options.position;
+
+ let { flags, mode, position, length } = this;
+ let fd = isString(path) ? openSync(path, flags, mode) : path;
+ this.fd = fd;
+
+ let input = nsIFileInputStream(fd);
+ // Setting a stream position, unless it"s `-1` which means current position.
+ if (position >= 0)
+ input.QueryInterface(Ci.nsISeekableStream).seek(NS_SEEK_SET, position);
+ // We use `nsIStreamTransportService` service to transform blocking
+ // file input stream into a fully asynchronous stream that can be written
+ // without blocking the main thread.
+ let transport = createInputTransport(input, position, length, false);
+ // Open an input stream on a transport. We don"t pass flags to guarantee
+ // non-blocking stream semantics. Also we use defaults for segment size &
+ // count.
+ InputStream.prototype.initialize.call(this, {
+ asyncInputStream: transport.openInputStream(null, 0, 0)
+ });
+
+ // Close file descriptor on end and destroy the stream.
+ on(this, "end", _ => {
+ this.destroy();
+ emit(this, "close");
+ });
+
+ this.read();
+ },
+ destroy: function() {
+ closeSync(this.fd);
+ InputStream.prototype.destroy.call(this);
+ }
+});
+exports.ReadStream = ReadStream;
+exports.createReadStream = function createReadStream(path, options) {
+ return new ReadStream(path, options);
+};
+
+const WriteStream = Class({
+ extends: OutputStream,
+ initialize: function initialize(path, options) {
+ this.drainable = true;
+ this.flags = "w";
+ this.position = -1;
+ this.mode = FILE_PERMISSION;
+
+ options = options || {};
+
+ if ("flags" in options && options.flags)
+ this.flags = options.flags;
+ if ("mode" in options && options.mode)
+ this.mode = options.mode;
+ if ("position" in options && options.position !== undefined)
+ this.position = options.position;
+
+ let { position, flags, mode } = this;
+ // If pass was passed we create a file descriptor out of it. Otherwise
+ // we just use given file descriptor.
+ let fd = isString(path) ? openSync(path, flags, mode) : path;
+ this.fd = fd;
+
+ let output = nsIFileOutputStream(fd);
+ // Setting a stream position, unless it"s `-1` which means current position.
+ if (position >= 0)
+ output.QueryInterface(Ci.nsISeekableStream).seek(NS_SEEK_SET, position);
+ // We use `nsIStreamTransportService` service to transform blocking
+ // file output stream into a fully asynchronous stream that can be written
+ // without blocking the main thread.
+ let transport = createOutputTransport(output, position, -1, false);
+ // Open an output stream on a transport. We don"t pass flags to guarantee
+ // non-blocking stream semantics. Also we use defaults for segment size &
+ // count.
+ OutputStream.prototype.initialize.call(this, {
+ asyncOutputStream: transport.openOutputStream(OPEN_UNBUFFERED, 0, 0),
+ output: output
+ });
+
+ // For write streams "finish" basically means close.
+ on(this, "finish", _ => {
+ this.destroy();
+ emit(this, "close");
+ });
+ },
+ destroy: function() {
+ OutputStream.prototype.destroy.call(this);
+ closeSync(this.fd);
+ }
+});
+exports.WriteStream = WriteStream;
+exports.createWriteStream = function createWriteStream(path, options) {
+ return new WriteStream(path, options);
+};
+
+const Stats = Class({
+ initialize: function initialize(path) {
+ let file = new nsILocalFile(path);
+ if (!file.exists()) throw FSError("stat", "ENOENT", 34, path);
+ nsIFile(this, file);
+ },
+ isDirectory: function() {
+ return nsIFile(this).isDirectory();
+ },
+ isFile: function() {
+ return nsIFile(this).isFile();
+ },
+ isSymbolicLink: function() {
+ return nsIFile(this).isSymlink();
+ },
+ get mode() {
+ return nsIFile(this).permissions;
+ },
+ get size() {
+ return nsIFile(this).fileSize;
+ },
+ get mtime() {
+ return nsIFile(this).lastModifiedTime;
+ },
+ isBlockDevice: function() {
+ return nsIFile(this).isSpecial();
+ },
+ isCharacterDevice: function() {
+ return nsIFile(this).isSpecial();
+ },
+ isFIFO: function() {
+ return nsIFile(this).isSpecial();
+ },
+ isSocket: function() {
+ return nsIFile(this).isSpecial();
+ },
+ // non standard
+ get exists() {
+ return nsIFile(this).exists();
+ },
+ get hidden() {
+ return nsIFile(this).isHidden();
+ },
+ get writable() {
+ return nsIFile(this).isWritable();
+ },
+ get readable() {
+ return nsIFile(this).isReadable();
+ }
+});
+exports.Stats = Stats;
+
+const LStats = Class({
+ extends: Stats,
+ get size() {
+ return this.isSymbolicLink() ? nsIFile(this).fileSizeOfLink :
+ nsIFile(this).fileSize;
+ },
+ get mtime() {
+ return this.isSymbolicLink() ? nsIFile(this).lastModifiedTimeOfLink :
+ nsIFile(this).lastModifiedTime;
+ },
+ // non standard
+ get permissions() {
+ return this.isSymbolicLink() ? nsIFile(this).permissionsOfLink :
+ nsIFile(this).permissions;
+ }
+});
+
+const FStat = Class({
+ extends: Stats,
+ initialize: function initialize(fd) {
+ nsIFile(this, nsIFile(fd));
+ }
+});
+
+function noop() {}
+function Async(wrapped) {
+ return function (path, callback) {
+ let args = Array.slice(arguments);
+ callback = args.pop();
+ // If node is not given a callback argument
+ // it just does not calls it.
+ if (typeof(callback) !== "function") {
+ args.push(callback);
+ callback = noop;
+ }
+ setTimeout(function() {
+ try {
+ var result = wrapped.apply(this, args);
+ if (result === undefined) callback(null);
+ else callback(null, result);
+ } catch (error) {
+ callback(error);
+ }
+ }, 0);
+ }
+}
+
+
+/**
+ * Synchronous rename(2)
+ */
+function renameSync(oldPath, newPath) {
+ let source = new nsILocalFile(oldPath);
+ let target = new nsILocalFile(newPath);
+ if (!source.exists()) throw FSError("rename", "ENOENT", 34, oldPath);
+ return source.moveTo(target.parent, target.leafName);
+};
+exports.renameSync = renameSync;
+
+/**
+ * Asynchronous rename(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+var rename = Async(renameSync);
+exports.rename = rename;
+
+/**
+ * Test whether or not the given path exists by checking with the file system.
+ */
+function existsSync(path) {
+ return new nsILocalFile(path).exists();
+}
+exports.existsSync = existsSync;
+
+var exists = Async(existsSync);
+exports.exists = exists;
+
+/**
+ * Synchronous ftruncate(2).
+ */
+function truncateSync(path, length) {
+ let fd = openSync(path, "w");
+ ftruncateSync(fd, length);
+ closeSync(fd);
+}
+exports.truncateSync = truncateSync;
+
+/**
+ * Asynchronous ftruncate(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+function truncate(path, length, callback) {
+ open(path, "w", function(error, fd) {
+ if (error) return callback(error);
+ ftruncate(fd, length, function(error) {
+ if (error) {
+ closeSync(fd);
+ callback(error);
+ }
+ else {
+ close(fd, callback);
+ }
+ });
+ });
+}
+exports.truncate = truncate;
+
+function ftruncate(fd, length, callback) {
+ write(fd, new Buffer(length), 0, length, 0, function(error) {
+ callback(error);
+ });
+}
+exports.ftruncate = ftruncate;
+
+function ftruncateSync(fd, length = 0) {
+ writeSync(fd, new Buffer(length), 0, length, 0);
+}
+exports.ftruncateSync = ftruncateSync;
+
+function chownSync(path, uid, gid) {
+ throw Error("Not implemented yet!!");
+}
+exports.chownSync = chownSync;
+
+var chown = Async(chownSync);
+exports.chown = chown;
+
+function lchownSync(path, uid, gid) {
+ throw Error("Not implemented yet!!");
+}
+exports.lchownSync = chownSync;
+
+var lchown = Async(lchown);
+exports.lchown = lchown;
+
+/**
+ * Synchronous chmod(2).
+ */
+function chmodSync (path, mode) {
+ let file;
+ try {
+ file = new nsILocalFile(path);
+ } catch(e) {
+ throw FSError("chmod", "ENOENT", 34, path);
+ }
+
+ file.permissions = Mode(mode);
+}
+exports.chmodSync = chmodSync;
+/**
+ * Asynchronous chmod(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+var chmod = Async(chmodSync);
+exports.chmod = chmod;
+
+/**
+ * Synchronous chmod(2).
+ */
+function fchmodSync(fd, mode) {
+ throw Error("Not implemented yet!!");
+};
+exports.fchmodSync = fchmodSync;
+/**
+ * Asynchronous chmod(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+var fchmod = Async(fchmodSync);
+exports.fchmod = fchmod;
+
+
+/**
+ * Synchronous stat(2). Returns an instance of `fs.Stats`
+ */
+function statSync(path) {
+ return new Stats(path);
+};
+exports.statSync = statSync;
+
+/**
+ * Asynchronous stat(2). The callback gets two arguments (err, stats) where
+ * stats is a `fs.Stats` object. It looks like this:
+ */
+var stat = Async(statSync);
+exports.stat = stat;
+
+/**
+ * Synchronous lstat(2). Returns an instance of `fs.Stats`.
+ */
+function lstatSync(path) {
+ return new LStats(path);
+};
+exports.lstatSync = lstatSync;
+
+/**
+ * Asynchronous lstat(2). The callback gets two arguments (err, stats) where
+ * stats is a fs.Stats object. lstat() is identical to stat(), except that if
+ * path is a symbolic link, then the link itself is stat-ed, not the file that
+ * it refers to.
+ */
+var lstat = Async(lstatSync);
+exports.lstat = lstat;
+
+/**
+ * Synchronous fstat(2). Returns an instance of `fs.Stats`.
+ */
+function fstatSync(fd) {
+ return new FStat(fd);
+};
+exports.fstatSync = fstatSync;
+
+/**
+ * Asynchronous fstat(2). The callback gets two arguments (err, stats) where
+ * stats is a fs.Stats object.
+ */
+var fstat = Async(fstatSync);
+exports.fstat = fstat;
+
+/**
+ * Synchronous link(2).
+ */
+function linkSync(source, target) {
+ throw Error("Not implemented yet!!");
+};
+exports.linkSync = linkSync;
+
+/**
+ * Asynchronous link(2). No arguments other than a possible exception are given
+ * to the completion callback.
+ */
+var link = Async(linkSync);
+exports.link = link;
+
+/**
+ * Synchronous symlink(2).
+ */
+function symlinkSync(source, target) {
+ throw Error("Not implemented yet!!");
+};
+exports.symlinkSync = symlinkSync;
+
+/**
+ * Asynchronous symlink(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+var symlink = Async(symlinkSync);
+exports.symlink = symlink;
+
+/**
+ * Synchronous readlink(2). Returns the resolved path.
+ */
+function readlinkSync(path) {
+ return new nsILocalFile(path).target;
+};
+exports.readlinkSync = readlinkSync;
+
+/**
+ * Asynchronous readlink(2). The callback gets two arguments
+ * `(error, resolvedPath)`.
+ */
+var readlink = Async(readlinkSync);
+exports.readlink = readlink;
+
+/**
+ * Synchronous realpath(2). Returns the resolved path.
+ */
+function realpathSync(path) {
+ return new nsILocalFile(path).path;
+};
+exports.realpathSync = realpathSync;
+
+/**
+ * Asynchronous realpath(2). The callback gets two arguments
+ * `(err, resolvedPath)`.
+ */
+var realpath = Async(realpathSync);
+exports.realpath = realpath;
+
+/**
+ * Synchronous unlink(2).
+ */
+var unlinkSync = remove;
+exports.unlinkSync = unlinkSync;
+
+/**
+ * Asynchronous unlink(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+var unlink = Async(remove);
+exports.unlink = unlink;
+
+/**
+ * Synchronous rmdir(2).
+ */
+var rmdirSync = remove;
+exports.rmdirSync = rmdirSync;
+
+/**
+ * Asynchronous rmdir(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+var rmdir = Async(rmdirSync);
+exports.rmdir = rmdir;
+
+/**
+ * Synchronous mkdir(2).
+ */
+function mkdirSync(path, mode) {
+ try {
+ return nsILocalFile(path).create(DIRECTORY_TYPE, Mode(mode));
+ } catch (error) {
+ // Adjust exception thorw to match ones thrown by node.
+ if (error.name === "NS_ERROR_FILE_ALREADY_EXISTS") {
+ let { fileName, lineNumber } = error;
+ error = FSError("mkdir", "EEXIST", 47, path, fileName, lineNumber);
+ }
+ throw error;
+ }
+};
+exports.mkdirSync = mkdirSync;
+
+/**
+ * Asynchronous mkdir(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+var mkdir = Async(mkdirSync);
+exports.mkdir = mkdir;
+
+/**
+ * Synchronous readdir(3). Returns an array of filenames excluding `"."` and
+ * `".."`.
+ */
+function readdirSync(path) {
+ try {
+ return toArray(new nsILocalFile(path).directoryEntries).map(getFileName);
+ }
+ catch (error) {
+ // Adjust exception thorw to match ones thrown by node.
+ if (error.name === "NS_ERROR_FILE_TARGET_DOES_NOT_EXIST" ||
+ error.name === "NS_ERROR_FILE_NOT_FOUND")
+ {
+ let { fileName, lineNumber } = error;
+ error = FSError("readdir", "ENOENT", 34, path, fileName, lineNumber);
+ }
+ throw error;
+ }
+};
+exports.readdirSync = readdirSync;
+
+/**
+ * Asynchronous readdir(3). Reads the contents of a directory. The callback
+ * gets two arguments `(error, files)` where `files` is an array of the names
+ * of the files in the directory excluding `"."` and `".."`.
+ */
+var readdir = Async(readdirSync);
+exports.readdir = readdir;
+
+/**
+ * Synchronous close(2).
+ */
+ function closeSync(fd) {
+ let input = nsIFileInputStream(fd);
+ let output = nsIFileOutputStream(fd);
+
+ // Closing input stream and removing reference.
+ if (input) input.close();
+ // Closing output stream and removing reference.
+ if (output) output.close();
+
+ nsIFile(fd, null);
+ nsIFileInputStream(fd, null);
+ nsIFileOutputStream(fd, null);
+ nsIBinaryInputStream(fd, null);
+ nsIBinaryOutputStream(fd, null);
+};
+exports.closeSync = closeSync;
+/**
+ * Asynchronous close(2). No arguments other than a possible exception are
+ * given to the completion callback.
+ */
+var close = Async(closeSync);
+exports.close = close;
+
+/**
+ * Synchronous open(2).
+ */
+function openSync(aPath, aFlag, aMode) {
+ let [ fd, flags, mode, file ] =
+ [ { path: aPath }, Flags(aFlag), Mode(aMode), nsILocalFile(aPath) ];
+
+ nsIFile(fd, file);
+
+ // If trying to open file for just read that does not exists
+ // need to throw exception as node does.
+ if (!file.exists() && !isWritable(flags))
+ throw FSError("open", "ENOENT", 34, aPath);
+
+ // If we want to open file in read mode we initialize input stream.
+ if (isReadable(flags)) {
+ let input = FileInputStream(file, flags, mode, DEFER_OPEN);
+ nsIFileInputStream(fd, input);
+ }
+
+ // If we want to open file in write mode we initialize output stream for it.
+ if (isWritable(flags)) {
+ let output = FileOutputStream(file, flags, mode, DEFER_OPEN);
+ nsIFileOutputStream(fd, output);
+ }
+
+ return fd;
+}
+exports.openSync = openSync;
+/**
+ * Asynchronous file open. See open(2). Flags can be
+ * `"r", "r+", "w", "w+", "a"`, or `"a+"`. mode defaults to `0666`.
+ * The callback gets two arguments `(error, fd).
+ */
+var open = Async(openSync);
+exports.open = open;
+
+/**
+ * Synchronous version of buffer-based fs.write(). Returns the number of bytes
+ * written.
+ */
+function writeSync(fd, buffer, offset, length, position) {
+ if (length + offset > buffer.length) {
+ throw Error("Length is extends beyond buffer");
+ }
+ else if (length + offset !== buffer.length) {
+ buffer = buffer.slice(offset, offset + length);
+ }
+
+ let output = BinaryOutputStream(nsIFileOutputStream(fd));
+ nsIBinaryOutputStream(fd, output);
+ // We write content as a byte array as this will avoid any transcoding
+ // if content was a buffer.
+ output.writeByteArray(buffer.valueOf(), buffer.length);
+ output.flush();
+};
+exports.writeSync = writeSync;
+
+/**
+ * Write buffer to the file specified by fd.
+ *
+ * `offset` and `length` determine the part of the buffer to be written.
+ *
+ * `position` refers to the offset from the beginning of the file where this
+ * data should be written. If `position` is `null`, the data will be written
+ * at the current position. See pwrite(2).
+ *
+ * The callback will be given three arguments `(error, written, buffer)` where
+ * written specifies how many bytes were written into buffer.
+ *
+ * Note that it is unsafe to use `fs.write` multiple times on the same file
+ * without waiting for the callback.
+ */
+function write(fd, buffer, offset, length, position, callback) {
+ if (!Buffer.isBuffer(buffer)) {
+ // (fd, data, position, encoding, callback)
+ let encoding = null;
+ [ position, encoding, callback ] = Array.slice(arguments, 1);
+ buffer = new Buffer(String(buffer), encoding);
+ offset = 0;
+ } else if (length + offset > buffer.length) {
+ throw Error("Length is extends beyond buffer");
+ } else if (length + offset !== buffer.length) {
+ buffer = buffer.slice(offset, offset + length);
+ }
+
+ let writeStream = new WriteStream(fd, { position: position,
+ length: length });
+ writeStream.on("error", callback);
+ writeStream.write(buffer, function onEnd() {
+ writeStream.destroy();
+ if (callback)
+ callback(null, buffer.length, buffer);
+ });
+};
+exports.write = write;
+
+/**
+ * Synchronous version of string-based fs.read. Returns the number of
+ * bytes read.
+ */
+function readSync(fd, buffer, offset, length, position) {
+ let input = nsIFileInputStream(fd);
+ // Setting a stream position, unless it"s `-1` which means current position.
+ if (position >= 0)
+ input.QueryInterface(Ci.nsISeekableStream).seek(NS_SEEK_SET, position);
+ // We use `nsIStreamTransportService` service to transform blocking
+ // file input stream into a fully asynchronous stream that can be written
+ // without blocking the main thread.
+ let binaryInputStream = BinaryInputStream(input);
+ let count = length === ALL ? binaryInputStream.available() : length;
+ if (offset === 0) binaryInputStream.readArrayBuffer(count, buffer.buffer);
+ else {
+ let chunk = new Buffer(count);
+ binaryInputStream.readArrayBuffer(count, chunk.buffer);
+ chunk.copy(buffer, offset);
+ }
+
+ return buffer.slice(offset, offset + count);
+};
+exports.readSync = readSync;
+
+/**
+ * Read data from the file specified by `fd`.
+ *
+ * `buffer` is the buffer that the data will be written to.
+ * `offset` is offset within the buffer where writing will start.
+ *
+ * `length` is an integer specifying the number of bytes to read.
+ *
+ * `position` is an integer specifying where to begin reading from in the file.
+ * If `position` is `null`, data will be read from the current file position.
+ *
+ * The callback is given the three arguments, `(error, bytesRead, buffer)`.
+ */
+function read(fd, buffer, offset, length, position, callback) {
+ let bytesRead = 0;
+ let readStream = new ReadStream(fd, { position: position, length: length });
+ readStream.on("data", function onData(data) {
+ data.copy(buffer, offset + bytesRead);
+ bytesRead += data.length;
+ });
+ readStream.on("end", function onEnd() {
+ callback(null, bytesRead, buffer);
+ readStream.destroy();
+ });
+};
+exports.read = read;
+
+/**
+ * Asynchronously reads the entire contents of a file.
+ * The callback is passed two arguments `(error, data)`, where data is the
+ * contents of the file.
+ */
+function readFile(path, encoding, callback) {
+ if (isFunction(encoding)) {
+ callback = encoding
+ encoding = null
+ }
+
+ let buffer = null;
+ try {
+ let readStream = new ReadStream(path);
+ readStream.on("data", function(data) {
+ if (!buffer) buffer = data;
+ else buffer = Buffer.concat([buffer, data], 2);
+ });
+ readStream.on("error", function onError(error) {
+ callback(error);
+ });
+ readStream.on("end", function onEnd() {
+ // Note: Need to destroy before invoking a callback
+ // so that file descriptor is released.
+ readStream.destroy();
+ callback(null, buffer);
+ });
+ }
+ catch (error) {
+ setTimeout(callback, 0, error);
+ }
+};
+exports.readFile = readFile;
+
+/**
+ * Synchronous version of `fs.readFile`. Returns the contents of the path.
+ * If encoding is specified then this function returns a string.
+ * Otherwise it returns a buffer.
+ */
+function readFileSync(path, encoding) {
+ let fd = openSync(path, "r");
+ let size = fstatSync(fd).size;
+ let buffer = new Buffer(size);
+ try {
+ readSync(fd, buffer, 0, ALL, 0);
+ }
+ finally {
+ closeSync(fd);
+ }
+ return buffer;
+};
+exports.readFileSync = readFileSync;
+
+/**
+ * Asynchronously writes data to a file, replacing the file if it already
+ * exists. data can be a string or a buffer.
+ */
+function writeFile(path, content, encoding, callback) {
+ if (!isString(path))
+ throw new TypeError('path must be a string');
+
+ try {
+ if (isFunction(encoding)) {
+ callback = encoding
+ encoding = null
+ }
+ if (isString(content))
+ content = new Buffer(content, encoding);
+
+ let writeStream = new WriteStream(path);
+ let error = null;
+
+ writeStream.end(content, function() {
+ writeStream.destroy();
+ callback(error);
+ });
+
+ writeStream.on("error", function onError(reason) {
+ error = reason;
+ writeStream.destroy();
+ });
+ } catch (error) {
+ callback(error);
+ }
+};
+exports.writeFile = writeFile;
+
+/**
+ * The synchronous version of `fs.writeFile`.
+ */
+function writeFileSync(filename, data, encoding) {
+ // TODO: Implement this in bug 1148209 https://bugzilla.mozilla.org/show_bug.cgi?id=1148209
+ throw Error("Not implemented");
+};
+exports.writeFileSync = writeFileSync;
+
+
+function utimesSync(path, atime, mtime) {
+ throw Error("Not implemented");
+}
+exports.utimesSync = utimesSync;
+
+var utimes = Async(utimesSync);
+exports.utimes = utimes;
+
+function futimesSync(fd, atime, mtime, callback) {
+ throw Error("Not implemented");
+}
+exports.futimesSync = futimesSync;
+
+var futimes = Async(futimesSync);
+exports.futimes = futimes;
+
+function fsyncSync(fd, atime, mtime, callback) {
+ throw Error("Not implemented");
+}
+exports.fsyncSync = fsyncSync;
+
+var fsync = Async(fsyncSync);
+exports.fsync = fsync;
+
+
+/**
+ * Watch for changes on filename. The callback listener will be called each
+ * time the file is accessed.
+ *
+ * The second argument is optional. The options if provided should be an object
+ * containing two members a boolean, persistent, and interval, a polling value
+ * in milliseconds. The default is { persistent: true, interval: 0 }.
+ */
+function watchFile(path, options, listener) {
+ throw Error("Not implemented");
+};
+exports.watchFile = watchFile;
+
+
+function unwatchFile(path, listener) {
+ throw Error("Not implemented");
+}
+exports.unwatchFile = unwatchFile;
+
+function watch(path, options, listener) {
+ throw Error("Not implemented");
+}
+exports.watch = watch;
diff --git a/toolkit/jetpack/sdk/io/stream.js b/toolkit/jetpack/sdk/io/stream.js
new file mode 100644
index 000000000..0698b8e32
--- /dev/null
+++ b/toolkit/jetpack/sdk/io/stream.js
@@ -0,0 +1,440 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { CC, Cc, Ci, Cu, Cr, components } = require("chrome");
+const { EventTarget } = require("../event/target");
+const { emit } = require("../event/core");
+const { Buffer } = require("./buffer");
+const { Class } = require("../core/heritage");
+const { setTimeout } = require("../timers");
+
+
+const MultiplexInputStream = CC("@mozilla.org/io/multiplex-input-stream;1",
+ "nsIMultiplexInputStream");
+const AsyncStreamCopier = CC("@mozilla.org/network/async-stream-copier;1",
+ "nsIAsyncStreamCopier", "init");
+const StringInputStream = CC("@mozilla.org/io/string-input-stream;1",
+ "nsIStringInputStream");
+const ArrayBufferInputStream = CC("@mozilla.org/io/arraybuffer-input-stream;1",
+ "nsIArrayBufferInputStream");
+
+const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
+ "nsIBinaryInputStream", "setInputStream");
+const InputStreamPump = CC("@mozilla.org/network/input-stream-pump;1",
+ "nsIInputStreamPump", "init");
+
+const threadManager = Cc["@mozilla.org/thread-manager;1"].
+ getService(Ci.nsIThreadManager);
+
+const eventTarget = Cc["@mozilla.org/network/stream-transport-service;1"].
+ getService(Ci.nsIEventTarget);
+
+var isFunction = value => typeof(value) === "function"
+
+function accessor() {
+ let map = new WeakMap();
+ return function(target, value) {
+ if (value)
+ map.set(target, value);
+ return map.get(target);
+ }
+}
+
+const Stream = Class({
+ extends: EventTarget,
+ initialize: function() {
+ this.readable = false;
+ this.writable = false;
+ this.encoding = null;
+ },
+ setEncoding: function setEncoding(encoding) {
+ this.encoding = String(encoding).toUpperCase();
+ },
+ pipe: function pipe(target, options) {
+ let source = this;
+ function onData(chunk) {
+ if (target.writable) {
+ if (false === target.write(chunk))
+ source.pause();
+ }
+ }
+ function onDrain() {
+ if (source.readable)
+ source.resume();
+ }
+ function onEnd() {
+ target.end();
+ }
+ function onPause() {
+ source.pause();
+ }
+ function onResume() {
+ if (source.readable)
+ source.resume();
+ }
+
+ function cleanup() {
+ source.removeListener("data", onData);
+ target.removeListener("drain", onDrain);
+ source.removeListener("end", onEnd);
+
+ target.removeListener("pause", onPause);
+ target.removeListener("resume", onResume);
+
+ source.removeListener("end", cleanup);
+ source.removeListener("close", cleanup);
+
+ target.removeListener("end", cleanup);
+ target.removeListener("close", cleanup);
+ }
+
+ if (!options || options.end !== false)
+ target.on("end", onEnd);
+
+ source.on("data", onData);
+ target.on("drain", onDrain);
+ target.on("resume", onResume);
+ target.on("pause", onPause);
+
+ source.on("end", cleanup);
+ source.on("close", cleanup);
+
+ target.on("end", cleanup);
+ target.on("close", cleanup);
+
+ emit(target, "pipe", source);
+ },
+ pause: function pause() {
+ emit(this, "pause");
+ },
+ resume: function resume() {
+ emit(this, "resume");
+ },
+ destroySoon: function destroySoon() {
+ this.destroy();
+ }
+});
+exports.Stream = Stream;
+
+
+var nsIStreamListener = accessor();
+var nsIInputStreamPump = accessor();
+var nsIAsyncInputStream = accessor();
+var nsIBinaryInputStream = accessor();
+
+const StreamListener = Class({
+ initialize: function(stream) {
+ this.stream = stream;
+ },
+
+ // Next three methods are part of `nsIStreamListener` interface and are
+ // invoked by `nsIInputStreamPump.asyncRead`.
+ onDataAvailable: function(request, context, input, offset, count) {
+ let stream = this.stream;
+ let buffer = new ArrayBuffer(count);
+ nsIBinaryInputStream(stream).readArrayBuffer(count, buffer);
+ emit(stream, "data", new Buffer(buffer));
+ },
+
+ // Next two methods implement `nsIRequestObserver` interface and are invoked
+ // by `nsIInputStreamPump.asyncRead`.
+ onStartRequest: function() {},
+ // Called to signify the end of an asynchronous request. We only care to
+ // discover errors.
+ onStopRequest: function(request, context, status) {
+ let stream = this.stream;
+ stream.readable = false;
+ if (!components.isSuccessCode(status))
+ emit(stream, "error", status);
+ else
+ emit(stream, "end");
+ }
+});
+
+
+const InputStream = Class({
+ extends: Stream,
+ readable: false,
+ paused: false,
+ initialize: function initialize(options) {
+ let { asyncInputStream } = options;
+
+ this.readable = true;
+
+ let binaryInputStream = new BinaryInputStream(asyncInputStream);
+ let inputStreamPump = new InputStreamPump(asyncInputStream,
+ -1, -1, 0, 0, false);
+ let streamListener = new StreamListener(this);
+
+ nsIAsyncInputStream(this, asyncInputStream);
+ nsIInputStreamPump(this, inputStreamPump);
+ nsIBinaryInputStream(this, binaryInputStream);
+ nsIStreamListener(this, streamListener);
+
+ this.asyncInputStream = asyncInputStream;
+ this.inputStreamPump = inputStreamPump;
+ this.binaryInputStream = binaryInputStream;
+ },
+ get status() {
+ return nsIInputStreamPump(this).status;
+ },
+ read: function() {
+ nsIInputStreamPump(this).asyncRead(nsIStreamListener(this), null);
+ },
+ pause: function pause() {
+ this.paused = true;
+ nsIInputStreamPump(this).suspend();
+ emit(this, "paused");
+ },
+ resume: function resume() {
+ this.paused = false;
+ if (nsIInputStreamPump(this).isPending()) {
+ nsIInputStreamPump(this).resume();
+ emit(this, "resume");
+ }
+ },
+ close: function close() {
+ this.readable = false;
+ nsIInputStreamPump(this).cancel(Cr.NS_OK);
+ nsIBinaryInputStream(this).close();
+ nsIAsyncInputStream(this).close();
+ },
+ destroy: function destroy() {
+ this.close();
+
+ nsIInputStreamPump(this);
+ nsIAsyncInputStream(this);
+ nsIBinaryInputStream(this);
+ nsIStreamListener(this);
+ }
+});
+exports.InputStream = InputStream;
+
+
+
+var nsIRequestObserver = accessor();
+var nsIAsyncOutputStream = accessor();
+var nsIAsyncStreamCopier = accessor();
+var nsIMultiplexInputStream = accessor();
+
+const RequestObserver = Class({
+ initialize: function(stream) {
+ this.stream = stream;
+ },
+ // Method is part of `nsIRequestObserver` interface that is
+ // invoked by `nsIAsyncStreamCopier.asyncCopy`.
+ onStartRequest: function() {},
+ // Method is part of `nsIRequestObserver` interface that is
+ // invoked by `nsIAsyncStreamCopier.asyncCopy`.
+ onStopRequest: function(request, context, status) {
+ let stream = this.stream;
+ stream.drained = true;
+
+ // Remove copied chunk.
+ let multiplexInputStream = nsIMultiplexInputStream(stream);
+ multiplexInputStream.removeStream(0);
+
+ // If there was an error report.
+ if (!components.isSuccessCode(status))
+ emit(stream, "error", status);
+
+ // If there more chunks in queue then flush them.
+ else if (multiplexInputStream.count)
+ stream.flush();
+
+ // If stream is still writable notify that queue has drained.
+ else if (stream.writable)
+ emit(stream, "drain");
+
+ // If stream is no longer writable close it.
+ else {
+ nsIAsyncStreamCopier(stream).cancel(Cr.NS_OK);
+ nsIMultiplexInputStream(stream).close();
+ nsIAsyncOutputStream(stream).close();
+ nsIAsyncOutputStream(stream).flush();
+ }
+ }
+});
+
+const OutputStreamCallback = Class({
+ initialize: function(stream) {
+ this.stream = stream;
+ },
+ // Method is part of `nsIOutputStreamCallback` interface that
+ // is invoked by `nsIAsyncOutputStream.asyncWait`. It is registered
+ // with `WAIT_CLOSURE_ONLY` flag that overrides the default behavior,
+ // causing the `onOutputStreamReady` notification to be suppressed until
+ // the stream becomes closed.
+ onOutputStreamReady: function(nsIAsyncOutputStream) {
+ emit(this.stream, "finish");
+ }
+});
+
+const OutputStream = Class({
+ extends: Stream,
+ writable: false,
+ drained: true,
+ get bufferSize() {
+ let multiplexInputStream = nsIMultiplexInputStream(this);
+ return multiplexInputStream && multiplexInputStream.available();
+ },
+ initialize: function initialize(options) {
+ let { asyncOutputStream, output } = options;
+ this.writable = true;
+
+ // Ensure that `nsIAsyncOutputStream` was provided.
+ asyncOutputStream.QueryInterface(Ci.nsIAsyncOutputStream);
+
+ // Create a `nsIMultiplexInputStream` and `nsIAsyncStreamCopier`. Former
+ // is used to queue written data chunks that `asyncStreamCopier` will
+ // asynchronously drain into `asyncOutputStream`.
+ let multiplexInputStream = MultiplexInputStream();
+ let asyncStreamCopier = AsyncStreamCopier(multiplexInputStream,
+ output || asyncOutputStream,
+ eventTarget,
+ // nsIMultiplexInputStream
+ // implemnts .readSegments()
+ true,
+ // nsIOutputStream may or
+ // may not implemnet
+ // .writeSegments().
+ false,
+ // Use default buffer size.
+ null,
+ // Should not close an input.
+ false,
+ // Should not close an output.
+ false);
+
+ // Create `requestObserver` implementing `nsIRequestObserver` interface
+ // in the constructor that's gonna be reused across several flushes.
+ let requestObserver = RequestObserver(this);
+
+
+ // Create observer that implements `nsIOutputStreamCallback` and register
+ // using `WAIT_CLOSURE_ONLY` flag. That way it will be notfied once
+ // `nsIAsyncOutputStream` is closed.
+ asyncOutputStream.asyncWait(OutputStreamCallback(this),
+ asyncOutputStream.WAIT_CLOSURE_ONLY,
+ 0,
+ threadManager.currentThread);
+
+ nsIRequestObserver(this, requestObserver);
+ nsIAsyncOutputStream(this, asyncOutputStream);
+ nsIMultiplexInputStream(this, multiplexInputStream);
+ nsIAsyncStreamCopier(this, asyncStreamCopier);
+
+ this.asyncOutputStream = asyncOutputStream;
+ this.multiplexInputStream = multiplexInputStream;
+ this.asyncStreamCopier = asyncStreamCopier;
+ },
+ write: function write(content, encoding, callback) {
+ if (isFunction(encoding)) {
+ callback = encoding;
+ encoding = callback;
+ }
+
+ // If stream is not writable we throw an error.
+ if (!this.writable) throw Error("stream is not writable");
+
+ let chunk = null;
+
+ // If content is not a buffer then we create one out of it.
+ if (Buffer.isBuffer(content)) {
+ chunk = new ArrayBufferInputStream();
+ chunk.setData(content.buffer, 0, content.length);
+ }
+ else {
+ chunk = new StringInputStream();
+ chunk.setData(content, content.length);
+ }
+
+ if (callback)
+ this.once("drain", callback);
+
+ // Queue up chunk to be copied to output sync.
+ nsIMultiplexInputStream(this).appendStream(chunk);
+ this.flush();
+
+ return this.drained;
+ },
+ flush: function() {
+ if (this.drained) {
+ this.drained = false;
+ nsIAsyncStreamCopier(this).asyncCopy(nsIRequestObserver(this), null);
+ }
+ },
+ end: function end(content, encoding, callback) {
+ if (isFunction(content)) {
+ callback = content
+ content = callback
+ }
+ if (isFunction(encoding)) {
+ callback = encoding
+ encoding = callback
+ }
+
+ // Setting a listener to "finish" event if passed.
+ if (isFunction(callback))
+ this.once("finish", callback);
+
+
+ if (content)
+ this.write(content, encoding);
+ this.writable = false;
+
+ // Close `asyncOutputStream` only if output has drained. If it's
+ // not drained than `asyncStreamCopier` is busy writing, so let
+ // it finish. Note that since `this.writable` is false copier will
+ // close `asyncOutputStream` once output drains.
+ if (this.drained)
+ nsIAsyncOutputStream(this).close();
+ },
+ destroy: function destroy() {
+ nsIAsyncOutputStream(this).close();
+ nsIAsyncOutputStream(this);
+ nsIMultiplexInputStream(this);
+ nsIAsyncStreamCopier(this);
+ nsIRequestObserver(this);
+ }
+});
+exports.OutputStream = OutputStream;
+
+const DuplexStream = Class({
+ extends: Stream,
+ implements: [InputStream, OutputStream],
+ allowHalfOpen: true,
+ initialize: function initialize(options) {
+ options = options || {};
+ let { readable, writable, allowHalfOpen } = options;
+
+ InputStream.prototype.initialize.call(this, options);
+ OutputStream.prototype.initialize.call(this, options);
+
+ if (readable === false)
+ this.readable = false;
+
+ if (writable === false)
+ this.writable = false;
+
+ if (allowHalfOpen === false)
+ this.allowHalfOpen = false;
+
+ // If in a half open state and it's disabled enforce end.
+ this.once("end", () => {
+ if (!this.allowHalfOpen && (!this.readable || !this.writable))
+ this.end();
+ });
+ },
+ destroy: function destroy(error) {
+ InputStream.prototype.destroy.call(this);
+ OutputStream.prototype.destroy.call(this);
+ }
+});
+exports.DuplexStream = DuplexStream;
diff --git a/toolkit/jetpack/sdk/io/text-streams.js b/toolkit/jetpack/sdk/io/text-streams.js
new file mode 100644
index 000000000..ed4ec4972
--- /dev/null
+++ b/toolkit/jetpack/sdk/io/text-streams.js
@@ -0,0 +1,235 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci, Cu, components } = require("chrome");
+const { ensure } = require("../system/unload");
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
+
+// NetUtil.asyncCopy() uses this buffer length, and since we call it, for best
+// performance we use it, too.
+const BUFFER_BYTE_LEN = 0x8000;
+const PR_UINT32_MAX = 0xffffffff;
+const DEFAULT_CHARSET = "UTF-8";
+
+
+/**
+ * An input stream that reads text from a backing stream using a given text
+ * encoding.
+ *
+ * @param inputStream
+ * The stream is backed by this nsIInputStream. It must already be
+ * opened.
+ * @param charset
+ * Text in inputStream is expected to be in this character encoding. If
+ * not given, "UTF-8" is assumed. See nsICharsetConverterManager.idl for
+ * documentation on how to determine other valid values for this.
+ */
+function TextReader(inputStream, charset) {
+ charset = checkCharset(charset);
+
+ let stream = Cc["@mozilla.org/intl/converter-input-stream;1"].
+ createInstance(Ci.nsIConverterInputStream);
+ stream.init(inputStream, charset, BUFFER_BYTE_LEN,
+ Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
+
+ let manager = new StreamManager(this, stream);
+
+ /**
+ * Reads a string from the stream. If the stream is closed, an exception is
+ * thrown.
+ *
+ * @param numChars
+ * The number of characters to read. If not given, the remainder of
+ * the stream is read.
+ * @return The string read. If the stream is already at EOS, returns the
+ * empty string.
+ */
+ this.read = function TextReader_read(numChars) {
+ manager.ensureOpened();
+
+ let readAll = false;
+ if (typeof(numChars) === "number")
+ numChars = Math.max(numChars, 0);
+ else
+ readAll = true;
+
+ let str = "";
+ let totalRead = 0;
+ let chunkRead = 1;
+
+ // Read in numChars or until EOS, whichever comes first. Note that the
+ // units here are characters, not bytes.
+ while (true) {
+ let chunk = {};
+ let toRead = readAll ?
+ PR_UINT32_MAX :
+ Math.min(numChars - totalRead, PR_UINT32_MAX);
+ if (toRead <= 0 || chunkRead <= 0)
+ break;
+
+ // The converter stream reads in at most BUFFER_BYTE_LEN bytes in a call
+ // to readString, enough to fill its byte buffer. chunkRead will be the
+ // number of characters encoded by the bytes in that buffer.
+ chunkRead = stream.readString(toRead, chunk);
+ str += chunk.value;
+ totalRead += chunkRead;
+ }
+
+ return str;
+ };
+}
+exports.TextReader = TextReader;
+
+/**
+ * A buffered output stream that writes text to a backing stream using a given
+ * text encoding.
+ *
+ * @param outputStream
+ * The stream is backed by this nsIOutputStream. It must already be
+ * opened.
+ * @param charset
+ * Text will be written to outputStream using this character encoding.
+ * If not given, "UTF-8" is assumed. See nsICharsetConverterManager.idl
+ * for documentation on how to determine other valid values for this.
+ */
+function TextWriter(outputStream, charset) {
+ charset = checkCharset(charset);
+
+ let stream = outputStream;
+
+ // Buffer outputStream if it's not already.
+ let ioUtils = Cc["@mozilla.org/io-util;1"].getService(Ci.nsIIOUtil);
+ if (!ioUtils.outputStreamIsBuffered(outputStream)) {
+ stream = Cc["@mozilla.org/network/buffered-output-stream;1"].
+ createInstance(Ci.nsIBufferedOutputStream);
+ stream.init(outputStream, BUFFER_BYTE_LEN);
+ }
+
+ // I'd like to use nsIConverterOutputStream. But NetUtil.asyncCopy(), which
+ // we use below in writeAsync(), naturally expects its sink to be an instance
+ // of nsIOutputStream, which nsIConverterOutputStream's only implementation is
+ // not. So we use uconv and manually convert all strings before writing to
+ // outputStream.
+ let uconv = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
+ createInstance(Ci.nsIScriptableUnicodeConverter);
+ uconv.charset = charset;
+
+ let manager = new StreamManager(this, stream);
+
+ /**
+ * Flushes the backing stream's buffer.
+ */
+ this.flush = function TextWriter_flush() {
+ manager.ensureOpened();
+ stream.flush();
+ };
+
+ /**
+ * Writes a string to the stream. If the stream is closed, an exception is
+ * thrown.
+ *
+ * @param str
+ * The string to write.
+ */
+ this.write = function TextWriter_write(str) {
+ manager.ensureOpened();
+ let istream = uconv.convertToInputStream(str);
+ let len = istream.available();
+ while (len > 0) {
+ stream.writeFrom(istream, len);
+ len = istream.available();
+ }
+ istream.close();
+ };
+
+ /**
+ * Writes a string on a background thread. After the write completes, the
+ * backing stream's buffer is flushed, and both the stream and the backing
+ * stream are closed, also on the background thread. If the stream is already
+ * closed, an exception is thrown immediately.
+ *
+ * @param str
+ * The string to write.
+ * @param callback
+ * An optional function. If given, it's called as callback(error) when
+ * the write completes. error is an Error object or undefined if there
+ * was no error. Inside callback, |this| is the stream object.
+ */
+ this.writeAsync = function TextWriter_writeAsync(str, callback) {
+ manager.ensureOpened();
+ let istream = uconv.convertToInputStream(str);
+ NetUtil.asyncCopy(istream, stream, (result) => {
+ let err = components.isSuccessCode(result) ? undefined :
+ new Error("An error occured while writing to the stream: " + result);
+ if (err)
+ console.error(err);
+
+ // asyncCopy() closes its output (and input) stream.
+ manager.opened = false;
+
+ if (typeof(callback) === "function") {
+ try {
+ callback.call(this, err);
+ }
+ catch (exc) {
+ console.exception(exc);
+ }
+ }
+ });
+ };
+}
+exports.TextWriter = TextWriter;
+
+// This manages the lifetime of stream, a TextReader or TextWriter. It defines
+// closed and close() on stream and registers an unload listener that closes
+// rawStream if it's still opened. It also provides ensureOpened(), which
+// throws an exception if the stream is closed.
+function StreamManager(stream, rawStream) {
+ this.rawStream = rawStream;
+ this.opened = true;
+
+ /**
+ * True iff the stream is closed.
+ */
+ stream.__defineGetter__("closed", () => !this.opened);
+
+ /**
+ * Closes both the stream and its backing stream. If the stream is already
+ * closed, an exception is thrown. For TextWriters, this first flushes the
+ * backing stream's buffer.
+ */
+ stream.close = () => {
+ this.ensureOpened();
+ this.unload();
+ };
+
+ ensure(this);
+}
+
+StreamManager.prototype = {
+ ensureOpened: function StreamManager_ensureOpened() {
+ if (!this.opened)
+ throw new Error("The stream is closed and cannot be used.");
+ },
+ unload: function StreamManager_unload() {
+ // TextWriter.writeAsync() causes rawStream to close and therefore sets
+ // opened to false, so check that we're still opened.
+ if (this.opened) {
+ // Calling close() on both an nsIUnicharInputStream and
+ // nsIBufferedOutputStream closes their backing streams. It also forces
+ // nsIOutputStreams to flush first.
+ this.rawStream.close();
+ this.opened = false;
+ }
+ }
+};
+
+function checkCharset(charset) {
+ return typeof(charset) === "string" ? charset : DEFAULT_CHARSET;
+}
diff --git a/toolkit/jetpack/sdk/keyboard/hotkeys.js b/toolkit/jetpack/sdk/keyboard/hotkeys.js
new file mode 100644
index 000000000..a179502b8
--- /dev/null
+++ b/toolkit/jetpack/sdk/keyboard/hotkeys.js
@@ -0,0 +1,110 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { observer: keyboardObserver } = require("./observer");
+const { getKeyForCode, normalize, isFunctionKey,
+ MODIFIERS } = require("./utils");
+
+/**
+ * Register a global `hotkey` that executes `listener` when the key combination
+ * in `hotkey` is pressed. If more then one `listener` is registered on the same
+ * key combination only last one will be executed.
+ *
+ * @param {string} hotkey
+ * Key combination in the format of 'modifier key'.
+ *
+ * Examples:
+ *
+ * "accel s"
+ * "meta shift i"
+ * "control alt d"
+ *
+ * Modifier keynames:
+ *
+ * - **shift**: The Shift key.
+ * - **alt**: The Alt key. On the Macintosh, this is the Option key. On
+ * Macintosh this can only be used in conjunction with another modifier,
+ * since `Alt+Letter` combinations are reserved for entering special
+ * characters in text.
+ * - **meta**: The Meta key. On the Macintosh, this is the Command key.
+ * - **control**: The Control key.
+ * - **accel**: The key used for keyboard shortcuts on the user's platform,
+ * which is Control on Windows and Linux, and Command on Mac. Usually, this
+ * would be the value you would use.
+ *
+ * @param {function} listener
+ * Function to execute when the `hotkey` is executed.
+ */
+exports.register = function register(hotkey, listener) {
+ hotkey = normalize(hotkey);
+ hotkeys[hotkey] = listener;
+};
+
+/**
+ * Unregister a global `hotkey`. If passed `listener` is not the one registered
+ * for the given `hotkey`, the call to this function will be ignored.
+ *
+ * @param {string} hotkey
+ * Key combination in the format of 'modifier key'.
+ * @param {function} listener
+ * Function that will be invoked when the `hotkey` is pressed.
+ */
+exports.unregister = function unregister(hotkey, listener) {
+ hotkey = normalize(hotkey);
+ if (hotkeys[hotkey] === listener)
+ delete hotkeys[hotkey];
+};
+
+/**
+ * Map of hotkeys and associated functions.
+ */
+const hotkeys = exports.hotkeys = {};
+
+keyboardObserver.on("keydown", function onKeypress(event, window) {
+ let key, modifiers = [];
+ let isChar = "isChar" in event && event.isChar;
+ let which = "which" in event ? event.which : null;
+ let keyCode = "keyCode" in event ? event.keyCode : null;
+
+ if ("shiftKey" in event && event.shiftKey)
+ modifiers.push("shift");
+ if ("altKey" in event && event.altKey)
+ modifiers.push("alt");
+ if ("ctrlKey" in event && event.ctrlKey)
+ modifiers.push("control");
+ if ("metaKey" in event && event.metaKey)
+ modifiers.push("meta");
+
+ // If it's not a printable character then we fall back to a human readable
+ // equivalent of one of the following constants.
+ // http://dxr.mozilla.org/mozilla-central/source/dom/interfaces/events/nsIDOMKeyEvent.idl
+ key = getKeyForCode(keyCode);
+
+ // If only non-function (f1 - f24) key or only modifiers are pressed we don't
+ // have a valid combination so we return immediately (Also, sometimes
+ // `keyCode` may be one for the modifier which means we do not have a
+ // modifier).
+ if (!key || (!isFunctionKey(key) && !modifiers.length) || key in MODIFIERS)
+ return;
+
+ let combination = normalize({ key: key, modifiers: modifiers });
+ let hotkey = hotkeys[combination];
+
+ if (hotkey) {
+ try {
+ hotkey();
+ } catch (exception) {
+ console.exception(exception);
+ } finally {
+ // Work around bug 582052 by preventing the (nonexistent) default action.
+ event.preventDefault();
+ }
+ }
+});
diff --git a/toolkit/jetpack/sdk/keyboard/observer.js b/toolkit/jetpack/sdk/keyboard/observer.js
new file mode 100644
index 000000000..b8e32b95c
--- /dev/null
+++ b/toolkit/jetpack/sdk/keyboard/observer.js
@@ -0,0 +1,58 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Class } = require("../core/heritage");
+const { EventTarget } = require("../event/target");
+const { emit } = require("../event/core");
+const { DOMEventAssembler } = require("../deprecated/events/assembler");
+const { browserWindowIterator } = require('../deprecated/window-utils');
+const { isBrowser } = require('../window/utils');
+const { observer: windowObserver } = require("../windows/observer");
+
+// Event emitter objects used to register listeners and emit events on them
+// when they occur.
+const Observer = Class({
+ implements: [DOMEventAssembler, EventTarget],
+ initialize() {
+ // Adding each opened window to a list of observed windows.
+ windowObserver.on("open", window => {
+ if (isBrowser(window))
+ this.observe(window);
+ });
+
+ // Removing each closed window form the list of observed windows.
+ windowObserver.on("close", window => {
+ if (isBrowser(window))
+ this.ignore(window);
+ });
+
+ // Making observer aware of already opened windows.
+ for (let window of browserWindowIterator()) {
+ this.observe(window);
+ }
+ },
+ /**
+ * Events that are supported and emitted by the module.
+ */
+ supportedEventsTypes: [ "keydown", "keyup", "keypress" ],
+ /**
+ * Function handles all the supported events on all the windows that are
+ * observed. Method is used to proxy events to the listeners registered on
+ * this event emitter.
+ * @param {Event} event
+ * Keyboard event being emitted.
+ */
+ handleEvent(event) {
+ emit(this, event.type, event, event.target.ownerDocument ? event.target.ownerDocument.defaultView
+ : undefined);
+ }
+});
+
+exports.observer = new Observer();
diff --git a/toolkit/jetpack/sdk/keyboard/utils.js b/toolkit/jetpack/sdk/keyboard/utils.js
new file mode 100644
index 000000000..1b7df4ce3
--- /dev/null
+++ b/toolkit/jetpack/sdk/keyboard/utils.js
@@ -0,0 +1,189 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci } = require("chrome");
+const runtime = require("../system/runtime");
+const { isString } = require("../lang/type");
+const array = require("../util/array");
+
+
+const SWP = "{{SEPARATOR}}";
+const SEPARATOR = "-"
+const INVALID_COMBINATION = "Hotkey key combination must contain one or more " +
+ "modifiers and only one key";
+
+// Map of modifier key mappings.
+const MODIFIERS = exports.MODIFIERS = {
+ 'accel': runtime.OS === "Darwin" ? 'meta' : 'control',
+ 'meta': 'meta',
+ 'control': 'control',
+ 'ctrl': 'control',
+ 'option': 'alt',
+ 'command': 'meta',
+ 'alt': 'alt',
+ 'shift': 'shift'
+};
+
+// Hash of key:code pairs for all the chars supported by `nsIDOMKeyEvent`.
+// This is just a copy of the `nsIDOMKeyEvent` hash with normalized names.
+// @See: http://dxr.mozilla.org/mozilla-central/source/dom/interfaces/events/nsIDOMKeyEvent.idl
+const CODES = exports.CODES = new function Codes() {
+ let nsIDOMKeyEvent = Ci.nsIDOMKeyEvent;
+ // Names that will be substituted with a shorter analogs.
+ let aliases = {
+ 'subtract': '-',
+ 'add': '+',
+ 'equals': '=',
+ 'slash': '/',
+ 'backslash': '\\',
+ 'openbracket': '[',
+ 'closebracket': ']',
+ 'quote': '\'',
+ 'backquote': '`',
+ 'period': '.',
+ 'semicolon': ';',
+ 'comma': ','
+ };
+
+ // Normalizing keys and copying values to `this` object.
+ Object.keys(nsIDOMKeyEvent).filter(function(key) {
+ // Filter out only key codes.
+ return key.indexOf('DOM_VK') === 0;
+ }).map(function(key) {
+ // Map to key:values
+ return [ key, nsIDOMKeyEvent[key] ];
+ }).map(function([key, value]) {
+ return [ key.replace('DOM_VK_', '').replace('_', '').toLowerCase(), value ];
+ }).forEach(function ([ key, value ]) {
+ this[aliases[key] || key] = value;
+ }, this);
+};
+
+// Inverted `CODES` hash of `code:key`.
+const KEYS = exports.KEYS = new function Keys() {
+ Object.keys(CODES).forEach(function(key) {
+ this[CODES[key]] = key;
+ }, this)
+}
+
+exports.getKeyForCode = function getKeyForCode(code) {
+ return (code in KEYS) && KEYS[code];
+};
+exports.getCodeForKey = function getCodeForKey(key) {
+ return (key in CODES) && CODES[key];
+};
+
+/**
+ * Utility function that takes string or JSON that defines a `hotkey` and
+ * returns normalized string version of it.
+ * @param {JSON|String} hotkey
+ * @param {String} [separator=" "]
+ * Optional string that represents separator used to concatenate keys in the
+ * given `hotkey`.
+ * @returns {String}
+ * @examples
+ *
+ * require("keyboard/hotkeys").normalize("b Shift accel");
+ * // 'control shift b' -> on windows & linux
+ * // 'meta shift b' -> on mac
+ * require("keyboard/hotkeys").normalize("alt-d-shift", "-");
+ * // 'alt shift d'
+ */
+var normalize = exports.normalize = function normalize(hotkey, separator) {
+ if (!isString(hotkey))
+ hotkey = toString(hotkey, separator);
+ return toString(toJSON(hotkey, separator), separator);
+};
+
+/*
+ * Utility function that splits a string of characters that defines a `hotkey`
+ * into modifier keys and the defining key.
+ * @param {String} hotkey
+ * @param {String} [separator=" "]
+ * Optional string that represents separator used to concatenate keys in the
+ * given `hotkey`.
+ * @returns {JSON}
+ * @examples
+ *
+ * require("keyboard/hotkeys").toJSON("accel shift b");
+ * // { key: 'b', modifiers: [ 'control', 'shift' ] } -> on windows & linux
+ * // { key: 'b', modifiers: [ 'meta', 'shift' ] } -> on mac
+ *
+ * require("keyboard/hotkeys").normalize("alt-d-shift", "-");
+ * // { key: 'd', modifiers: [ 'alt', 'shift' ] }
+ */
+var toJSON = exports.toJSON = function toJSON(hotkey, separator) {
+ separator = separator || SEPARATOR;
+ // Since default separator is `-`, combination may take form of `alt--`. To
+ // avoid misbehavior we replace `--` with `-{{SEPARATOR}}` where
+ // `{{SEPARATOR}}` can be swapped later.
+ hotkey = hotkey.toLowerCase().replace(separator + separator, separator + SWP);
+
+ let value = {};
+ let modifiers = [];
+ let keys = hotkey.split(separator);
+ keys.forEach(function(name) {
+ // If name is `SEPARATOR` than we swap it back.
+ if (name === SWP)
+ name = separator;
+ if (name in MODIFIERS) {
+ array.add(modifiers, MODIFIERS[name]);
+ } else {
+ if (!value.key)
+ value.key = name;
+ else
+ throw new TypeError(INVALID_COMBINATION);
+ }
+ });
+
+ if (!value.key)
+ throw new TypeError(INVALID_COMBINATION);
+
+ value.modifiers = modifiers.sort();
+ return value;
+};
+
+/**
+ * Utility function that takes object that defines a `hotkey` and returns
+ * string representation of it.
+ *
+ * _Please note that this function does not validates data neither it normalizes
+ * it, if you are unsure that data is well formed use `normalize` function
+ * instead.
+ *
+ * @param {JSON} hotkey
+ * @param {String} [separator=" "]
+ * Optional string that represents separator used to concatenate keys in the
+ * given `hotkey`.
+ * @returns {String}
+ * @examples
+ *
+ * require("keyboard/hotkeys").toString({
+ * key: 'b',
+ * modifiers: [ 'control', 'shift' ]
+ * }, '+');
+ * // 'control+shift+b
+ *
+ */
+var toString = exports.toString = function toString(hotkey, separator) {
+ let keys = hotkey.modifiers.slice();
+ keys.push(hotkey.key);
+ return keys.join(separator || SEPARATOR);
+};
+
+/**
+ * Utility function takes `key` name and returns `true` if it's function key
+ * (F1, ..., F24) and `false` if it's not.
+ */
+var isFunctionKey = exports.isFunctionKey = function isFunctionKey(key) {
+ var $
+ return key[0].toLowerCase() === 'f' &&
+ ($ = parseInt(key.substr(1)), 0 < $ && $ < 25);
+};
diff --git a/toolkit/jetpack/sdk/l10n.js b/toolkit/jetpack/sdk/l10n.js
new file mode 100644
index 000000000..db5a9d7b6
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n.js
@@ -0,0 +1,91 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const json = require("./l10n/json/core");
+const { get: getKey } = require("./l10n/core");
+const properties = require("./l10n/properties/core");
+const { getRulesForLocale } = require("./l10n/plural-rules");
+
+// Retrieve the plural mapping function
+var pluralMappingFunction = getRulesForLocale(json.language()) ||
+ getRulesForLocale("en");
+
+exports.get = function get(k) {
+ // For now, we only accept a "string" as first argument
+ // TODO: handle plural forms in gettext pattern
+ if (typeof k !== "string")
+ throw new Error("First argument of localization method should be a string");
+ let n = arguments[1];
+
+ // Get translation from big hashmap or default to hard coded string:
+ let localized = getKey(k, n) || k;
+
+ // # Simplest usecase:
+ // // String hard coded in source code:
+ // _("Hello world")
+ // // Identifier of a key stored in properties file
+ // _("helloString")
+ if (arguments.length <= 1)
+ return localized;
+
+ let args = Array.slice(arguments);
+ let placeholders = [null, ...args.slice(typeof(n) === "number" ? 2 : 1)];
+
+ if (typeof localized == "object" && "other" in localized) {
+ // # Plural form:
+ // // Strings hard coded in source code:
+ // _(["One download", "%d downloads"], 10);
+ // // Identifier of a key stored in properties file
+ // _("downloadNumber", 0);
+ let n = arguments[1];
+
+ // First handle simple universal forms that may not be mandatory
+ // for each language, (i.e. not different than 'other' form,
+ // but still usefull for better phrasing)
+ // For example 0 in english is the same form than 'other'
+ // but we accept 'zero' form if specified in localization file
+ if (n === 0 && "zero" in localized)
+ localized = localized["zero"];
+ else if (n === 1 && "one" in localized)
+ localized = localized["one"];
+ else if (n === 2 && "two" in localized)
+ localized = localized["two"];
+ else {
+ let pluralForm = pluralMappingFunction(n);
+ if (pluralForm in localized)
+ localized = localized[pluralForm];
+ else // Fallback in case of error: missing plural form
+ localized = localized["other"];
+ }
+
+ // Simulate a string with one placeholder:
+ args = [null, n];
+ }
+
+ // # String with placeholders:
+ // // Strings hard coded in source code:
+ // _("Hello %s", username)
+ // // Identifier of a key stored in properties file
+ // _("helloString", username)
+ // * We supports `%1s`, `%2s`, ... pattern in order to change arguments order
+ // in translation.
+ // * In case of plural form, we has `%d` instead of `%s`.
+ let offset = 1;
+ if (placeholders.length > 1) {
+ args = placeholders;
+ }
+
+ localized = localized.replace(/%(\d*)[sd]/g, (v, n) => {
+ let rv = args[n != "" ? n : offset];
+ offset++;
+ return rv;
+ });
+
+ return localized;
+}
diff --git a/toolkit/jetpack/sdk/l10n/core.js b/toolkit/jetpack/sdk/l10n/core.js
new file mode 100644
index 000000000..2f8f84c04
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n/core.js
@@ -0,0 +1,9 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const json = require("./json/core");
+const properties = require("./properties/core");
+
+exports.get = json.usingJSON ? json.get : properties.get;
diff --git a/toolkit/jetpack/sdk/l10n/html.js b/toolkit/jetpack/sdk/l10n/html.js
new file mode 100644
index 000000000..fa2cf9cf0
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n/html.js
@@ -0,0 +1,32 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { processes, remoteRequire } = require("../remote/parent");
+remoteRequire("sdk/content/l10n-html");
+
+var enabled = false;
+function enable() {
+ if (!enabled) {
+ processes.port.emit("sdk/l10n/html/enable");
+ enabled = true;
+ }
+}
+exports.enable = enable;
+
+function disable() {
+ if (enabled) {
+ processes.port.emit("sdk/l10n/html/disable");
+ enabled = false;
+ }
+}
+exports.disable = disable;
+
+processes.forEvery(process => {
+ process.port.emit(enabled ? "sdk/l10n/html/enable" : "sdk/l10n/html/disable");
+});
diff --git a/toolkit/jetpack/sdk/l10n/json/core.js b/toolkit/jetpack/sdk/l10n/json/core.js
new file mode 100644
index 000000000..af52f956f
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n/json/core.js
@@ -0,0 +1,36 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ "use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+var usingJSON = false;
+var hash = {}, bestMatchingLocale = null;
+try {
+ let data = require("@l10n/data");
+ hash = data.hash;
+ bestMatchingLocale = data.bestMatchingLocale;
+ usingJSON = true;
+}
+catch(e) {}
+
+exports.usingJSON = usingJSON;
+
+// Returns the translation for a given key, if available.
+exports.get = function get(k) {
+ return k in hash ? hash[k] : null;
+}
+
+// Returns the full length locale code: ja-JP-mac, en-US or fr
+exports.locale = function locale() {
+ return bestMatchingLocale;
+}
+
+// Returns the short locale code: ja, en, fr
+exports.language = function language() {
+ return bestMatchingLocale ? bestMatchingLocale.split("-")[0].toLowerCase()
+ : "en";
+}
diff --git a/toolkit/jetpack/sdk/l10n/loader.js b/toolkit/jetpack/sdk/l10n/loader.js
new file mode 100644
index 000000000..60e219e44
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n/loader.js
@@ -0,0 +1,70 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci } = require("chrome");
+const { getPreferedLocales, findClosestLocale } = require("./locale");
+const { readURI } = require("../net/url");
+const { resolve } = require("../core/promise");
+
+function parseJsonURI(uri) {
+ return readURI(uri).
+ then(JSON.parse).
+ then(null, function (error) {
+ throw Error("Failed to parse locale file:\n" + uri + "\n" + error);
+ });
+}
+
+// Returns the array stored in `locales.json` manifest that list available
+// locales files
+function getAvailableLocales(rootURI) {
+ let uri = rootURI + "locales.json";
+ return parseJsonURI(uri).then(function (manifest) {
+ return "locales" in manifest &&
+ Array.isArray(manifest.locales) ?
+ manifest.locales : [];
+ });
+}
+
+// Returns URI of the best locales file to use from the XPI
+function getBestLocale(rootURI) {
+ // Read localization manifest file that contains list of available languages
+ return getAvailableLocales(rootURI).then(function (availableLocales) {
+ // Retrieve list of prefered locales to use
+ let preferedLocales = getPreferedLocales();
+
+ // Compute the most preferable locale to use by using these two lists
+ return findClosestLocale(availableLocales, preferedLocales);
+ });
+}
+
+/**
+ * Read localization files and returns a promise of data to put in `@l10n/data`
+ * pseudo module, in order to allow l10n/json/core to fetch it.
+ */
+exports.load = function load(rootURI) {
+ // First, search for a locale file:
+ return getBestLocale(rootURI).then(function (bestMatchingLocale) {
+ // It may be null if the addon doesn't have any locale file
+ if (!bestMatchingLocale)
+ return resolve(null);
+
+ let localeURI = rootURI + "locale/" + bestMatchingLocale + ".json";
+
+ // Locale files only contains one big JSON object that is used as
+ // an hashtable of: "key to translate" => "translated key"
+ // TODO: We are likely to change this in order to be able to overload
+ // a specific key translation. For a specific package, module or line?
+ return parseJsonURI(localeURI).then(function (json) {
+ return {
+ hash: json,
+ bestMatchingLocale: bestMatchingLocale
+ };
+ });
+ });
+}
diff --git a/toolkit/jetpack/sdk/l10n/locale.js b/toolkit/jetpack/sdk/l10n/locale.js
new file mode 100644
index 000000000..950b33b20
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n/locale.js
@@ -0,0 +1,127 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const prefs = require("../preferences/service");
+const { Cu, Cc, Ci } = require("chrome");
+const { Services } = Cu.import("resource://gre/modules/Services.jsm");
+
+/**
+ * Gets the currently selected locale for display.
+ * Gets all usable locale that we can use sorted by priority of relevance
+ * @return Array of locales, begins with highest priority
+ */
+const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
+const PREF_SELECTED_LOCALE = "general.useragent.locale";
+const PREF_ACCEPT_LANGUAGES = "intl.accept_languages";
+
+function getPreferedLocales(caseSensitve) {
+ let locales = [];
+ function addLocale(locale) {
+ locale = locale.trim();
+ if (!caseSensitve)
+ locale = locale.toLowerCase();
+ if (locales.indexOf(locale) === -1)
+ locales.push(locale);
+ }
+
+ // Most important locale is OS one. But we use it, only if
+ // "intl.locale.matchOS" pref is set to `true`.
+ // Currently only used for multi-locales mobile builds.
+ // http://mxr.mozilla.org/mozilla-central/source/mobile/android/installer/Makefile.in#46
+ if (prefs.get(PREF_MATCH_OS_LOCALE, false)) {
+ let localeService = Cc["@mozilla.org/intl/nslocaleservice;1"].
+ getService(Ci.nsILocaleService);
+ let osLocale = localeService.getLocaleComponentForUserAgent();
+ addLocale(osLocale);
+ }
+
+ // In some cases, mainly on Fennec and on Linux version,
+ // `general.useragent.locale` is a special 'localized' value, like:
+ // "chrome://global/locale/intl.properties"
+ let browserUiLocale = prefs.getLocalized(PREF_SELECTED_LOCALE, "") ||
+ prefs.get(PREF_SELECTED_LOCALE, "");
+ if (browserUiLocale)
+ addLocale(browserUiLocale);
+
+ // Third priority is the list of locales used for web content
+ let contentLocales = prefs.getLocalized(PREF_ACCEPT_LANGUAGES, "") ||
+ prefs.get(PREF_ACCEPT_LANGUAGES, "");
+ if (contentLocales) {
+ // This list is a string of locales seperated by commas.
+ // There is spaces after commas, so strip each item
+ for (let locale of contentLocales.split(","))
+ addLocale(locale.replace(/(^\s+)|(\s+$)/g, ""));
+ }
+
+ // Finally, we ensure that en-US is the final fallback if it wasn't added
+ addLocale("en-US");
+
+ return locales;
+}
+exports.getPreferedLocales = getPreferedLocales;
+
+/**
+ * Selects the closest matching locale from a list of locales.
+ *
+ * @param aLocales
+ * An array of available locales
+ * @param aMatchLocales
+ * An array of prefered locales, ordered by priority. Most wanted first.
+ * Locales have to be in lowercase.
+ * If null, uses getPreferedLocales() results
+ * @return the best match for the currently selected locale
+ *
+ * Stolen from http://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+ */
+exports.findClosestLocale = function findClosestLocale(aLocales, aMatchLocales) {
+ aMatchLocales = aMatchLocales || getPreferedLocales();
+
+ // Holds the best matching localized resource
+ let bestmatch = null;
+ // The number of locale parts it matched with
+ let bestmatchcount = 0;
+ // The number of locale parts in the match
+ let bestpartcount = 0;
+
+ for (let locale of aMatchLocales) {
+ let lparts = locale.split("-");
+ for (let localized of aLocales) {
+ let found = localized.toLowerCase();
+ // Exact match is returned immediately
+ if (locale == found)
+ return localized;
+
+ let fparts = found.split("-");
+ /* If we have found a possible match and this one isn't any longer
+ then we dont need to check further. */
+ if (bestmatch && fparts.length < bestmatchcount)
+ continue;
+
+ // Count the number of parts that match
+ let maxmatchcount = Math.min(fparts.length, lparts.length);
+ let matchcount = 0;
+ while (matchcount < maxmatchcount &&
+ fparts[matchcount] == lparts[matchcount])
+ matchcount++;
+
+ /* If we matched more than the last best match or matched the same and
+ this locale is less specific than the last best match. */
+ if (matchcount > bestmatchcount ||
+ (matchcount == bestmatchcount && fparts.length < bestpartcount)) {
+ bestmatch = localized;
+ bestmatchcount = matchcount;
+ bestpartcount = fparts.length;
+ }
+ }
+ // If we found a valid match for this locale return it
+ if (bestmatch)
+ return bestmatch;
+ }
+ return null;
+}
diff --git a/toolkit/jetpack/sdk/l10n/plural-rules.js b/toolkit/jetpack/sdk/l10n/plural-rules.js
new file mode 100644
index 000000000..a3ef48a5e
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n/plural-rules.js
@@ -0,0 +1,407 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// This file is automatically generated with /python-lib/plural-rules-generator.py
+// Fetching data from: http://unicode.org/repos/cldr/trunk/common/supplemental/plurals.xml
+
+// Mapping of short locale name == to == > rule index in following list
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const LOCALES_TO_RULES = {
+ "af": 3,
+ "ak": 4,
+ "am": 4,
+ "ar": 1,
+ "asa": 3,
+ "az": 0,
+ "be": 11,
+ "bem": 3,
+ "bez": 3,
+ "bg": 3,
+ "bh": 4,
+ "bm": 0,
+ "bn": 3,
+ "bo": 0,
+ "br": 20,
+ "brx": 3,
+ "bs": 11,
+ "ca": 3,
+ "cgg": 3,
+ "chr": 3,
+ "cs": 12,
+ "cy": 17,
+ "da": 3,
+ "de": 3,
+ "dv": 3,
+ "dz": 0,
+ "ee": 3,
+ "el": 3,
+ "en": 3,
+ "eo": 3,
+ "es": 3,
+ "et": 3,
+ "eu": 3,
+ "fa": 0,
+ "ff": 5,
+ "fi": 3,
+ "fil": 4,
+ "fo": 3,
+ "fr": 5,
+ "fur": 3,
+ "fy": 3,
+ "ga": 8,
+ "gd": 24,
+ "gl": 3,
+ "gsw": 3,
+ "gu": 3,
+ "guw": 4,
+ "gv": 23,
+ "ha": 3,
+ "haw": 3,
+ "he": 2,
+ "hi": 4,
+ "hr": 11,
+ "hu": 0,
+ "id": 0,
+ "ig": 0,
+ "ii": 0,
+ "is": 3,
+ "it": 3,
+ "iu": 7,
+ "ja": 0,
+ "jmc": 3,
+ "jv": 0,
+ "ka": 0,
+ "kab": 5,
+ "kaj": 3,
+ "kcg": 3,
+ "kde": 0,
+ "kea": 0,
+ "kk": 3,
+ "kl": 3,
+ "km": 0,
+ "kn": 0,
+ "ko": 0,
+ "ksb": 3,
+ "ksh": 21,
+ "ku": 3,
+ "kw": 7,
+ "lag": 18,
+ "lb": 3,
+ "lg": 3,
+ "ln": 4,
+ "lo": 0,
+ "lt": 10,
+ "lv": 6,
+ "mas": 3,
+ "mg": 4,
+ "mk": 16,
+ "ml": 3,
+ "mn": 3,
+ "mo": 9,
+ "mr": 3,
+ "ms": 0,
+ "mt": 15,
+ "my": 0,
+ "nah": 3,
+ "naq": 7,
+ "nb": 3,
+ "nd": 3,
+ "ne": 3,
+ "nl": 3,
+ "nn": 3,
+ "no": 3,
+ "nr": 3,
+ "nso": 4,
+ "ny": 3,
+ "nyn": 3,
+ "om": 3,
+ "or": 3,
+ "pa": 3,
+ "pap": 3,
+ "pl": 13,
+ "ps": 3,
+ "pt": 3,
+ "rm": 3,
+ "ro": 9,
+ "rof": 3,
+ "ru": 11,
+ "rwk": 3,
+ "sah": 0,
+ "saq": 3,
+ "se": 7,
+ "seh": 3,
+ "ses": 0,
+ "sg": 0,
+ "sh": 11,
+ "shi": 19,
+ "sk": 12,
+ "sl": 14,
+ "sma": 7,
+ "smi": 7,
+ "smj": 7,
+ "smn": 7,
+ "sms": 7,
+ "sn": 3,
+ "so": 3,
+ "sq": 3,
+ "sr": 11,
+ "ss": 3,
+ "ssy": 3,
+ "st": 3,
+ "sv": 3,
+ "sw": 3,
+ "syr": 3,
+ "ta": 3,
+ "te": 3,
+ "teo": 3,
+ "th": 0,
+ "ti": 4,
+ "tig": 3,
+ "tk": 3,
+ "tl": 4,
+ "tn": 3,
+ "to": 0,
+ "tr": 0,
+ "ts": 3,
+ "tzm": 22,
+ "uk": 11,
+ "ur": 3,
+ "ve": 3,
+ "vi": 0,
+ "vun": 3,
+ "wa": 4,
+ "wae": 3,
+ "wo": 0,
+ "xh": 3,
+ "xog": 3,
+ "yo": 0,
+ "zh": 0,
+ "zu": 3
+};
+
+// Utility functions for plural rules methods
+function isIn(n, list) {
+ return list.indexOf(n) !== -1;
+}
+function isBetween(n, start, end) {
+ return start <= n && n <= end;
+}
+
+// List of all plural rules methods, that maps an integer to the plural form name to use
+const RULES = {
+ "0": function (n) {
+
+ return "other"
+ },
+ "1": function (n) {
+ if ((isBetween((n % 100), 3, 10)))
+ return "few";
+ if (n == 0)
+ return "zero";
+ if ((isBetween((n % 100), 11, 99)))
+ return "many";
+ if (n == 2)
+ return "two";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "2": function (n) {
+ if (n != 0 && (n % 10) == 0)
+ return "many";
+ if (n == 2)
+ return "two";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "3": function (n) {
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "4": function (n) {
+ if ((isBetween(n, 0, 1)))
+ return "one";
+ return "other"
+ },
+ "5": function (n) {
+ if ((isBetween(n, 0, 2)) && n != 2)
+ return "one";
+ return "other"
+ },
+ "6": function (n) {
+ if (n == 0)
+ return "zero";
+ if ((n % 10) == 1 && (n % 100) != 11)
+ return "one";
+ return "other"
+ },
+ "7": function (n) {
+ if (n == 2)
+ return "two";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "8": function (n) {
+ if ((isBetween(n, 3, 6)))
+ return "few";
+ if ((isBetween(n, 7, 10)))
+ return "many";
+ if (n == 2)
+ return "two";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "9": function (n) {
+ if (n == 0 || n != 1 && (isBetween((n % 100), 1, 19)))
+ return "few";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "10": function (n) {
+ if ((isBetween((n % 10), 2, 9)) && !(isBetween((n % 100), 11, 19)))
+ return "few";
+ if ((n % 10) == 1 && !(isBetween((n % 100), 11, 19)))
+ return "one";
+ return "other"
+ },
+ "11": function (n) {
+ if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14)))
+ return "few";
+ if ((n % 10) == 0 || (isBetween((n % 10), 5, 9)) || (isBetween((n % 100), 11, 14)))
+ return "many";
+ if ((n % 10) == 1 && (n % 100) != 11)
+ return "one";
+ return "other"
+ },
+ "12": function (n) {
+ if ((isBetween(n, 2, 4)))
+ return "few";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "13": function (n) {
+ if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14)))
+ return "few";
+ if (n != 1 && (isBetween((n % 10), 0, 1)) || (isBetween((n % 10), 5, 9)) || (isBetween((n % 100), 12, 14)))
+ return "many";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "14": function (n) {
+ if ((isBetween((n % 100), 3, 4)))
+ return "few";
+ if ((n % 100) == 2)
+ return "two";
+ if ((n % 100) == 1)
+ return "one";
+ return "other"
+ },
+ "15": function (n) {
+ if (n == 0 || (isBetween((n % 100), 2, 10)))
+ return "few";
+ if ((isBetween((n % 100), 11, 19)))
+ return "many";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "16": function (n) {
+ if ((n % 10) == 1 && n != 11)
+ return "one";
+ return "other"
+ },
+ "17": function (n) {
+ if (n == 3)
+ return "few";
+ if (n == 0)
+ return "zero";
+ if (n == 6)
+ return "many";
+ if (n == 2)
+ return "two";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "18": function (n) {
+ if (n == 0)
+ return "zero";
+ if ((isBetween(n, 0, 2)) && n != 0 && n != 2)
+ return "one";
+ return "other"
+ },
+ "19": function (n) {
+ if ((isBetween(n, 2, 10)))
+ return "few";
+ if ((isBetween(n, 0, 1)))
+ return "one";
+ return "other"
+ },
+ "20": function (n) {
+ if ((isBetween((n % 10), 3, 4) || ((n % 10) == 9)) && !(isBetween((n % 100), 10, 19) || isBetween((n % 100), 70, 79) || isBetween((n % 100), 90, 99)))
+ return "few";
+ if ((n % 1000000) == 0 && n != 0)
+ return "many";
+ if ((n % 10) == 2 && !isIn((n % 100), [12, 72, 92]))
+ return "two";
+ if ((n % 10) == 1 && !isIn((n % 100), [11, 71, 91]))
+ return "one";
+ return "other"
+ },
+ "21": function (n) {
+ if (n == 0)
+ return "zero";
+ if (n == 1)
+ return "one";
+ return "other"
+ },
+ "22": function (n) {
+ if ((isBetween(n, 0, 1)) || (isBetween(n, 11, 99)))
+ return "one";
+ return "other"
+ },
+ "23": function (n) {
+ if ((isBetween((n % 10), 1, 2)) || (n % 20) == 0)
+ return "one";
+ return "other"
+ },
+ "24": function (n) {
+ if ((isBetween(n, 3, 10) || isBetween(n, 13, 19)))
+ return "few";
+ if (isIn(n, [2, 12]))
+ return "two";
+ if (isIn(n, [1, 11]))
+ return "one";
+ return "other"
+ },
+};
+
+/**
+ * Return a function that gives the plural form name for a given integer
+ * for the specified `locale`
+ * let fun = getRulesForLocale('en');
+ * fun(1) -> 'one'
+ * fun(0) -> 'other'
+ * fun(1000) -> 'other'
+ */
+exports.getRulesForLocale = function getRulesForLocale(locale) {
+ let index = LOCALES_TO_RULES[locale];
+ if (!(index in RULES)) {
+ console.warn('Plural form unknown for locale "' + locale + '"');
+ return function () { return "other"; };
+ }
+ return RULES[index];
+}
+
diff --git a/toolkit/jetpack/sdk/l10n/prefs.js b/toolkit/jetpack/sdk/l10n/prefs.js
new file mode 100644
index 000000000..8ee26fc5b
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n/prefs.js
@@ -0,0 +1,51 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { on } = require("../system/events");
+const core = require("./core");
+const { id: jetpackId } = require('../self');
+
+const OPTIONS_DISPLAYED = "addon-options-displayed";
+
+function enable() {
+ on(OPTIONS_DISPLAYED, onOptionsDisplayed);
+}
+exports.enable = enable;
+
+function onOptionsDisplayed({ subject: document, data: addonId }) {
+ if (addonId !== jetpackId)
+ return;
+ localizeInlineOptions(document);
+}
+
+function localizeInlineOptions(document) {
+ let query = 'setting[data-jetpack-id="' + jetpackId + '"][pref-name], ' +
+ 'button[data-jetpack-id="' + jetpackId + '"][pref-name]';
+ let nodes = document.querySelectorAll(query);
+ for (let node of nodes) {
+ let name = node.getAttribute("pref-name");
+ if (node.tagName == "setting") {
+ let desc = core.get(name + "_description");
+ if (desc)
+ node.setAttribute("desc", desc);
+ let title = core.get(name + "_title");
+ if (title)
+ node.setAttribute("title", title);
+
+ for (let item of node.querySelectorAll("menuitem, radio")) {
+ let key = name + "_options." + item.getAttribute("label");
+ let label = core.get(key);
+ if (label)
+ item.setAttribute("label", label);
+ }
+ }
+ else if (node.tagName == "button") {
+ let label = core.get(name + "_label");
+ if (label)
+ node.setAttribute("label", label);
+ }
+ }
+}
+exports.localizeInlineOptions = localizeInlineOptions;
diff --git a/toolkit/jetpack/sdk/l10n/properties/core.js b/toolkit/jetpack/sdk/l10n/properties/core.js
new file mode 100644
index 000000000..7a9081d0b
--- /dev/null
+++ b/toolkit/jetpack/sdk/l10n/properties/core.js
@@ -0,0 +1,87 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Cu } = require("chrome");
+const { newURI } = require('../../url/utils')
+const { getRulesForLocale } = require("../plural-rules");
+const { getPreferedLocales } = require('../locale');
+const { rootURI } = require("@loader/options");
+const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+
+const baseURI = rootURI + "locale/";
+const preferedLocales = getPreferedLocales(true);
+
+// Make sure we don't get stale data after an update
+// (See Bug 1300735 for rationale).
+Services.strings.flushBundles();
+
+function getLocaleURL(locale) {
+ // if the locale is a valid chrome URI, return it
+ try {
+ let uri = newURI(locale);
+ if (uri.scheme == 'chrome')
+ return uri.spec;
+ }
+ catch(_) {}
+ // otherwise try to construct the url
+ return baseURI + locale + ".properties";
+}
+
+function getKey(locale, key) {
+ let bundle = Services.strings.createBundle(getLocaleURL(locale));
+ try {
+ return bundle.GetStringFromName(key) + "";
+ }
+ catch (_) {}
+ return undefined;
+}
+
+function get(key, n, locales) {
+ // try this locale
+ let locale = locales.shift();
+ let localized;
+
+ if (typeof n == 'number') {
+ if (n == 0) {
+ localized = getKey(locale, key + '[zero]');
+ }
+ else if (n == 1) {
+ localized = getKey(locale, key + '[one]');
+ }
+ else if (n == 2) {
+ localized = getKey(locale, key + '[two]');
+ }
+
+ if (!localized) {
+ // Retrieve the plural mapping function
+ let pluralForm = (getRulesForLocale(locale.split("-")[0].toLowerCase()) ||
+ getRulesForLocale("en"))(n);
+ localized = getKey(locale, key + '[' + pluralForm + ']');
+ }
+
+ if (!localized) {
+ localized = getKey(locale, key + '[other]');
+ }
+ }
+
+ if (!localized) {
+ localized = getKey(locale, key);
+ }
+
+ if (!localized) {
+ localized = getKey(locale, key + '[other]');
+ }
+
+ if (localized) {
+ return localized;
+ }
+
+ // try next locale
+ if (locales.length)
+ return get(key, n, locales);
+
+ return undefined;
+}
+exports.get = (k, n) => get(k, n, Array.slice(preferedLocales));
diff --git a/toolkit/jetpack/sdk/lang/functional.js b/toolkit/jetpack/sdk/lang/functional.js
new file mode 100644
index 000000000..66e30edfa
--- /dev/null
+++ b/toolkit/jetpack/sdk/lang/functional.js
@@ -0,0 +1,47 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Disclaimer: Some of the functions in this module implement APIs from
+// Jeremy Ashkenas's http://underscorejs.org/ library and all credits for
+// those goes to him.
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { defer, remit, delay, debounce,
+ throttle } = require("./functional/concurrent");
+const { method, invoke, partial, curry, compose, wrap, identity, memoize, once,
+ cache, complement, constant, when, apply, flip, field, query,
+ isInstance, chainable, is, isnt } = require("./functional/core");
+
+exports.defer = defer;
+exports.remit = remit;
+exports.delay = delay;
+exports.debounce = debounce;
+exports.throttle = throttle;
+
+exports.method = method;
+exports.invoke = invoke;
+exports.partial = partial;
+exports.curry = curry;
+exports.compose = compose;
+exports.wrap = wrap;
+exports.identity = identity;
+exports.memoize = memoize;
+exports.once = once;
+exports.cache = cache;
+exports.complement = complement;
+exports.constant = constant;
+exports.when = when;
+exports.apply = apply;
+exports.flip = flip;
+exports.field = field;
+exports.query = query;
+exports.isInstance = isInstance;
+exports.chainable = chainable;
+exports.is = is;
+exports.isnt = isnt;
diff --git a/toolkit/jetpack/sdk/lang/functional/concurrent.js b/toolkit/jetpack/sdk/lang/functional/concurrent.js
new file mode 100644
index 000000000..85e8cff46
--- /dev/null
+++ b/toolkit/jetpack/sdk/lang/functional/concurrent.js
@@ -0,0 +1,110 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Disclaimer: Some of the functions in this module implement APIs from
+// Jeremy Ashkenas's http://underscorejs.org/ library and all credits for
+// those goes to him.
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { arity, name, derive, invoke } = require("./helpers");
+const { setTimeout, clearTimeout, setImmediate } = require("../../timers");
+
+/**
+ * Takes a function and returns a wrapped one instead, calling which will call
+ * original function in the next turn of event loop. This is basically utility
+ * to do `setImmediate(function() { ... })`, with a difference that returned
+ * function is reused, instead of creating a new one each time. This also allows
+ * to use this functions as event listeners.
+ */
+const defer = f => derive(function(...args) {
+ setImmediate(invoke, f, args, this);
+}, f);
+exports.defer = defer;
+// Exporting `remit` alias as `defer` may conflict with promises.
+exports.remit = defer;
+
+/**
+ * Much like setTimeout, invokes function after wait milliseconds. If you pass
+ * the optional arguments, they will be forwarded on to the function when it is
+ * invoked.
+ */
+const delay = function delay(f, ms, ...args) {
+ setTimeout(() => f.apply(this, args), ms);
+};
+exports.delay = delay;
+
+/**
+ * From underscore's `_.debounce`
+ * http://underscorejs.org
+ * (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+ * Underscore may be freely distributed under the MIT license.
+ */
+const debounce = function debounce (fn, wait) {
+ let timeout, args, context, timestamp, result;
+
+ let later = function () {
+ let last = Date.now() - timestamp;
+ if (last < wait) {
+ timeout = setTimeout(later, wait - last);
+ } else {
+ timeout = null;
+ result = fn.apply(context, args);
+ context = args = null;
+ }
+ };
+
+ return function (...aArgs) {
+ context = this;
+ args = aArgs;
+ timestamp = Date.now();
+ if (!timeout) {
+ timeout = setTimeout(later, wait);
+ }
+
+ return result;
+ };
+};
+exports.debounce = debounce;
+
+/**
+ * From underscore's `_.throttle`
+ * http://underscorejs.org
+ * (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+ * Underscore may be freely distributed under the MIT license.
+ */
+const throttle = function throttle (func, wait, options) {
+ let context, args, result;
+ let timeout = null;
+ let previous = 0;
+ options || (options = {});
+ let later = function() {
+ previous = options.leading === false ? 0 : Date.now();
+ timeout = null;
+ result = func.apply(context, args);
+ context = args = null;
+ };
+ return function() {
+ let now = Date.now();
+ if (!previous && options.leading === false) previous = now;
+ let remaining = wait - (now - previous);
+ context = this;
+ args = arguments;
+ if (remaining <= 0) {
+ clearTimeout(timeout);
+ timeout = null;
+ previous = now;
+ result = func.apply(context, args);
+ context = args = null;
+ } else if (!timeout && options.trailing !== false) {
+ timeout = setTimeout(later, remaining);
+ }
+ return result;
+ };
+};
+exports.throttle = throttle;
diff --git a/toolkit/jetpack/sdk/lang/functional/core.js b/toolkit/jetpack/sdk/lang/functional/core.js
new file mode 100644
index 000000000..0d9143364
--- /dev/null
+++ b/toolkit/jetpack/sdk/lang/functional/core.js
@@ -0,0 +1,290 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Disclaimer: Some of the functions in this module implement APIs from
+// Jeremy Ashkenas's http://underscorejs.org/ library and all credits for
+// those goes to him.
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+}
+const { arity, name, derive, invoke } = require("./helpers");
+
+/**
+ * Takes variadic numeber of functions and returns composed one.
+ * Returned function pushes `this` pseudo-variable to the head
+ * of the passed arguments and invokes all the functions from
+ * left to right passing same arguments to them. Composite function
+ * returns return value of the right most funciton.
+ */
+const method = (...lambdas) => {
+ return function method(...args) {
+ args.unshift(this);
+ return lambdas.reduce((_, lambda) => lambda.apply(this, args),
+ void(0));
+ };
+};
+exports.method = method;
+
+/**
+ * Invokes `callee` by passing `params` as an arguments and `self` as `this`
+ * pseudo-variable. Returns value that is returned by a callee.
+ * @param {Function} callee
+ * Function to invoke.
+ * @param {Array} params
+ * Arguments to invoke function with.
+ * @param {Object} self
+ * Object to be passed as a `this` pseudo variable.
+ */
+exports.invoke = invoke;
+
+/**
+ * Takes a function and bind values to one or more arguments, returning a new
+ * function of smaller arity.
+ *
+ * @param {Function} fn
+ * The function to partial
+ *
+ * @returns The new function with binded values
+ */
+const partial = (f, ...curried) => {
+ if (typeof(f) !== "function")
+ throw new TypeError(String(f) + " is not a function");
+
+ let fn = derive(function(...args) {
+ return f.apply(this, curried.concat(args));
+ }, f);
+ fn.arity = arity(f) - curried.length;
+ return fn;
+};
+exports.partial = partial;
+
+/**
+ * Returns function with implicit currying, which will continue currying until
+ * expected number of argument is collected. Expected number of arguments is
+ * determined by `fn.length`. Using this with variadic functions is stupid,
+ * so don't do it.
+ *
+ * @examples
+ *
+ * var sum = curry(function(a, b) {
+ * return a + b
+ * })
+ * console.log(sum(2, 2)) // 4
+ * console.log(sum(2)(4)) // 6
+ */
+const curry = new function() {
+ const currier = (fn, arity, params) => {
+ // Function either continues to curry arguments or executes function
+ // if desired arguments have being collected.
+ const curried = function(...input) {
+ // Prepend all curried arguments to the given arguments.
+ if (params) input.unshift.apply(input, params);
+ // If expected number of arguments has being collected invoke fn,
+ // othrewise return curried version Otherwise continue curried.
+ return (input.length >= arity) ? fn.apply(this, input) :
+ currier(fn, arity, input);
+ };
+ curried.arity = arity - (params ? params.length : 0);
+
+ return curried;
+ };
+
+ return fn => currier(fn, arity(fn));
+};
+exports.curry = curry;
+
+/**
+ * Returns the composition of a list of functions, where each function consumes
+ * the return value of the function that follows. In math terms, composing the
+ * functions `f()`, `g()`, and `h()` produces `f(g(h()))`.
+ * @example
+ *
+ * var greet = function(name) { return "hi: " + name; };
+ * var exclaim = function(statement) { return statement + "!"; };
+ * var welcome = compose(exclaim, greet);
+ *
+ * welcome('moe'); // => 'hi: moe!'
+ */
+function compose(...lambdas) {
+ return function composed(...args) {
+ let index = lambdas.length;
+ while (0 <= --index)
+ args = [lambdas[index].apply(this, args)];
+
+ return args[0];
+ };
+}
+exports.compose = compose;
+
+/*
+ * Returns the first function passed as an argument to the second,
+ * allowing you to adjust arguments, run code before and after, and
+ * conditionally execute the original function.
+ * @example
+ *
+ * var hello = function(name) { return "hello: " + name; };
+ * hello = wrap(hello, function(f) {
+ * return "before, " + f("moe") + ", after";
+ * });
+ *
+ * hello(); // => 'before, hello: moe, after'
+ */
+const wrap = (f, wrapper) => derive(function wrapped(...args) {
+ return wrapper.apply(this, [f].concat(args));
+}, f);
+exports.wrap = wrap;
+
+/**
+ * Returns the same value that is used as the argument. In math: f(x) = x
+ */
+const identity = value => value;
+exports.identity = identity;
+
+/**
+ * Memoizes a given function by caching the computed result. Useful for
+ * speeding up slow-running computations. If passed an optional hashFunction,
+ * it will be used to compute the hash key for storing the result, based on
+ * the arguments to the original function. The default hashFunction just uses
+ * the first argument to the memoized function as the key.
+ */
+const memoize = (f, hasher) => {
+ let memo = Object.create(null);
+ let cache = new WeakMap();
+ hasher = hasher || identity;
+ return derive(function memoizer(...args) {
+ const key = hasher.apply(this, args);
+ const type = typeof(key);
+ if (key && (type === "object" || type === "function")) {
+ if (!cache.has(key))
+ cache.set(key, f.apply(this, args));
+ return cache.get(key);
+ }
+ else {
+ if (!(key in memo))
+ memo[key] = f.apply(this, args);
+ return memo[key];
+ }
+ }, f);
+};
+exports.memoize = memoize;
+
+/*
+ * Creates a version of the function that can only be called one time. Repeated
+ * calls to the modified function will have no effect, returning the value from
+ * the original call. Useful for initialization functions, instead of having to
+ * set a boolean flag and then check it later.
+ */
+const once = f => {
+ let ran = false, cache;
+ return derive(function(...args) {
+ return ran ? cache : (ran = true, cache = f.apply(this, args));
+ }, f);
+};
+exports.once = once;
+// export cache as once will may be conflicting with event once a lot.
+exports.cache = once;
+
+// Takes a `f` function and returns a function that takes the same
+// arguments as `f`, has the same effects, if any, and returns the
+// opposite truth value.
+const complement = f => derive(function(...args) {
+ return args.length < arity(f) ? complement(partial(f, ...args)) :
+ !f.apply(this, args);
+}, f);
+exports.complement = complement;
+
+// Constructs function that returns `x` no matter what is it
+// invoked with.
+const constant = x => _ => x;
+exports.constant = constant;
+
+// Takes `p` predicate, `consequent` function and an optional
+// `alternate` function and composes function that returns
+// application of arguments over `consequent` if application over
+// `p` is `true` otherwise returns application over `alternate`.
+// If `alternate` is not a function returns `undefined`.
+const when = (p, consequent, alternate) => {
+ if (typeof(alternate) !== "function" && alternate !== void(0))
+ throw TypeError("alternate must be a function");
+ if (typeof(consequent) !== "function")
+ throw TypeError("consequent must be a function");
+
+ return function(...args) {
+ return p.apply(this, args) ?
+ consequent.apply(this, args) :
+ alternate && alternate.apply(this, args);
+ };
+};
+exports.when = when;
+
+// Apply function that behaves as `apply` does in lisp:
+// apply(f, x, [y, z]) => f.apply(f, [x, y, z])
+// apply(f, x) => f.apply(f, [x])
+const apply = (f, ...rest) => f.apply(f, rest.concat(rest.pop()));
+exports.apply = apply;
+
+// Returns function identical to given `f` but with flipped order
+// of arguments.
+const flip = f => derive(function(...args) {
+ return f.apply(this, args.reverse());
+}, f);
+exports.flip = flip;
+
+// Takes field `name` and `target` and returns value of that field.
+// If `target` is `null` or `undefined` it would be returned back
+// instead of attempt to access it's field. Function is implicitly
+// curried, this allows accessor function generation by calling it
+// with only `name` argument.
+const field = curry((name, target) =>
+ // Note: Permisive `==` is intentional.
+ target == null ? target : target[name]);
+exports.field = field;
+
+// Takes `.` delimited string representing `path` to a nested field
+// and a `target` to get it from. For convinience function is
+// implicitly curried, there for accessors can be created by invoking
+// it with just a `path` argument.
+const query = curry((path, target) => {
+ const names = path.split(".");
+ const count = names.length;
+ let index = 0;
+ let result = target;
+ // Note: Permisive `!=` is intentional.
+ while (result != null && index < count) {
+ result = result[names[index]];
+ index = index + 1;
+ }
+ return result;
+});
+exports.query = query;
+
+// Takes `Type` (constructor function) and a `value` and returns
+// `true` if `value` is instance of the given `Type`. Function is
+// implicitly curried this allows predicate generation by calling
+// function with just first argument.
+const isInstance = curry((Type, value) => value instanceof Type);
+exports.isInstance = isInstance;
+
+/*
+ * Takes a funtion and returns a wrapped function that returns `this`
+ */
+const chainable = f => derive(function(...args) {
+ f.apply(this, args);
+ return this;
+}, f);
+exports.chainable = chainable;
+
+// Functions takes `expected` and `actual` values and returns `true` if
+// `expected === actual`. Returns curried function if called with less then
+// two arguments.
+//
+// [ 1, 0, 1, 0, 1 ].map(is(1)) // => [ true, false, true, false, true ]
+const is = curry((expected, actual) => actual === expected);
+exports.is = is;
+
+const isnt = complement(is);
+exports.isnt = isnt;
diff --git a/toolkit/jetpack/sdk/lang/functional/helpers.js b/toolkit/jetpack/sdk/lang/functional/helpers.js
new file mode 100644
index 000000000..60f4e3300
--- /dev/null
+++ b/toolkit/jetpack/sdk/lang/functional/helpers.js
@@ -0,0 +1,29 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Disclaimer: Some of the functions in this module implement APIs from
+// Jeremy Ashkenas's http://underscorejs.org/ library and all credits for
+// those goes to him.
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+}
+
+const arity = f => f.arity || f.length;
+exports.arity = arity;
+
+const name = f => f.displayName || f.name;
+exports.name = name;
+
+const derive = (f, source) => {
+ f.displayName = name(source);
+ f.arity = arity(source);
+ return f;
+};
+exports.derive = derive;
+
+const invoke = (callee, params, self) => callee.apply(self, params);
+exports.invoke = invoke;
diff --git a/toolkit/jetpack/sdk/lang/type.js b/toolkit/jetpack/sdk/lang/type.js
new file mode 100644
index 000000000..b50e6be4c
--- /dev/null
+++ b/toolkit/jetpack/sdk/lang/type.js
@@ -0,0 +1,388 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+/**
+ * Returns `true` if `value` is `undefined`.
+ * @examples
+ * var foo; isUndefined(foo); // true
+ * isUndefined(0); // false
+ */
+function isUndefined(value) {
+ return value === undefined;
+}
+exports.isUndefined = isUndefined;
+
+/**
+ * Returns `true` if value is `null`.
+ * @examples
+ * isNull(null); // true
+ * isNull(undefined); // false
+ */
+function isNull(value) {
+ return value === null;
+}
+exports.isNull = isNull;
+
+/**
+ * Returns `true` if value is `null` or `undefined`.
+ * It's equivalent to `== null`, but resolve the ambiguity of the writer
+ * intention, makes clear that he's clearly checking both `null` and `undefined`
+ * values, and it's not a typo for `=== null`.
+ */
+function isNil(value) {
+ return value === null || value === undefined;
+}
+exports.isNil = isNil;
+
+function isBoolean(value) {
+ return typeof value === "boolean";
+}
+exports.isBoolean = isBoolean;
+/**
+ * Returns `true` if value is a string.
+ * @examples
+ * isString("moe"); // true
+ */
+function isString(value) {
+ return typeof value === "string";
+}
+exports.isString = isString;
+
+/**
+ * Returns `true` if `value` is a number.
+ * @examples
+ * isNumber(8.4 * 5); // true
+ */
+function isNumber(value) {
+ return typeof value === "number";
+}
+exports.isNumber = isNumber;
+
+/**
+ * Returns `true` if `value` is a `RegExp`.
+ * @examples
+ * isRegExp(/moe/); // true
+ */
+function isRegExp(value) {
+ return isObject(value) && instanceOf(value, RegExp);
+}
+exports.isRegExp = isRegExp;
+
+/**
+ * Returns true if `value` is a `Date`.
+ * @examples
+ * isDate(new Date()); // true
+ */
+function isDate(value) {
+ return isObject(value) && instanceOf(value, Date);
+}
+exports.isDate = isDate;
+
+/**
+ * Returns true if object is a Function.
+ * @examples
+ * isFunction(function foo(){}) // true
+ */
+function isFunction(value) {
+ return typeof value === "function";
+}
+exports.isFunction = isFunction;
+
+/**
+ * Returns `true` if `value` is an object (please note that `null` is considered
+ * to be an atom and not an object).
+ * @examples
+ * isObject({}) // true
+ * isObject(null) // false
+ */
+function isObject(value) {
+ return typeof value === "object" && value !== null;
+}
+exports.isObject = isObject;
+
+/**
+ * Detect whether a value is a generator.
+ *
+ * @param aValue
+ * The value to identify.
+ * @return A boolean indicating whether the value is a generator.
+ */
+function isGenerator(aValue) {
+ return !!(aValue && aValue.isGenerator && aValue.isGenerator());
+}
+exports.isGenerator = isGenerator;
+
+/**
+ * Returns true if `value` is an Array.
+ * @examples
+ * isArray([1, 2, 3]) // true
+ * isArray({ 0: 'foo', length: 1 }) // false
+ */
+var isArray = Array.isArray;
+exports.isArray = isArray;
+
+/**
+ * Returns `true` if `value` is an Arguments object.
+ * @examples
+ * (function(){ return isArguments(arguments); })(1, 2, 3); // true
+ * isArguments([1,2,3]); // false
+ */
+function isArguments(value) {
+ return Object.prototype.toString.call(value) === "[object Arguments]";
+}
+exports.isArguments = isArguments;
+
+var isMap = value => Object.prototype.toString.call(value) === "[object Map]"
+exports.isMap = isMap;
+
+var isSet = value => Object.prototype.toString.call(value) === "[object Set]"
+exports.isSet = isSet;
+
+/**
+ * Returns true if it is a primitive `value`. (null, undefined, number,
+ * boolean, string)
+ * @examples
+ * isPrimitive(3) // true
+ * isPrimitive('foo') // true
+ * isPrimitive({ bar: 3 }) // false
+ */
+function isPrimitive(value) {
+ return !isFunction(value) && !isObject(value);
+}
+exports.isPrimitive = isPrimitive;
+
+/**
+ * Returns `true` if given `object` is flat (it is direct decedent of
+ * `Object.prototype` or `null`).
+ * @examples
+ * isFlat({}) // true
+ * isFlat(new Type()) // false
+ */
+function isFlat(object) {
+ return isObject(object) && (isNull(Object.getPrototypeOf(object)) ||
+ isNull(Object.getPrototypeOf(
+ Object.getPrototypeOf(object))));
+}
+exports.isFlat = isFlat;
+
+/**
+ * Returns `true` if object contains no values.
+ */
+function isEmpty(object) {
+ if (isObject(object)) {
+ for (var key in object)
+ return false;
+ return true;
+ }
+ return false;
+}
+exports.isEmpty = isEmpty;
+
+/**
+ * Returns `true` if `value` is an array / flat object containing only atomic
+ * values and other flat objects.
+ */
+function isJSON(value, visited) {
+ // Adding value to array of visited values.
+ (visited || (visited = [])).push(value);
+ // If `value` is an atom return `true` cause it's valid JSON.
+ return isPrimitive(value) ||
+ // If `value` is an array of JSON values that has not been visited
+ // yet.
+ (isArray(value) && value.every(function(element) {
+ return isJSON(element, visited);
+ })) ||
+ // If `value` is a plain object containing properties with a JSON
+ // values it's a valid JSON.
+ (isFlat(value) && Object.keys(value).every(function(key) {
+ var $ = Object.getOwnPropertyDescriptor(value, key);
+ // Check every proprety of a plain object to verify that
+ // it's neither getter nor setter, but a JSON value, that
+ // has not been visited yet.
+ return ((!isObject($.value) || !~visited.indexOf($.value)) &&
+ !('get' in $) && !('set' in $) &&
+ isJSON($.value, visited));
+ }));
+}
+exports.isJSON = function (value) {
+ return isJSON(value);
+};
+
+/**
+ * Returns `true` if `value` is JSONable
+ */
+const isJSONable = (value) => {
+ try {
+ JSON.parse(JSON.stringify(value));
+ }
+ catch (e) {
+ return false;
+ }
+ return true;
+};
+exports.isJSONable = isJSONable;
+
+/**
+ * Returns if `value` is an instance of a given `Type`. This is exactly same as
+ * `value instanceof Type` with a difference that `Type` can be from a scope
+ * that has a different top level object. (Like in case where `Type` is a
+ * function from different iframe / jetpack module / sandbox).
+ */
+function instanceOf(value, Type) {
+ var isConstructorNameSame;
+ var isConstructorSourceSame;
+
+ // If `instanceof` returned `true` we know result right away.
+ var isInstanceOf = value instanceof Type;
+
+ // If `instanceof` returned `false` we do ducktype check since `Type` may be
+ // from a different sandbox. If a constructor of the `value` or a constructor
+ // of the value's prototype has same name and source we assume that it's an
+ // instance of the Type.
+ if (!isInstanceOf && value) {
+ isConstructorNameSame = value.constructor.name === Type.name;
+ isConstructorSourceSame = String(value.constructor) == String(Type);
+ isInstanceOf = (isConstructorNameSame && isConstructorSourceSame) ||
+ instanceOf(Object.getPrototypeOf(value), Type);
+ }
+ return isInstanceOf;
+}
+exports.instanceOf = instanceOf;
+
+/**
+ * Function returns textual representation of a value passed to it. Function
+ * takes additional `indent` argument that is used for indentation. Also
+ * optional `limit` argument may be passed to limit amount of detail returned.
+ * @param {Object} value
+ * @param {String} [indent=" "]
+ * @param {Number} [limit]
+ */
+function source(value, indent, limit, offset, visited) {
+ var result;
+ var names;
+ var nestingIndex;
+ var isCompact = !isUndefined(limit);
+
+ indent = indent || " ";
+ offset = (offset || "");
+ result = "";
+ visited = visited || [];
+
+ if (isUndefined(value)) {
+ result += "undefined";
+ }
+ else if (isNull(value)) {
+ result += "null";
+ }
+ else if (isString(value)) {
+ result += '"' + value + '"';
+ }
+ else if (isFunction(value)) {
+ value = String(value).split("\n");
+ if (isCompact && value.length > 2) {
+ value = value.splice(0, 2);
+ value.push("...}");
+ }
+ result += value.join("\n" + offset);
+ }
+ else if (isArray(value)) {
+ if ((nestingIndex = (visited.indexOf(value) + 1))) {
+ result = "#" + nestingIndex + "#";
+ }
+ else {
+ visited.push(value);
+
+ if (isCompact)
+ value = value.slice(0, limit);
+
+ result += "[\n";
+ result += value.map(function(value) {
+ return offset + indent + source(value, indent, limit, offset + indent,
+ visited);
+ }).join(",\n");
+ result += isCompact && value.length > limit ?
+ ",\n" + offset + "...]" : "\n" + offset + "]";
+ }
+ }
+ else if (isObject(value)) {
+ if ((nestingIndex = (visited.indexOf(value) + 1))) {
+ result = "#" + nestingIndex + "#"
+ }
+ else {
+ visited.push(value)
+
+ names = Object.keys(value);
+
+ result += "{ // " + value + "\n";
+ result += (isCompact ? names.slice(0, limit) : names).map(function(name) {
+ var _limit = isCompact ? limit - 1 : limit;
+ var descriptor = Object.getOwnPropertyDescriptor(value, name);
+ var result = offset + indent + "// ";
+ var accessor;
+ if (0 <= name.indexOf(" "))
+ name = '"' + name + '"';
+
+ if (descriptor.writable)
+ result += "writable ";
+ if (descriptor.configurable)
+ result += "configurable ";
+ if (descriptor.enumerable)
+ result += "enumerable ";
+
+ result += "\n";
+ if ("value" in descriptor) {
+ result += offset + indent + name + ": ";
+ result += source(descriptor.value, indent, _limit, indent + offset,
+ visited);
+ }
+ else {
+
+ if (descriptor.get) {
+ result += offset + indent + "get " + name + " ";
+ accessor = source(descriptor.get, indent, _limit, indent + offset,
+ visited);
+ result += accessor.substr(accessor.indexOf("{"));
+ }
+
+ if (descriptor.set) {
+ result += offset + indent + "set " + name + " ";
+ accessor = source(descriptor.set, indent, _limit, indent + offset,
+ visited);
+ result += accessor.substr(accessor.indexOf("{"));
+ }
+ }
+ return result;
+ }).join(",\n");
+
+ if (isCompact) {
+ if (names.length > limit && limit > 0) {
+ result += ",\n" + offset + indent + "//...";
+ }
+ }
+ else {
+ if (names.length)
+ result += ",";
+
+ result += "\n" + offset + indent + '"__proto__": ';
+ result += source(Object.getPrototypeOf(value), indent, 0,
+ offset + indent);
+ }
+
+ result += "\n" + offset + "}";
+ }
+ }
+ else {
+ result += String(value);
+ }
+ return result;
+}
+exports.source = function (value, indentation, limit) {
+ return source(value, indentation, limit);
+};
diff --git a/toolkit/jetpack/sdk/lang/weak-set.js b/toolkit/jetpack/sdk/lang/weak-set.js
new file mode 100644
index 000000000..8972602a5
--- /dev/null
+++ b/toolkit/jetpack/sdk/lang/weak-set.js
@@ -0,0 +1,75 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+"use strict";
+
+const { Cu } = require("chrome");
+
+function makeGetterFor(Type) {
+ let cache = new WeakMap();
+
+ return {
+ getFor(target) {
+ if (!cache.has(target))
+ cache.set(target, new Type());
+
+ return cache.get(target);
+ },
+ clearFor(target) {
+ return cache.delete(target)
+ }
+ }
+}
+
+var {getFor: getLookupFor, clearFor: clearLookupFor} = makeGetterFor(WeakMap);
+var {getFor: getRefsFor, clearFor: clearRefsFor} = makeGetterFor(Set);
+
+function add(target, value) {
+ if (has(target, value))
+ return;
+
+ getLookupFor(target).set(value, true);
+ getRefsFor(target).add(Cu.getWeakReference(value));
+}
+exports.add = add;
+
+function remove(target, value) {
+ getLookupFor(target).delete(value);
+}
+exports.remove = remove;
+
+function has(target, value) {
+ return getLookupFor(target).has(value);
+}
+exports.has = has;
+
+function clear(target) {
+ clearLookupFor(target);
+ clearRefsFor(target);
+}
+exports.clear = clear;
+
+function iterator(target) {
+ let refs = getRefsFor(target);
+
+ for (let ref of refs) {
+ let value = ref.get();
+
+ // If `value` is already gc'ed, it would be `null`.
+ // The `has` function is using a WeakMap as lookup table, so passing `null`
+ // would raise an exception because WeakMap accepts as value only non-null
+ // object.
+ // Plus, if `value` is already gc'ed, we do not have to take it in account
+ // during the iteration, and remove it from the references.
+ if (value !== null && has(target, value))
+ yield value;
+ else
+ refs.delete(ref);
+ }
+}
+exports.iterator = iterator;
diff --git a/toolkit/jetpack/sdk/loader/cuddlefish.js b/toolkit/jetpack/sdk/loader/cuddlefish.js
new file mode 100644
index 000000000..6ba19157b
--- /dev/null
+++ b/toolkit/jetpack/sdk/loader/cuddlefish.js
@@ -0,0 +1,102 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+// This module is manually loaded by bootstrap.js in a sandbox and immediatly
+// put in module cache so that it is never loaded in any other way.
+
+/* Workarounds to include dependencies in the manifest
+require('chrome') // Otherwise CFX will complain about Components
+require('toolkit/loader') // Otherwise CFX will stip out loader.js
+require('sdk/addon/runner') // Otherwise CFX will stip out addon/runner.js
+*/
+
+const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components;
+
+// `loadSandbox` is exposed by bootstrap.js
+const loaderURI = module.uri.replace("sdk/loader/cuddlefish.js",
+ "toolkit/loader.js");
+const xulappURI = module.uri.replace("loader/cuddlefish.js",
+ "system/xul-app.jsm");
+// We need to keep a reference to the sandbox in order to unload it in
+// bootstrap.js
+
+var loaderSandbox = loadSandbox(loaderURI);
+const loaderModule = loaderSandbox.exports;
+
+const { incompatibility } = Cu.import(xulappURI, {}).XulApp;
+
+const { override, load } = loaderModule;
+
+function CuddlefishLoader(options) {
+ let { manifest } = options;
+
+ options = override(options, {
+ // Put `api-utils/loader` and `api-utils/cuddlefish` loaded as JSM to module
+ // cache to avoid subsequent loads via `require`.
+ modules: override({
+ 'toolkit/loader': loaderModule,
+ 'sdk/loader/cuddlefish': exports
+ }, options.modules),
+ resolve: function resolve(id, requirer) {
+ let entry = requirer && requirer in manifest && manifest[requirer];
+ let uri = null;
+
+ // If manifest entry for this requirement is present we follow manifest.
+ // Note: Standard library modules like 'panel' will be present in
+ // manifest unless they were moved to platform.
+ if (entry) {
+ let requirement = entry.requirements[id];
+ // If requirer entry is in manifest and it's requirement is not, than
+ // it has no authority to load since linker was not able to find it.
+ if (!requirement)
+ throw Error('Module: ' + requirer + ' has no authority to load: '
+ + id, requirer);
+
+ uri = requirement;
+ } else {
+ // If requirer is off manifest than it's a system module and we allow it
+ // to go off manifest by resolving a relative path.
+ uri = loaderModule.resolve(id, requirer);
+ }
+ return uri;
+ },
+ load: function(loader, module) {
+ let result;
+ let error;
+
+ // In order to get the module's metadata, we need to load the module.
+ // if an exception is raised here, it could be that is due to application
+ // incompatibility. Therefore the exception is stored, and thrown again
+ // only if the module seems be compatible with the application currently
+ // running. Otherwise the incompatibility message takes the precedence.
+ try {
+ result = load(loader, module);
+ }
+ catch (e) {
+ error = e;
+ }
+
+ error = incompatibility(module) || error;
+
+ if (error)
+ throw error;
+
+ return result;
+ }
+ });
+
+ let loader = loaderModule.Loader(options);
+ // Hack to allow loading from `toolkit/loader`.
+ loader.modules[loaderURI] = loaderSandbox;
+ return loader;
+}
+
+exports = override(loaderModule, {
+ Loader: CuddlefishLoader
+});
diff --git a/toolkit/jetpack/sdk/loader/sandbox.js b/toolkit/jetpack/sdk/loader/sandbox.js
new file mode 100644
index 000000000..791dbc086
--- /dev/null
+++ b/toolkit/jetpack/sdk/loader/sandbox.js
@@ -0,0 +1,74 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci, CC, Cu } = require('chrome');
+const systemPrincipal = CC('@mozilla.org/systemprincipal;1', 'nsIPrincipal')();
+const scriptLoader = Cc['@mozilla.org/moz/jssubscript-loader;1'].
+ getService(Ci.mozIJSSubScriptLoader);
+const self = require('sdk/self');
+const { getTabId } = require('../tabs/utils');
+const { getInnerId } = require('../window/utils');
+
+const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+const { require: devtoolsRequire } = devtools;
+const { addContentGlobal, removeContentGlobal } = devtoolsRequire("devtools/server/content-globals");
+
+/**
+ * Make a new sandbox that inherits given `source`'s principals. Source can be
+ * URI string, DOMWindow or `null` for system principals.
+ */
+function sandbox(target, options) {
+ options = options || {};
+ options.metadata = options.metadata ? options.metadata : {};
+ options.metadata.addonID = options.metadata.addonID ?
+ options.metadata.addonID : self.id;
+
+ let sandbox = Cu.Sandbox(target || systemPrincipal, options);
+ Cu.setSandboxMetadata(sandbox, options.metadata);
+ let innerWindowID = options.metadata['inner-window-id']
+ if (innerWindowID) {
+ addContentGlobal({
+ global: sandbox,
+ 'inner-window-id': innerWindowID
+ });
+ }
+ return sandbox;
+}
+exports.sandbox = sandbox;
+
+/**
+ * Evaluates given `source` in a given `sandbox` and returns result.
+ */
+function evaluate(sandbox, code, uri, line, version) {
+ return Cu.evalInSandbox(code, sandbox, version || '1.8', uri || '', line || 1);
+}
+exports.evaluate = evaluate;
+
+/**
+ * Evaluates code under the given `uri` in the given `sandbox`.
+ *
+ * @param {String} uri
+ * The URL pointing to the script to load.
+ * It must be a local chrome:, resource:, file: or data: URL.
+ */
+function load(sandbox, uri) {
+ if (uri.indexOf('data:') === 0) {
+ let source = uri.substr(uri.indexOf(',') + 1);
+
+ return evaluate(sandbox, decodeURIComponent(source), '1.8', uri, 0);
+ } else {
+ return scriptLoader.loadSubScript(uri, sandbox, 'UTF-8');
+ }
+}
+exports.load = load;
+
+/**
+ * Forces the given `sandbox` to be freed immediately.
+ */
+exports.nuke = Cu.nukeSandbox
diff --git a/toolkit/jetpack/sdk/messaging.js b/toolkit/jetpack/sdk/messaging.js
new file mode 100644
index 000000000..07580eb33
--- /dev/null
+++ b/toolkit/jetpack/sdk/messaging.js
@@ -0,0 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { window } = require("sdk/addon/window");
+exports.MessageChannel = window.MessageChannel;
+exports.MessagePort = window.MessagePort;
diff --git a/toolkit/jetpack/sdk/model/core.js b/toolkit/jetpack/sdk/model/core.js
new file mode 100644
index 000000000..315f8b1cd
--- /dev/null
+++ b/toolkit/jetpack/sdk/model/core.js
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { dispatcher } = require("../util/dispatcher");
+
+
+// Define `modelFor` accessor function that can be implemented
+// for different types of views. Since view's we'll be dealing
+// with types that don't really play well with `instanceof`
+// operator we're gonig to use `dispatcher` that is slight
+// extension over polymorphic dispatch provided by method.
+// This allows models to extend implementations of this by
+// providing predicates:
+//
+// modelFor.when($ => $ && $.nodeName === "tab", findTabById($.id))
+const modelFor = dispatcher("modelFor");
+exports.modelFor = modelFor;
diff --git a/toolkit/jetpack/sdk/net/url.js b/toolkit/jetpack/sdk/net/url.js
new file mode 100644
index 000000000..5502171ee
--- /dev/null
+++ b/toolkit/jetpack/sdk/net/url.js
@@ -0,0 +1,94 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Ci, Cu, components } = require("chrome");
+
+const { defer } = require("../core/promise");
+const { merge } = require("../util/object");
+
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
+const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+
+/**
+ * Reads a URI and returns a promise.
+ *
+ * @param uri {string} The URI to read
+ * @param [options] {object} This parameter can have any or all of the following
+ * fields: `charset`. By default the `charset` is set to 'UTF-8'.
+ *
+ * @returns {promise} The promise that will be resolved with the content of the
+ * URL given.
+ *
+ * @example
+ * let promise = readURI('resource://gre/modules/NetUtil.jsm', {
+ * charset: 'US-ASCII'
+ * });
+ */
+function readURI(uri, options) {
+ options = options || {};
+ let charset = options.charset || 'UTF-8';
+
+ let channel = NetUtil.newChannel({
+ uri: NetUtil.newURI(uri, charset),
+ loadUsingSystemPrincipal: true});
+
+ let { promise, resolve, reject } = defer();
+
+ try {
+ NetUtil.asyncFetch(channel, function (stream, result) {
+ if (components.isSuccessCode(result)) {
+ let count = stream.available();
+ let data = NetUtil.readInputStreamToString(stream, count, { charset : charset });
+
+ resolve(data);
+ } else {
+ reject("Failed to read: '" + uri + "' (Error Code: " + result + ")");
+ }
+ });
+ }
+ catch (e) {
+ reject("Failed to read: '" + uri + "' (Error: " + e.message + ")");
+ }
+
+ return promise;
+}
+
+exports.readURI = readURI;
+
+/**
+ * Reads a URI synchronously.
+ * This function is intentionally undocumented to favorites the `readURI` usage.
+ *
+ * @param uri {string} The URI to read
+ * @param [charset] {string} The character set to use when read the content of
+ * the `uri` given. By default is set to 'UTF-8'.
+ *
+ * @returns {string} The content of the URI given.
+ *
+ * @example
+ * let data = readURISync('resource://gre/modules/NetUtil.jsm');
+ */
+function readURISync(uri, charset) {
+ charset = typeof charset === "string" ? charset : "UTF-8";
+
+ let channel = NetUtil.newChannel({
+ uri: NetUtil.newURI(uri, charset),
+ loadUsingSystemPrincipal: true});
+ let stream = channel.open2();
+
+ let count = stream.available();
+ let data = NetUtil.readInputStreamToString(stream, count, { charset : charset });
+
+ stream.close();
+
+ return data;
+}
+
+exports.readURISync = readURISync;
diff --git a/toolkit/jetpack/sdk/net/xhr.js b/toolkit/jetpack/sdk/net/xhr.js
new file mode 100644
index 000000000..415b9cbf4
--- /dev/null
+++ b/toolkit/jetpack/sdk/net/xhr.js
@@ -0,0 +1,36 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { deprecateFunction } = require("../util/deprecate");
+const { Cc, Ci } = require("chrome");
+const XMLHttpRequest = require("../addon/window").window.XMLHttpRequest;
+
+Object.defineProperties(XMLHttpRequest.prototype, {
+ mozBackgroundRequest: {
+ value: true,
+ },
+ forceAllowThirdPartyCookie: {
+ configurable: true,
+ value: deprecateFunction(function() {
+ forceAllowThirdPartyCookie(this);
+
+ }, "`xhr.forceAllowThirdPartyCookie()` is deprecated, please use" +
+ "`require('sdk/net/xhr').forceAllowThirdPartyCookie(request)` instead")
+ }
+});
+exports.XMLHttpRequest = XMLHttpRequest;
+
+function forceAllowThirdPartyCookie(xhr) {
+ if (xhr.channel instanceof Ci.nsIHttpChannelInternal)
+ xhr.channel.forceAllowThirdPartyCookie = true;
+}
+exports.forceAllowThirdPartyCookie = forceAllowThirdPartyCookie;
+
+// No need to handle add-on unloads as addon/window is closed at unload
+// and it will take down all the associated requests.
diff --git a/toolkit/jetpack/sdk/notifications.js b/toolkit/jetpack/sdk/notifications.js
new file mode 100644
index 000000000..752e08fb1
--- /dev/null
+++ b/toolkit/jetpack/sdk/notifications.js
@@ -0,0 +1,112 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { Cc, Ci, Cr } = require("chrome");
+const apiUtils = require("./deprecated/api-utils");
+const { isString, isUndefined, instanceOf } = require('./lang/type');
+const { URL, isLocalURL } = require('./url');
+const { data } = require('./self');
+
+const NOTIFICATION_DIRECTIONS = ["auto", "ltr", "rtl"];
+
+try {
+ let alertServ = Cc["@mozilla.org/alerts-service;1"].
+ getService(Ci.nsIAlertsService);
+
+ // The unit test sets this to a mock notification function.
+ var notify = alertServ.showAlertNotification.bind(alertServ);
+}
+catch (err) {
+ // An exception will be thrown if the platform doesn't provide an alert
+ // service, e.g., if Growl is not installed on OS X. In that case, use a
+ // mock notification function that just logs to the console.
+ notify = notifyUsingConsole;
+}
+
+exports.notify = function notifications_notify(options) {
+ let valOpts = validateOptions(options);
+ let clickObserver = !valOpts.onClick ? null : {
+ observe: (subject, topic, data) => {
+ if (topic === "alertclickcallback") {
+ try {
+ valOpts.onClick.call(exports, valOpts.data);
+ }
+ catch(e) {
+ console.exception(e);
+ }
+ }
+ }
+ };
+ function notifyWithOpts(notifyFn) {
+ let { iconURL } = valOpts;
+ iconURL = iconURL && isLocalURL(iconURL) ? data.url(iconURL) : iconURL;
+
+ notifyFn(iconURL, valOpts.title, valOpts.text, !!clickObserver,
+ valOpts.data, clickObserver, valOpts.tag, valOpts.dir, valOpts.lang);
+ }
+ try {
+ notifyWithOpts(notify);
+ }
+ catch (err) {
+ if (err instanceof Ci.nsIException && err.result == Cr.NS_ERROR_FILE_NOT_FOUND) {
+ console.warn("The notification icon named by " + iconURL +
+ " does not exist. A default icon will be used instead.");
+ delete valOpts.iconURL;
+ notifyWithOpts(notify);
+ }
+ else {
+ notifyWithOpts(notifyUsingConsole);
+ }
+ }
+};
+
+function notifyUsingConsole(iconURL, title, text) {
+ title = title ? "[" + title + "]" : "";
+ text = text || "";
+ let str = [title, text].filter(s => s).join(" ");
+ console.log(str);
+}
+
+function validateOptions(options) {
+ return apiUtils.validateOptions(options, {
+ data: {
+ is: ["string", "undefined"]
+ },
+ iconURL: {
+ is: ["string", "undefined", "object"],
+ ok: function(value) {
+ return isUndefined(value) || isString(value) || (value instanceof URL);
+ },
+ msg: "`iconURL` must be a string or an URL instance."
+ },
+ onClick: {
+ is: ["function", "undefined"]
+ },
+ text: {
+ is: ["string", "undefined", "number"]
+ },
+ title: {
+ is: ["string", "undefined", "number"]
+ },
+ tag: {
+ is: ["string", "undefined", "number"]
+ },
+ dir: {
+ is: ["string", "undefined"],
+ ok: function(value) {
+ return isUndefined(value) || ~NOTIFICATION_DIRECTIONS.indexOf(value);
+ },
+ msg: '`dir` option must be one of: "auto", "ltr" or "rtl".'
+ },
+ lang: {
+ is: ["string", "undefined"]
+ }
+ });
+}
diff --git a/toolkit/jetpack/sdk/output/system.js b/toolkit/jetpack/sdk/output/system.js
new file mode 100644
index 000000000..4fb16dcd5
--- /dev/null
+++ b/toolkit/jetpack/sdk/output/system.js
@@ -0,0 +1,71 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Cc, Ci, Cr } = require("chrome");
+const { Input, start, stop, receive, outputs } = require("../event/utils");
+const { id: addonID } = require("../self");
+const { setImmediate } = require("../timers");
+const { notifyObservers } = Cc['@mozilla.org/observer-service;1'].
+ getService(Ci.nsIObserverService);
+
+const NOT_AN_INPUT = "OutputPort can be used only for sending messages";
+
+// `OutputPort` creates a port to which messages can be send. Those
+// messages are actually disptached as `subject`'s of the observer
+// notifications. This is handy for communicating between different
+// components of the SDK. By default messages are dispatched
+// asynchronously, although `options.sync` can be used to make them
+// synchronous. If `options.id` is given `topic` for observer
+// notifications is generated by namespacing it, to avoid spamming
+// other SDK add-ons. It's also possible to provide `options.topic`
+// to use excat `topic` without namespacing it.
+//
+// Note: Symmetric `new InputPort({ id: "x" })` instances can be used to
+// receive messages send to the instances of `new OutputPort({ id: "x" })`.
+const OutputPort = function({id, topic, sync}) {
+ this.id = id || topic;
+ this.sync = !!sync;
+ this.topic = topic || "sdk:" + addonID + ":" + id;
+};
+// OutputPort extends base signal type to implement same message
+// receiving interface.
+OutputPort.prototype = new Input();
+OutputPort.constructor = OutputPort;
+
+// OutputPort can not be consumed there for starting or stopping it
+// is not supported.
+OutputPort.prototype[start] = _ => { throw TypeError(NOT_AN_INPUT); };
+OutputPort.prototype[stop] = _ => { throw TypeError(NOT_AN_INPUT); };
+
+// Port reecives message send to it, which will be dispatched via
+// observer notification service.
+OutputPort.receive = ({topic, sync}, message) => {
+ const type = typeof(message);
+ const supported = message === null ||
+ type === "object" ||
+ type === "function";
+
+ // There is no sensible way to wrap JS primitives that would make sense
+ // for general observer notification users. It's also probably not very
+ // useful to dispatch JS primitives as subject of observer service, there
+ // for we do not support those use cases.
+ if (!supported)
+ throw new TypeError("Unsupproted message type: `" + type + "`");
+
+ // Normalize `message` to create a valid observer notification `subject`.
+ // If `message` is `null`, implements `nsISupports` interface or already
+ // represents wrapped JS object use it as is. Otherwise create a wrapped
+ // object so that observers could receive it.
+ const subject = message === null ? null :
+ message instanceof Ci.nsISupports ? message :
+ message.wrappedJSObject ? message :
+ {wrappedJSObject: message};
+ if (sync)
+ notifyObservers(subject, topic, null);
+ else
+ setImmediate(notifyObservers, subject, topic, null);
+};
+OutputPort.prototype[receive] = OutputPort.receive;
+exports.OutputPort = OutputPort;
diff --git a/toolkit/jetpack/sdk/page-mod.js b/toolkit/jetpack/sdk/page-mod.js
new file mode 100644
index 000000000..538be2732
--- /dev/null
+++ b/toolkit/jetpack/sdk/page-mod.js
@@ -0,0 +1,190 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { contract: loaderContract } = require('./content/loader');
+const { contract } = require('./util/contract');
+const { WorkerHost, connect } = require('./content/utils');
+const { Class } = require('./core/heritage');
+const { Disposable } = require('./core/disposable');
+const { Worker } = require('./content/worker');
+const { EventTarget } = require('./event/target');
+const { on, emit, once, setListeners } = require('./event/core');
+const { isRegExp, isUndefined } = require('./lang/type');
+const { merge, omit } = require('./util/object');
+const { remove, has, hasAny } = require("./util/array");
+const { Rules } = require("./util/rules");
+const { processes, frames, remoteRequire } = require('./remote/parent');
+remoteRequire('sdk/content/page-mod');
+
+const pagemods = new Map();
+const workers = new Map();
+const models = new WeakMap();
+var modelFor = (mod) => models.get(mod);
+var workerFor = (mod) => workers.get(mod)[0];
+
+// Helper functions
+var isRegExpOrString = (v) => isRegExp(v) || typeof v === 'string';
+
+var PAGEMOD_ID = 0;
+
+// Validation Contracts
+const modOptions = {
+ // contentStyle* / contentScript* are sharing the same validation constraints,
+ // so they can be mostly reused, except for the messages.
+ contentStyle: merge(Object.create(loaderContract.rules.contentScript), {
+ msg: 'The `contentStyle` option must be a string or an array of strings.'
+ }),
+ contentStyleFile: merge(Object.create(loaderContract.rules.contentScriptFile), {
+ msg: 'The `contentStyleFile` option must be a local URL or an array of URLs'
+ }),
+ include: {
+ is: ['string', 'array', 'regexp'],
+ ok: (rule) => {
+ if (isRegExpOrString(rule))
+ return true;
+ if (Array.isArray(rule) && rule.length > 0)
+ return rule.every(isRegExpOrString);
+ return false;
+ },
+ msg: 'The `include` option must always contain atleast one rule as a string, regular expression, or an array of strings and regular expressions.'
+ },
+ exclude: {
+ is: ['string', 'array', 'regexp', 'undefined'],
+ ok: (rule) => {
+ if (isRegExpOrString(rule) || isUndefined(rule))
+ return true;
+ if (Array.isArray(rule) && rule.length > 0)
+ return rule.every(isRegExpOrString);
+ return false;
+ },
+ msg: 'If set, the `exclude` option must always contain at least one ' +
+ 'rule as a string, regular expression, or an array of strings and ' +
+ 'regular expressions.'
+ },
+ attachTo: {
+ is: ['string', 'array', 'undefined'],
+ map: function (attachTo) {
+ if (!attachTo) return ['top', 'frame'];
+ if (typeof attachTo === 'string') return [attachTo];
+ return attachTo;
+ },
+ ok: function (attachTo) {
+ return hasAny(attachTo, ['top', 'frame']) &&
+ attachTo.every(has.bind(null, ['top', 'frame', 'existing']));
+ },
+ msg: 'The `attachTo` option must be a string or an array of strings. ' +
+ 'The only valid options are "existing", "top" and "frame", and must ' +
+ 'contain at least "top" or "frame" values.'
+ },
+};
+
+const modContract = contract(merge({}, loaderContract.rules, modOptions));
+
+/**
+ * PageMod constructor (exported below).
+ * @constructor
+ */
+const PageMod = Class({
+ implements: [
+ modContract.properties(modelFor),
+ EventTarget,
+ Disposable,
+ ],
+ extends: WorkerHost(workerFor),
+ setup: function PageMod(options) {
+ let mod = this;
+ let model = modContract(options);
+ models.set(this, model);
+ model.id = PAGEMOD_ID++;
+
+ let include = model.include;
+ model.include = Rules();
+ model.include.add.apply(model.include, [].concat(include));
+
+ let exclude = isUndefined(model.exclude) ? [] : model.exclude;
+ model.exclude = Rules();
+ model.exclude.add.apply(model.exclude, [].concat(exclude));
+
+ // Set listeners on {PageMod} itself, not the underlying worker,
+ // like `onMessage`, as it'll get piped.
+ setListeners(this, options);
+
+ pagemods.set(model.id, this);
+ workers.set(this, []);
+
+ function serializeRules(rules) {
+ for (let rule of rules) {
+ yield isRegExp(rule) ? { type: "regexp", pattern: rule.source, flags: rule.flags }
+ : { type: "string", value: rule };
+ }
+ }
+
+ model.childOptions = omit(model, ["include", "exclude", "contentScriptOptions"]);
+ model.childOptions.include = [...serializeRules(model.include)];
+ model.childOptions.exclude = [...serializeRules(model.exclude)];
+ model.childOptions.contentScriptOptions = model.contentScriptOptions ?
+ JSON.stringify(model.contentScriptOptions) :
+ null;
+
+ processes.port.emit('sdk/page-mod/create', model.childOptions);
+ },
+
+ dispose: function(reason) {
+ processes.port.emit('sdk/page-mod/destroy', modelFor(this).id);
+ pagemods.delete(modelFor(this).id);
+ workers.delete(this);
+ },
+
+ destroy: function(reason) {
+ // Explicit destroy call, i.e. not via unload so destroy the workers
+ let list = workers.get(this);
+ if (!list)
+ return;
+
+ // Triggers dispose which will cause the child page-mod to be destroyed
+ Disposable.prototype.destroy.call(this, reason);
+
+ // Destroy any active workers
+ for (let worker of list)
+ worker.destroy(reason);
+ }
+});
+exports.PageMod = PageMod;
+
+// Whenever a new process starts send over the list of page-mods
+processes.forEvery(process => {
+ for (let mod of pagemods.values())
+ process.port.emit('sdk/page-mod/create', modelFor(mod).childOptions);
+});
+
+frames.port.on('sdk/page-mod/worker-create', (frame, modId, workerOptions) => {
+ let mod = pagemods.get(modId);
+ if (!mod)
+ return;
+
+ // Attach the parent side of the worker to the child
+ let worker = Worker();
+
+ workers.get(mod).unshift(worker);
+ worker.on('*', (event, ...args) => {
+ // page-mod's "attach" event needs to be passed a worker
+ if (event === 'attach')
+ emit(mod, event, worker)
+ else
+ emit(mod, event, ...args);
+ });
+
+ worker.on('detach', () => {
+ let array = workers.get(mod);
+ if (array)
+ remove(array, worker);
+ });
+
+ connect(worker, frame, workerOptions);
+});
diff --git a/toolkit/jetpack/sdk/page-mod/match-pattern.js b/toolkit/jetpack/sdk/page-mod/match-pattern.js
new file mode 100644
index 000000000..afbbd401e
--- /dev/null
+++ b/toolkit/jetpack/sdk/page-mod/match-pattern.js
@@ -0,0 +1,10 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ "use strict";
+
+var { deprecateUsage } = require("../util/deprecate");
+
+deprecateUsage("Module 'sdk/page-mod/match-pattern' is deprecated use 'sdk/util/match-pattern' instead");
+
+module.exports = require("../util/match-pattern");
diff --git a/toolkit/jetpack/sdk/page-worker.js b/toolkit/jetpack/sdk/page-worker.js
new file mode 100644
index 000000000..837cf774b
--- /dev/null
+++ b/toolkit/jetpack/sdk/page-worker.js
@@ -0,0 +1,194 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { Class } = require('./core/heritage');
+const { ns } = require('./core/namespace');
+const { pipe, stripListeners } = require('./event/utils');
+const { connect, destroy, WorkerHost } = require('./content/utils');
+const { Worker } = require('./content/worker');
+const { Disposable } = require('./core/disposable');
+const { EventTarget } = require('./event/target');
+const { setListeners } = require('./event/core');
+const { window } = require('./addon/window');
+const { create: makeFrame, getDocShell } = require('./frame/utils');
+const { contract } = require('./util/contract');
+const { contract: loaderContract } = require('./content/loader');
+const { Rules } = require('./util/rules');
+const { merge } = require('./util/object');
+const { uuid } = require('./util/uuid');
+const { useRemoteProcesses, remoteRequire, frames } = require("./remote/parent");
+remoteRequire("sdk/content/page-worker");
+
+const workers = new WeakMap();
+const pages = new Map();
+
+const internal = ns();
+
+let workerFor = (page) => workers.get(page);
+let isDisposed = (page) => !pages.has(internal(page).id);
+
+// The frame is used to ensure we have a remote process to load workers in
+let remoteFrame = null;
+let framePromise = null;
+function getFrame() {
+ if (framePromise)
+ return framePromise;
+
+ framePromise = new Promise(resolve => {
+ let view = makeFrame(window.document, {
+ namespaceURI: "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
+ nodeName: "iframe",
+ type: "content",
+ remote: useRemoteProcesses,
+ uri: "about:blank"
+ });
+
+ // Wait for the remote side to connect
+ let listener = (frame) => {
+ if (frame.frameElement != view)
+ return;
+ frames.off("attach", listener);
+ remoteFrame = frame;
+ resolve(frame);
+ }
+ frames.on("attach", listener);
+ });
+ return framePromise;
+}
+
+var pageContract = contract(merge({
+ allow: {
+ is: ['object', 'undefined', 'null'],
+ map: function (allow) { return { script: !allow || allow.script !== false }}
+ },
+ onMessage: {
+ is: ['function', 'undefined']
+ },
+ include: {
+ is: ['string', 'array', 'regexp', 'undefined']
+ },
+ contentScriptWhen: {
+ is: ['string', 'undefined'],
+ map: (when) => when || "end"
+ }
+}, loaderContract.rules));
+
+function enableScript (page) {
+ getDocShell(viewFor(page)).allowJavascript = true;
+}
+
+function disableScript (page) {
+ getDocShell(viewFor(page)).allowJavascript = false;
+}
+
+function Allow (page) {
+ return {
+ get script() {
+ return internal(page).options.allow.script;
+ },
+ set script(value) {
+ internal(page).options.allow.script = value;
+
+ if (isDisposed(page))
+ return;
+
+ remoteFrame.port.emit("sdk/frame/set", internal(page).id, { allowScript: value });
+ }
+ };
+}
+
+function isValidURL(page, url) {
+ return !page.rules || page.rules.matchesAny(url);
+}
+
+const Page = Class({
+ implements: [
+ EventTarget,
+ Disposable
+ ],
+ extends: WorkerHost(workerFor),
+ setup: function Page(options) {
+ options = pageContract(options);
+ // Sanitize the options
+ if ("contentScriptOptions" in options)
+ options.contentScriptOptions = JSON.stringify(options.contentScriptOptions);
+
+ internal(this).id = uuid().toString();
+ internal(this).options = options;
+
+ for (let prop of ['contentScriptFile', 'contentScript', 'contentScriptWhen']) {
+ this[prop] = options[prop];
+ }
+
+ pages.set(internal(this).id, this);
+
+ // Set listeners on the {Page} object itself, not the underlying worker,
+ // like `onMessage`, as it gets piped
+ setListeners(this, options);
+ let worker = new Worker(stripListeners(options));
+ workers.set(this, worker);
+ pipe(worker, this);
+
+ if (options.include) {
+ this.rules = Rules();
+ this.rules.add.apply(this.rules, [].concat(options.include));
+ }
+
+ getFrame().then(frame => {
+ if (isDisposed(this))
+ return;
+
+ frame.port.emit("sdk/frame/create", internal(this).id, stripListeners(options));
+ });
+ },
+ get allow() { return Allow(this); },
+ set allow(value) {
+ if (isDisposed(this))
+ return;
+ this.allow.script = pageContract({ allow: value }).allow.script;
+ },
+ get contentURL() {
+ return internal(this).options.contentURL;
+ },
+ set contentURL(value) {
+ if (!isValidURL(this, value))
+ return;
+ internal(this).options.contentURL = value;
+ if (isDisposed(this))
+ return;
+
+ remoteFrame.port.emit("sdk/frame/set", internal(this).id, { contentURL: value });
+ },
+ dispose: function () {
+ if (isDisposed(this))
+ return;
+ pages.delete(internal(this).id);
+ let worker = workerFor(this);
+ if (worker)
+ destroy(worker);
+ remoteFrame.port.emit("sdk/frame/destroy", internal(this).id);
+
+ // Destroy the remote frame if all the pages have been destroyed
+ if (pages.size == 0) {
+ framePromise = null;
+ remoteFrame.frameElement.remove();
+ remoteFrame = null;
+ }
+ },
+ toString: function () { return '[object Page]' }
+});
+
+exports.Page = Page;
+
+frames.port.on("sdk/frame/connect", (frame, id, params) => {
+ let page = pages.get(id);
+ if (!page)
+ return;
+ connect(workerFor(page), frame, params);
+});
diff --git a/toolkit/jetpack/sdk/panel.js b/toolkit/jetpack/sdk/panel.js
new file mode 100644
index 000000000..4b625799d
--- /dev/null
+++ b/toolkit/jetpack/sdk/panel.js
@@ -0,0 +1,427 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+// The panel module currently supports only Firefox and SeaMonkey.
+// See: https://bugzilla.mozilla.org/show_bug.cgi?id=jetpack-panel-apps
+module.metadata = {
+ "stability": "stable",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+const { Cu, Ci } = require("chrome");
+const { setTimeout } = require('./timers');
+const { Class } = require("./core/heritage");
+const { merge } = require("./util/object");
+const { WorkerHost } = require("./content/utils");
+const { Worker } = require("./deprecated/sync-worker");
+const { Disposable } = require("./core/disposable");
+const { WeakReference } = require('./core/reference');
+const { contract: loaderContract } = require("./content/loader");
+const { contract } = require("./util/contract");
+const { on, off, emit, setListeners } = require("./event/core");
+const { EventTarget } = require("./event/target");
+const domPanel = require("./panel/utils");
+const { getDocShell } = require('./frame/utils');
+const { events } = require("./panel/events");
+const systemEvents = require("./system/events");
+const { filter, pipe, stripListeners } = require("./event/utils");
+const { getNodeView, getActiveView } = require("./view/core");
+const { isNil, isObject, isNumber } = require("./lang/type");
+const { getAttachEventType } = require("./content/utils");
+const { number, boolean, object } = require('./deprecated/api-utils');
+const { Style } = require("./stylesheet/style");
+const { attach, detach } = require("./content/mod");
+
+var isRect = ({top, right, bottom, left}) => [top, right, bottom, left].
+ some(value => isNumber(value) && !isNaN(value));
+
+var isSDKObj = obj => obj instanceof Class;
+
+var rectContract = contract({
+ top: number,
+ right: number,
+ bottom: number,
+ left: number
+});
+
+var position = {
+ is: object,
+ map: v => (isNil(v) || isSDKObj(v) || !isObject(v)) ? v : rectContract(v),
+ ok: v => isNil(v) || isSDKObj(v) || (isObject(v) && isRect(v)),
+ msg: 'The option "position" must be a SDK object registered as anchor; ' +
+ 'or an object with one or more of the following keys set to numeric ' +
+ 'values: top, right, bottom, left.'
+}
+
+var displayContract = contract({
+ width: number,
+ height: number,
+ focus: boolean,
+ position: position
+});
+
+var panelContract = contract(merge({
+ // contentStyle* / contentScript* are sharing the same validation constraints,
+ // so they can be mostly reused, except for the messages.
+ contentStyle: merge(Object.create(loaderContract.rules.contentScript), {
+ msg: 'The `contentStyle` option must be a string or an array of strings.'
+ }),
+ contentStyleFile: merge(Object.create(loaderContract.rules.contentScriptFile), {
+ msg: 'The `contentStyleFile` option must be a local URL or an array of URLs'
+ }),
+ contextMenu: boolean,
+ allow: {
+ is: ['object', 'undefined', 'null'],
+ map: function (allow) { return { script: !allow || allow.script !== false }}
+ },
+}, displayContract.rules, loaderContract.rules));
+
+function Allow(panel) {
+ return {
+ get script() { return getDocShell(viewFor(panel).backgroundFrame).allowJavascript; },
+ set script(value) { return setScriptState(panel, value); },
+ };
+}
+
+function setScriptState(panel, value) {
+ let view = viewFor(panel);
+ getDocShell(view.backgroundFrame).allowJavascript = value;
+ getDocShell(view.viewFrame).allowJavascript = value;
+ view.setAttribute("sdkscriptenabled", "" + value);
+}
+
+function isDisposed(panel) {
+ return !views.has(panel);
+}
+
+var panels = new WeakMap();
+var models = new WeakMap();
+var views = new WeakMap();
+var workers = new WeakMap();
+var styles = new WeakMap();
+
+const viewFor = (panel) => views.get(panel);
+const modelFor = (panel) => models.get(panel);
+const panelFor = (view) => panels.get(view);
+const workerFor = (panel) => workers.get(panel);
+const styleFor = (panel) => styles.get(panel);
+
+function getPanelFromWeakRef(weakRef) {
+ if (!weakRef) {
+ return null;
+ }
+ let panel = weakRef.get();
+ if (!panel) {
+ return null;
+ }
+ if (isDisposed(panel)) {
+ return null;
+ }
+ return panel;
+}
+
+var SinglePanelManager = {
+ visiblePanel: null,
+ enqueuedPanel: null,
+ enqueuedPanelCallback: null,
+ // Calls |callback| with no arguments when the panel may be shown.
+ requestOpen: function(panelToOpen, callback) {
+ let currentPanel = getPanelFromWeakRef(SinglePanelManager.visiblePanel);
+ if (currentPanel || SinglePanelManager.enqueuedPanel) {
+ SinglePanelManager.enqueuedPanel = Cu.getWeakReference(panelToOpen);
+ SinglePanelManager.enqueuedPanelCallback = callback;
+ if (currentPanel && currentPanel.isShowing) {
+ currentPanel.hide();
+ }
+ } else {
+ SinglePanelManager.notifyPanelCanOpen(panelToOpen, callback);
+ }
+ },
+ notifyPanelCanOpen: function(panel, callback) {
+ let view = viewFor(panel);
+ // Can't pass an arrow function as the event handler because we need to be
+ // able to call |removeEventListener| later.
+ view.addEventListener("popuphidden", SinglePanelManager.onVisiblePanelHidden, true);
+ view.addEventListener("popupshown", SinglePanelManager.onVisiblePanelShown, false);
+ SinglePanelManager.enqueuedPanel = null;
+ SinglePanelManager.enqueuedPanelCallback = null;
+ SinglePanelManager.visiblePanel = Cu.getWeakReference(panel);
+ callback();
+ },
+ onVisiblePanelShown: function(event) {
+ let panel = panelFor(event.target);
+ if (SinglePanelManager.enqueuedPanel) {
+ // Another panel started waiting for |panel| to close before |panel| was
+ // even done opening.
+ panel.hide();
+ }
+ },
+ onVisiblePanelHidden: function(event) {
+ let view = event.target;
+ let panel = panelFor(view);
+ let currentPanel = getPanelFromWeakRef(SinglePanelManager.visiblePanel);
+ if (currentPanel && currentPanel != panel) {
+ return;
+ }
+ SinglePanelManager.visiblePanel = null;
+ view.removeEventListener("popuphidden", SinglePanelManager.onVisiblePanelHidden, true);
+ view.removeEventListener("popupshown", SinglePanelManager.onVisiblePanelShown, false);
+ let nextPanel = getPanelFromWeakRef(SinglePanelManager.enqueuedPanel);
+ let nextPanelCallback = SinglePanelManager.enqueuedPanelCallback;
+ if (nextPanel) {
+ SinglePanelManager.notifyPanelCanOpen(nextPanel, nextPanelCallback);
+ }
+ }
+};
+
+const Panel = Class({
+ implements: [
+ // Generate accessors for the validated properties that update model on
+ // set and return values from model on get.
+ panelContract.properties(modelFor),
+ EventTarget,
+ Disposable,
+ WeakReference
+ ],
+ extends: WorkerHost(workerFor),
+ setup: function setup(options) {
+ let model = merge({
+ defaultWidth: 320,
+ defaultHeight: 240,
+ focus: true,
+ position: Object.freeze({}),
+ contextMenu: false
+ }, panelContract(options));
+ model.ready = false;
+ models.set(this, model);
+
+ if (model.contentStyle || model.contentStyleFile) {
+ styles.set(this, Style({
+ uri: model.contentStyleFile,
+ source: model.contentStyle
+ }));
+ }
+
+ // Setup view
+ let viewOptions = {allowJavascript: !model.allow || (model.allow.script !== false)};
+ let view = domPanel.make(null, viewOptions);
+ panels.set(view, this);
+ views.set(this, view);
+
+ // Load panel content.
+ domPanel.setURL(view, model.contentURL);
+
+ // Allow context menu
+ domPanel.allowContextMenu(view, model.contextMenu);
+
+ // Setup listeners.
+ setListeners(this, options);
+ let worker = new Worker(stripListeners(options));
+ workers.set(this, worker);
+
+ // pipe events from worker to a panel.
+ pipe(worker, this);
+ },
+ dispose: function dispose() {
+ this.hide();
+ off(this);
+
+ workerFor(this).destroy();
+ detach(styleFor(this));
+
+ domPanel.dispose(viewFor(this));
+
+ // Release circular reference between view and panel instance. This
+ // way view will be GC-ed. And panel as well once all the other refs
+ // will be removed from it.
+ views.delete(this);
+ },
+ /* Public API: Panel.width */
+ get width() {
+ return modelFor(this).width;
+ },
+ set width(value) {
+ this.resize(value, this.height);
+ },
+ /* Public API: Panel.height */
+ get height() {
+ return modelFor(this).height;
+ },
+ set height(value) {
+ this.resize(this.width, value);
+ },
+
+ /* Public API: Panel.focus */
+ get focus() {
+ return modelFor(this).focus;
+ },
+
+ /* Public API: Panel.position */
+ get position() {
+ return modelFor(this).position;
+ },
+
+ /* Public API: Panel.contextMenu */
+ get contextMenu() {
+ return modelFor(this).contextMenu;
+ },
+ set contextMenu(allow) {
+ let model = modelFor(this);
+ model.contextMenu = panelContract({ contextMenu: allow }).contextMenu;
+ domPanel.allowContextMenu(viewFor(this), model.contextMenu);
+ },
+
+ get contentURL() {
+ return modelFor(this).contentURL;
+ },
+ set contentURL(value) {
+ let model = modelFor(this);
+ model.contentURL = panelContract({ contentURL: value }).contentURL;
+ domPanel.setURL(viewFor(this), model.contentURL);
+ // Detach worker so that messages send will be queued until it's
+ // reatached once panel content is ready.
+ workerFor(this).detach();
+ },
+
+ get allow() { return Allow(this); },
+ set allow(value) {
+ let allowJavascript = panelContract({ allow: value }).allow.script;
+ return setScriptState(this, value);
+ },
+
+ /* Public API: Panel.isShowing */
+ get isShowing() {
+ return !isDisposed(this) && domPanel.isOpen(viewFor(this));
+ },
+
+ /* Public API: Panel.show */
+ show: function show(options={}, anchor) {
+ SinglePanelManager.requestOpen(this, () => {
+ if (options instanceof Ci.nsIDOMElement) {
+ [anchor, options] = [options, null];
+ }
+
+ if (anchor instanceof Ci.nsIDOMElement) {
+ console.warn(
+ "Passing a DOM node to Panel.show() method is an unsupported " +
+ "feature that will be soon replaced. " +
+ "See: https://bugzilla.mozilla.org/show_bug.cgi?id=878877"
+ );
+ }
+
+ let model = modelFor(this);
+ let view = viewFor(this);
+ let anchorView = getNodeView(anchor || options.position || model.position);
+
+ options = merge({
+ position: model.position,
+ width: model.width,
+ height: model.height,
+ defaultWidth: model.defaultWidth,
+ defaultHeight: model.defaultHeight,
+ focus: model.focus,
+ contextMenu: model.contextMenu
+ }, displayContract(options));
+
+ if (!isDisposed(this)) {
+ domPanel.show(view, options, anchorView);
+ }
+ });
+ return this;
+ },
+
+ /* Public API: Panel.hide */
+ hide: function hide() {
+ // Quit immediately if panel is disposed or there is no state change.
+ domPanel.close(viewFor(this));
+
+ return this;
+ },
+
+ /* Public API: Panel.resize */
+ resize: function resize(width, height) {
+ let model = modelFor(this);
+ let view = viewFor(this);
+ let change = panelContract({
+ width: width || model.width || model.defaultWidth,
+ height: height || model.height || model.defaultHeight
+ });
+
+ model.width = change.width
+ model.height = change.height
+
+ domPanel.resize(view, model.width, model.height);
+
+ return this;
+ }
+});
+exports.Panel = Panel;
+
+// Note must be defined only after value to `Panel` is assigned.
+getActiveView.define(Panel, viewFor);
+
+// Filter panel events to only panels that are create by this module.
+var panelEvents = filter(events, ({target}) => panelFor(target));
+
+// Panel events emitted after panel has being shown.
+var shows = filter(panelEvents, ({type}) => type === "popupshown");
+
+// Panel events emitted after panel became hidden.
+var hides = filter(panelEvents, ({type}) => type === "popuphidden");
+
+// Panel events emitted after content inside panel is ready. For different
+// panels ready may mean different state based on `contentScriptWhen` attribute.
+// Weather given event represents readyness is detected by `getAttachEventType`
+// helper function.
+var ready = filter(panelEvents, ({type, target}) =>
+ getAttachEventType(modelFor(panelFor(target))) === type);
+
+// Panel event emitted when the contents of the panel has been loaded.
+var readyToShow = filter(panelEvents, ({type}) => type === "DOMContentLoaded");
+
+// Styles should be always added as soon as possible, and doesn't makes them
+// depends on `contentScriptWhen`
+var start = filter(panelEvents, ({type}) => type === "document-element-inserted");
+
+// Forward panel show / hide events to panel's own event listeners.
+on(shows, "data", ({target}) => {
+ let panel = panelFor(target);
+ if (modelFor(panel).ready)
+ emit(panel, "show");
+});
+
+on(hides, "data", ({target}) => {
+ let panel = panelFor(target);
+ if (modelFor(panel).ready)
+ emit(panel, "hide");
+});
+
+on(ready, "data", ({target}) => {
+ let panel = panelFor(target);
+ let window = domPanel.getContentDocument(target).defaultView;
+
+ workerFor(panel).attach(window);
+});
+
+on(readyToShow, "data", ({target}) => {
+ let panel = panelFor(target);
+
+ if (!modelFor(panel).ready) {
+ modelFor(panel).ready = true;
+
+ if (viewFor(panel).state == "open")
+ emit(panel, "show");
+ }
+});
+
+on(start, "data", ({target}) => {
+ let panel = panelFor(target);
+ let window = domPanel.getContentDocument(target).defaultView;
+
+ attach(styleFor(panel), window);
+});
diff --git a/toolkit/jetpack/sdk/panel/events.js b/toolkit/jetpack/sdk/panel/events.js
new file mode 100644
index 000000000..f3040a11d
--- /dev/null
+++ b/toolkit/jetpack/sdk/panel/events.js
@@ -0,0 +1,27 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+// This module basically translates system/events to a SDK standard events
+// so that `map`, `filter` and other utilities could be used with them.
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const events = require("../system/events");
+const { emit } = require("../event/core");
+
+var channel = {};
+
+function forward({ subject, type, data }) {
+ return emit(channel, "data", { target: subject, type: type, data: data });
+}
+
+["popupshowing", "popuphiding", "popupshown", "popuphidden",
+"document-element-inserted", "DOMContentLoaded", "load"
+].forEach(type => events.on(type, forward));
+
+exports.events = channel;
diff --git a/toolkit/jetpack/sdk/panel/utils.js b/toolkit/jetpack/sdk/panel/utils.js
new file mode 100644
index 000000000..c85b274bc
--- /dev/null
+++ b/toolkit/jetpack/sdk/panel/utils.js
@@ -0,0 +1,451 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci } = require("chrome");
+const { Services } = require("resource://gre/modules/Services.jsm");
+const { setTimeout } = require("../timers");
+const { platform } = require("../system");
+const { getMostRecentBrowserWindow, getOwnerBrowserWindow,
+ getHiddenWindow, getScreenPixelsPerCSSPixel } = require("../window/utils");
+
+const { create: createFrame, swapFrameLoaders, getDocShell } = require("../frame/utils");
+const { window: addonWindow } = require("../addon/window");
+const { isNil } = require("../lang/type");
+const { data } = require('../self');
+
+const events = require("../system/events");
+
+
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+
+function calculateRegion({ position, width, height, defaultWidth, defaultHeight }, rect) {
+ position = position || {};
+
+ let x, y;
+
+ let hasTop = !isNil(position.top);
+ let hasRight = !isNil(position.right);
+ let hasBottom = !isNil(position.bottom);
+ let hasLeft = !isNil(position.left);
+ let hasWidth = !isNil(width);
+ let hasHeight = !isNil(height);
+
+ // if width is not specified by constructor or show's options, then get
+ // the default width
+ if (!hasWidth)
+ width = defaultWidth;
+
+ // if height is not specified by constructor or show's options, then get
+ // the default height
+ if (!hasHeight)
+ height = defaultHeight;
+
+ // default position is centered
+ x = (rect.right - width) / 2;
+ y = (rect.top + rect.bottom - height) / 2;
+
+ if (hasTop) {
+ y = rect.top + position.top;
+
+ if (hasBottom && !hasHeight)
+ height = rect.bottom - position.bottom - y;
+ }
+ else if (hasBottom) {
+ y = rect.bottom - position.bottom - height;
+ }
+
+ if (hasLeft) {
+ x = position.left;
+
+ if (hasRight && !hasWidth)
+ width = rect.right - position.right - x;
+ }
+ else if (hasRight) {
+ x = rect.right - width - position.right;
+ }
+
+ return {x: x, y: y, width: width, height: height};
+}
+
+function open(panel, options, anchor) {
+ // Wait for the XBL binding to be constructed
+ if (!panel.openPopup) setTimeout(open, 50, panel, options, anchor);
+ else display(panel, options, anchor);
+}
+exports.open = open;
+
+function isOpen(panel) {
+ return panel.state === "open"
+}
+exports.isOpen = isOpen;
+
+function isOpening(panel) {
+ return panel.state === "showing"
+}
+exports.isOpening = isOpening
+
+function close(panel) {
+ // Sometimes "TypeError: panel.hidePopup is not a function" is thrown
+ // when quitting the host application while a panel is visible. To suppress
+ // these errors, check for "hidePopup" in panel before calling it.
+ // It's not clear if there's an issue or it's expected behavior.
+ // See Bug 1151796.
+
+ return panel.hidePopup && panel.hidePopup();
+}
+exports.close = close
+
+
+function resize(panel, width, height) {
+ // Resize the iframe instead of using panel.sizeTo
+ // because sizeTo doesn't work with arrow panels
+ if (panel.firstChild) {
+ panel.firstChild.style.width = width + "px";
+ panel.firstChild.style.height = height + "px";
+ }
+}
+exports.resize = resize
+
+function display(panel, options, anchor) {
+ let document = panel.ownerDocument;
+
+ let x, y;
+ let { width, height, defaultWidth, defaultHeight } = options;
+
+ let popupPosition = null;
+
+ // Panel XBL has some SDK incompatible styling decisions. We shim panel
+ // instances until proper fix for Bug 859504 is shipped.
+ shimDefaultStyle(panel);
+
+ if (!anchor) {
+ // The XUL Panel doesn't have an arrow, so the margin needs to be reset
+ // in order to, be positioned properly
+ panel.style.margin = "0";
+
+ let viewportRect = document.defaultView.gBrowser.getBoundingClientRect();
+
+ ({x, y, width, height} = calculateRegion(options, viewportRect));
+ }
+ else {
+ // The XUL Panel has an arrow, so the margin needs to be reset
+ // to the default value.
+ panel.style.margin = "";
+ let { CustomizableUI, window } = anchor.ownerDocument.defaultView;
+
+ // In Australis, widgets may be positioned in an overflow panel or the
+ // menu panel.
+ // In such cases clicking this widget will hide the overflow/menu panel,
+ // and the widget's panel will show instead.
+ // If `CustomizableUI` is not available, it means the anchor is not in a
+ // chrome browser window, and therefore there is no need for this check.
+ if (CustomizableUI) {
+ let node = anchor;
+ ({anchor} = CustomizableUI.getWidget(anchor.id).forWindow(window));
+
+ // if `node` is not the `anchor` itself, it means the widget is
+ // positioned in a panel, therefore we have to hide it before show
+ // the widget's panel in the same anchor
+ if (node !== anchor)
+ CustomizableUI.hidePanelForNode(anchor);
+ }
+
+ width = width || defaultWidth;
+ height = height || defaultHeight;
+
+ // Open the popup by the anchor.
+ let rect = anchor.getBoundingClientRect();
+
+ let zoom = getScreenPixelsPerCSSPixel(window);
+ let screenX = rect.left + window.mozInnerScreenX * zoom;
+ let screenY = rect.top + window.mozInnerScreenY * zoom;
+
+ // Set up the vertical position of the popup relative to the anchor
+ // (always display the arrow on anchor center)
+ let horizontal, vertical;
+ if (screenY > window.screen.availHeight / 2 + height)
+ vertical = "top";
+ else
+ vertical = "bottom";
+
+ if (screenY > window.screen.availWidth / 2 + width)
+ horizontal = "left";
+ else
+ horizontal = "right";
+
+ let verticalInverse = vertical == "top" ? "bottom" : "top";
+ popupPosition = vertical + "center " + verticalInverse + horizontal;
+
+ // Allow panel to flip itself if the panel can't be displayed at the
+ // specified position (useful if we compute a bad position or if the
+ // user moves the window and panel remains visible)
+ panel.setAttribute("flip", "both");
+ }
+
+ if (!panel.viewFrame) {
+ panel.viewFrame = document.importNode(panel.backgroundFrame, false);
+ panel.appendChild(panel.viewFrame);
+
+ let {privateBrowsingId} = getDocShell(panel.viewFrame).getOriginAttributes();
+ let principal = Services.scriptSecurityManager.createNullPrincipal({privateBrowsingId});
+ getDocShell(panel.viewFrame).createAboutBlankContentViewer(principal);
+ }
+
+ // Resize the iframe instead of using panel.sizeTo
+ // because sizeTo doesn't work with arrow panels
+ panel.firstChild.style.width = width + "px";
+ panel.firstChild.style.height = height + "px";
+
+ panel.openPopup(anchor, popupPosition, x, y);
+}
+exports.display = display;
+
+// This utility function is just a workaround until Bug 859504 has shipped.
+function shimDefaultStyle(panel) {
+ let document = panel.ownerDocument;
+ // Please note that `panel` needs to be part of document in order to reach
+ // it's anonymous nodes. One of the anonymous node has a big padding which
+ // doesn't work well since panel frame needs to fill all of the panel.
+ // XBL binding is a not the best option as it's applied asynchronously, and
+ // makes injected frames behave in strange way. Also this feels a lot
+ // cheaper to do.
+ ["panel-inner-arrowcontent", "panel-arrowcontent"].forEach(function(value) {
+ let node = document.getAnonymousElementByAttribute(panel, "class", value);
+ if (node) node.style.padding = 0;
+ });
+}
+
+function show(panel, options, anchor) {
+ // Prevent the panel from getting focus when showing up
+ // if focus is set to false
+ panel.setAttribute("noautofocus", !options.focus);
+
+ let window = anchor && getOwnerBrowserWindow(anchor);
+ let { document } = window ? window : getMostRecentBrowserWindow();
+ attach(panel, document);
+
+ open(panel, options, anchor);
+}
+exports.show = show
+
+function onPanelClick(event) {
+ let { target, metaKey, ctrlKey, shiftKey, button } = event;
+ let accel = platform === "darwin" ? metaKey : ctrlKey;
+ let isLeftClick = button === 0;
+ let isMiddleClick = button === 1;
+
+ if ((isLeftClick && (accel || shiftKey)) || isMiddleClick) {
+ let link = target.closest('a');
+
+ if (link && link.href)
+ getMostRecentBrowserWindow().openUILink(link.href, event)
+ }
+}
+
+function setupPanelFrame(frame) {
+ frame.setAttribute("flex", 1);
+ frame.setAttribute("transparent", "transparent");
+ frame.setAttribute("autocompleteenabled", true);
+ frame.setAttribute("tooltip", "aHTMLTooltip");
+ if (platform === "darwin") {
+ frame.style.borderRadius = "var(--arrowpanel-border-radius, 3.5px)";
+ frame.style.padding = "1px";
+ }
+}
+
+function make(document, options) {
+ document = document || getMostRecentBrowserWindow().document;
+ let panel = document.createElementNS(XUL_NS, "panel");
+ panel.setAttribute("type", "arrow");
+ panel.setAttribute("sdkscriptenabled", options.allowJavascript);
+
+ // The panel needs to be attached to a browser window in order for us
+ // to copy browser styles to the content document when it loads.
+ attach(panel, document);
+
+ let frameOptions = {
+ allowJavascript: options.allowJavascript,
+ allowPlugins: true,
+ allowAuth: true,
+ allowWindowControl: false,
+ // Need to override `nodeName` to use `iframe` as `browsers` save session
+ // history and in consequence do not dispatch "inner-window-destroyed"
+ // notifications.
+ browser: false,
+ };
+
+ let backgroundFrame = createFrame(addonWindow, frameOptions);
+ setupPanelFrame(backgroundFrame);
+
+ getDocShell(backgroundFrame).inheritPrivateBrowsingId = false;
+
+ function onPopupShowing({type, target}) {
+ if (target === this) {
+ let attrs = getDocShell(backgroundFrame).getOriginAttributes();
+ getDocShell(panel.viewFrame).setOriginAttributes(attrs);
+
+ swapFrameLoaders(backgroundFrame, panel.viewFrame);
+ }
+ }
+
+ function onPopupHiding({type, target}) {
+ if (target === this) {
+ swapFrameLoaders(backgroundFrame, panel.viewFrame);
+
+ panel.viewFrame.remove();
+ panel.viewFrame = null;
+ }
+ }
+
+ function onContentReady({target, type}) {
+ if (target === getContentDocument(panel)) {
+ style(panel);
+ events.emit(type, { subject: panel });
+ }
+ }
+
+ function onContentLoad({target, type}) {
+ if (target === getContentDocument(panel))
+ events.emit(type, { subject: panel });
+ }
+
+ function onContentChange({subject: document, type}) {
+ if (document === getContentDocument(panel) && document.defaultView)
+ events.emit(type, { subject: panel });
+ }
+
+ function onPanelStateChange({target, type}) {
+ if (target === this)
+ events.emit(type, { subject: panel })
+ }
+
+ panel.addEventListener("popupshowing", onPopupShowing);
+ panel.addEventListener("popuphiding", onPopupHiding);
+ for (let event of ["popupshowing", "popuphiding", "popupshown", "popuphidden"])
+ panel.addEventListener(event, onPanelStateChange);
+
+ panel.addEventListener("click", onPanelClick, false);
+
+ // Panel content document can be either in panel `viewFrame` or in
+ // a `backgroundFrame` depending on panel state. Listeners are set
+ // on both to avoid setting and removing listeners on panel state changes.
+
+ panel.addEventListener("DOMContentLoaded", onContentReady, true);
+ backgroundFrame.addEventListener("DOMContentLoaded", onContentReady, true);
+
+ panel.addEventListener("load", onContentLoad, true);
+ backgroundFrame.addEventListener("load", onContentLoad, true);
+
+ events.on("document-element-inserted", onContentChange);
+
+ panel.backgroundFrame = backgroundFrame;
+ panel.viewFrame = null;
+
+ // Store event listener on the panel instance so that it won't be GC-ed
+ // while panel is alive.
+ panel.onContentChange = onContentChange;
+
+ return panel;
+}
+exports.make = make;
+
+function attach(panel, document) {
+ document = document || getMostRecentBrowserWindow().document;
+ let container = document.getElementById("mainPopupSet");
+ if (container !== panel.parentNode) {
+ detach(panel);
+ document.getElementById("mainPopupSet").appendChild(panel);
+ }
+}
+exports.attach = attach;
+
+function detach(panel) {
+ if (panel.parentNode) panel.parentNode.removeChild(panel);
+}
+exports.detach = detach;
+
+function dispose(panel) {
+ panel.backgroundFrame.remove();
+ panel.backgroundFrame = null;
+ events.off("document-element-inserted", panel.onContentChange);
+ panel.onContentChange = null;
+ detach(panel);
+}
+exports.dispose = dispose;
+
+function style(panel) {
+ /**
+ Injects default OS specific panel styles into content document that is loaded
+ into given panel. Optionally `document` of the browser window can be
+ given to inherit styles from it, by default it will use either panel owner
+ document or an active browser's document. It should not matter though unless
+ Firefox decides to style windows differently base on profile or mode like
+ chrome for example.
+ **/
+
+ try {
+ let document = panel.ownerDocument;
+ let contentDocument = getContentDocument(panel);
+ let window = document.defaultView;
+ let node = document.getAnonymousElementByAttribute(panel, "class",
+ "panel-arrowcontent");
+
+ let { color, fontFamily, fontSize, fontWeight } = window.getComputedStyle(node);
+
+ let style = contentDocument.createElement("style");
+ style.id = "sdk-panel-style";
+ style.textContent = "body { " +
+ "color: " + color + ";" +
+ "font-family: " + fontFamily + ";" +
+ "font-weight: " + fontWeight + ";" +
+ "font-size: " + fontSize + ";" +
+ "}";
+
+ let container = contentDocument.head ? contentDocument.head :
+ contentDocument.documentElement;
+
+ if (container.firstChild)
+ container.insertBefore(style, container.firstChild);
+ else
+ container.appendChild(style);
+ }
+ catch (error) {
+ console.error("Unable to apply panel style");
+ console.exception(error);
+ }
+}
+exports.style = style;
+
+var getContentFrame = panel => panel.viewFrame || panel.backgroundFrame;
+exports.getContentFrame = getContentFrame;
+
+function getContentDocument(panel) {
+ return getContentFrame(panel).contentDocument;
+}
+exports.getContentDocument = getContentDocument;
+
+function setURL(panel, url) {
+ let frame = getContentFrame(panel);
+ let webNav = getDocShell(frame).QueryInterface(Ci.nsIWebNavigation);
+
+ webNav.loadURI(url ? data.url(url) : "about:blank", 0, null, null, null);
+}
+
+exports.setURL = setURL;
+
+function allowContextMenu(panel, allow) {
+ if (allow) {
+ panel.setAttribute("context", "contentAreaContextMenu");
+ }
+ else {
+ panel.removeAttribute("context");
+ }
+}
+exports.allowContextMenu = allowContextMenu;
diff --git a/toolkit/jetpack/sdk/passwords.js b/toolkit/jetpack/sdk/passwords.js
new file mode 100644
index 000000000..70f0aa4da
--- /dev/null
+++ b/toolkit/jetpack/sdk/passwords.js
@@ -0,0 +1,61 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { search, remove, store } = require("./passwords/utils");
+const { defer, delay } = require("./lang/functional");
+
+/**
+ * Utility function that returns `onComplete` and `onError` callbacks form the
+ * given `options` objects. Also properties are removed from the passed
+ * `options` objects.
+ * @param {Object} options
+ * Object that is passed to the exported functions of this module.
+ * @returns {Function[]}
+ * Array with two elements `onComplete` and `onError` functions.
+ */
+function getCallbacks(options) {
+ let value = [
+ 'onComplete' in options ? options.onComplete : null,
+ 'onError' in options ? defer(options.onError) : console.exception
+ ];
+
+ delete options.onComplete;
+ delete options.onError;
+
+ return value;
+};
+
+/**
+ * Creates a wrapper function that tries to call `onComplete` with a return
+ * value of the wrapped function or falls back to `onError` if wrapped function
+ * throws an exception.
+ */
+function createWrapperMethod(wrapped) {
+ return function (options) {
+ let [ onComplete, onError ] = getCallbacks(options);
+ try {
+ let value = wrapped(options);
+ if (onComplete) {
+ delay(function() {
+ try {
+ onComplete(value);
+ } catch (exception) {
+ onError(exception);
+ }
+ });
+ }
+ } catch (exception) {
+ onError(exception);
+ }
+ };
+}
+
+exports.search = createWrapperMethod(search);
+exports.store = createWrapperMethod(store);
+exports.remove = createWrapperMethod(remove);
diff --git a/toolkit/jetpack/sdk/passwords/utils.js b/toolkit/jetpack/sdk/passwords/utils.js
new file mode 100644
index 000000000..334efa490
--- /dev/null
+++ b/toolkit/jetpack/sdk/passwords/utils.js
@@ -0,0 +1,107 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci, CC } = require("chrome");
+const { uri: ADDON_URI } = require("../self");
+const loginManager = Cc["@mozilla.org/login-manager;1"].
+ getService(Ci.nsILoginManager);
+const { URL: parseURL } = require("../url");
+const LoginInfo = CC("@mozilla.org/login-manager/loginInfo;1",
+ "nsILoginInfo", "init");
+
+function filterMatchingLogins(loginInfo) {
+ return Object.keys(this).every(key => loginInfo[key] === this[key], this);
+}
+
+/**
+ * Removes `user`, `password` and `path` fields from the given `url` if it's
+ * 'http', 'https' or 'ftp'. All other URLs are returned unchanged.
+ * @example
+ * http://user:pass@www.site.com/foo/?bar=baz#bang -> http://www.site.com
+ */
+function normalizeURL(url) {
+ let { scheme, host, port } = parseURL(url);
+ // We normalize URL only if it's `http`, `https` or `ftp`. All other types of
+ // URLs (`resource`, `chrome`, etc..) should not be normalized as they are
+ // used with add-on associated credentials path.
+ return scheme === "http" || scheme === "https" || scheme === "ftp" ?
+ scheme + "://" + (host || "") + (port ? ":" + port : "") :
+ url
+}
+
+function Login(options) {
+ let login = Object.create(Login.prototype);
+ Object.keys(options || {}).forEach(function(key) {
+ if (key === 'url')
+ login.hostname = normalizeURL(options.url);
+ else if (key === 'formSubmitURL')
+ login.formSubmitURL = options.formSubmitURL ?
+ normalizeURL(options.formSubmitURL) : null;
+ else if (key === 'realm')
+ login.httpRealm = options.realm;
+ else
+ login[key] = options[key];
+ });
+
+ return login;
+}
+Login.prototype.toJSON = function toJSON() {
+ return {
+ url: this.hostname || ADDON_URI,
+ realm: this.httpRealm || null,
+ formSubmitURL: this.formSubmitURL || null,
+ username: this.username || null,
+ password: this.password || null,
+ usernameField: this.usernameField || '',
+ passwordField: this.passwordField || '',
+ }
+};
+Login.prototype.toLoginInfo = function toLoginInfo() {
+ let { url, realm, formSubmitURL, username, password, usernameField,
+ passwordField } = this.toJSON();
+
+ return new LoginInfo(url, formSubmitURL, realm, username, password,
+ usernameField, passwordField);
+};
+
+function loginToJSON(value) {
+ return Login(value).toJSON();
+}
+
+/**
+ * Returns array of `nsILoginInfo` objects that are stored in the login manager
+ * and have all the properties with matching values as a given `options` object.
+ * @param {Object} options
+ * @returns {nsILoginInfo[]}
+ */
+exports.search = function search(options) {
+ return loginManager.getAllLogins()
+ .filter(filterMatchingLogins, Login(options))
+ .map(loginToJSON);
+};
+
+/**
+ * Stores login info created from the given `options` to the applications
+ * built-in login management system.
+ * @param {Object} options.
+ */
+exports.store = function store(options) {
+ loginManager.addLogin(Login(options).toLoginInfo());
+};
+
+/**
+ * Removes login info from the applications built-in login management system.
+ * _Please note: When removing a login info the specified properties must
+ * exactly match to the one that is already stored or exception will be thrown._
+ * @param {Object} options.
+ */
+exports.remove = function remove(options) {
+ loginManager.removeLogin(Login(options).toLoginInfo());
+};
diff --git a/toolkit/jetpack/sdk/places/bookmarks.js b/toolkit/jetpack/sdk/places/bookmarks.js
new file mode 100644
index 000000000..c4f9528f1
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/bookmarks.js
@@ -0,0 +1,395 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+/*
+ * Requiring hosts so they can subscribe to client messages
+ */
+require('./host/host-bookmarks');
+require('./host/host-tags');
+require('./host/host-query');
+
+const { Cc, Ci } = require('chrome');
+const { Class } = require('../core/heritage');
+const { send } = require('../addon/events');
+const { defer, reject, all, resolve, promised } = require('../core/promise');
+const { EventTarget } = require('../event/target');
+const { emit } = require('../event/core');
+const { identity, defer:async } = require('../lang/functional');
+const { extend, merge } = require('../util/object');
+const { fromIterator } = require('../util/array');
+const {
+ constructTree, fetchItem, createQuery,
+ isRootGroup, createQueryOptions
+} = require('./utils');
+const {
+ bookmarkContract, groupContract, separatorContract
+} = require('./contract');
+const bmsrv = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
+ getService(Ci.nsINavBookmarksService);
+
+/*
+ * Mapping of uncreated bookmarks with their created
+ * counterparts
+ */
+const itemMap = new WeakMap();
+
+/*
+ * Constant used by nsIHistoryQuery; 1 is a bookmark query
+ * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryQueryOptions
+ */
+const BOOKMARK_QUERY = 1;
+
+/*
+ * Bookmark Item classes
+ */
+
+const Bookmark = Class({
+ extends: [
+ bookmarkContract.properties(identity)
+ ],
+ initialize: function initialize (options) {
+ merge(this, bookmarkContract(extend(defaults, options)));
+ },
+ type: 'bookmark',
+ toString: () => '[object Bookmark]'
+});
+exports.Bookmark = Bookmark;
+
+const Group = Class({
+ extends: [
+ groupContract.properties(identity)
+ ],
+ initialize: function initialize (options) {
+ // Don't validate if root group
+ if (isRootGroup(options))
+ merge(this, options);
+ else
+ merge(this, groupContract(extend(defaults, options)));
+ },
+ type: 'group',
+ toString: () => '[object Group]'
+});
+exports.Group = Group;
+
+const Separator = Class({
+ extends: [
+ separatorContract.properties(identity)
+ ],
+ initialize: function initialize (options) {
+ merge(this, separatorContract(extend(defaults, options)));
+ },
+ type: 'separator',
+ toString: () => '[object Separator]'
+});
+exports.Separator = Separator;
+
+/*
+ * Functions
+ */
+
+function save (items, options) {
+ items = [].concat(items);
+ options = options || {};
+ let emitter = EventTarget();
+ let results = [];
+ let errors = [];
+ let root = constructTree(items);
+ let cache = new Map();
+
+ let isExplicitSave = item => !!~items.indexOf(item);
+ // `walk` returns an aggregate promise indicating the completion
+ // of the `commitItem` on each node, not whether or not that
+ // commit was successful
+
+ // Force this to be async, as if a ducktype fails validation,
+ // the promise implementation will fire an error event, which will
+ // not trigger the handler as it's not yet bound
+ //
+ // Can remove after `Promise.jsm` is implemented in Bug 881047,
+ // which will guarantee next tick execution
+ async(() => root.walk(preCommitItem).then(commitComplete))();
+
+ function preCommitItem ({value:item}) {
+ // Do nothing if tree root, default group (unsavable),
+ // or if it's a dependency and not explicitly saved (in the list
+ // of items to be saved), and not needed to be saved
+ if (item === null || // node is the tree root
+ isRootGroup(item) ||
+ (getId(item) && !isExplicitSave(item)))
+ return;
+
+ return promised(validate)(item)
+ .then(() => commitItem(item, options))
+ .then(data => construct(data, cache))
+ .then(savedItem => {
+ // If item was just created, make a map between
+ // the creation object and created object,
+ // so we can reference the item that doesn't have an id
+ if (!getId(item))
+ saveId(item, savedItem.id);
+
+ // Emit both the processed item, and original item
+ // so a mapping can be understood in handler
+ emit(emitter, 'data', savedItem, item);
+
+ // Push to results iff item was explicitly saved
+ if (isExplicitSave(item))
+ results[items.indexOf(item)] = savedItem;
+ }, reason => {
+ // Force reason to be a string for consistency
+ reason = reason + '';
+ // Emit both the reason, and original item
+ // so a mapping can be understood in handler
+ emit(emitter, 'error', reason + '', item);
+ // Store unsaved item in results list
+ results[items.indexOf(item)] = item;
+ errors.push(reason);
+ });
+ }
+
+ // Called when traversal of the node tree is completed and all
+ // items have been committed
+ function commitComplete () {
+ emit(emitter, 'end', results);
+ }
+
+ return emitter;
+}
+exports.save = save;
+
+function search (queries, options) {
+ queries = [].concat(queries);
+ let emitter = EventTarget();
+ let cache = new Map();
+ let queryObjs = queries.map(createQuery.bind(null, BOOKMARK_QUERY));
+ let optionsObj = createQueryOptions(BOOKMARK_QUERY, options);
+
+ // Can remove after `Promise.jsm` is implemented in Bug 881047,
+ // which will guarantee next tick execution
+ async(() => {
+ send('sdk-places-query', { queries: queryObjs, options: optionsObj })
+ .then(handleQueryResponse);
+ })();
+
+ function handleQueryResponse (data) {
+ let deferreds = data.map(item => {
+ return construct(item, cache).then(bookmark => {
+ emit(emitter, 'data', bookmark);
+ return bookmark;
+ }, reason => {
+ emit(emitter, 'error', reason);
+ errors.push(reason);
+ });
+ });
+
+ all(deferreds).then(data => {
+ emit(emitter, 'end', data);
+ }, () => emit(emitter, 'end', []));
+ }
+
+ return emitter;
+}
+exports.search = search;
+
+function remove (items) {
+ return [].concat(items).map(item => {
+ item.remove = true;
+ return item;
+ });
+}
+
+exports.remove = remove;
+
+/*
+ * Internal Utilities
+ */
+
+function commitItem (item, options) {
+ // Get the item's ID, or getId it's saved version if it exists
+ let id = getId(item);
+ let data = normalize(item);
+ let promise;
+
+ data.id = id;
+
+ if (!id) {
+ promise = send('sdk-places-bookmarks-create', data);
+ } else if (item.remove) {
+ promise = send('sdk-places-bookmarks-remove', { id: id });
+ } else {
+ promise = send('sdk-places-bookmarks-last-updated', {
+ id: id
+ }).then(function (updated) {
+ // If attempting to save an item that is not the
+ // latest snapshot of a bookmark item, execute
+ // the resolution function
+ if (updated !== item.updated && options.resolve)
+ return fetchItem(id)
+ .then(options.resolve.bind(null, data));
+ else
+ return data;
+ }).then(send.bind(null, 'sdk-places-bookmarks-save'));
+ }
+
+ return promise;
+}
+
+/*
+ * Turns a bookmark item into a plain object,
+ * converts `tags` from Set to Array, group instance to an id
+ */
+function normalize (item) {
+ let data = merge({}, item);
+ // Circumvent prototype property of `type`
+ delete data.type;
+ data.type = item.type;
+ data.tags = [];
+ if (item.tags) {
+ data.tags = fromIterator(item.tags);
+ }
+ data.group = getId(data.group) || exports.UNSORTED.id;
+
+ return data;
+}
+
+/*
+ * Takes a data object and constructs a BookmarkItem instance
+ * of it, recursively generating parent instances as well.
+ *
+ * Pass in a `cache` Map to reuse instances of
+ * bookmark items to reduce overhead;
+ * The cache object is a map of id to a deferred with a
+ * promise that resolves to the bookmark item.
+ */
+function construct (object, cache, forced) {
+ let item = instantiate(object);
+ let deferred = defer();
+
+ // Item could not be instantiated
+ if (!item)
+ return resolve(null);
+
+ // Return promise for item if found in the cache,
+ // and not `forced`. `forced` indicates that this is the construct
+ // call that should not read from cache, but should actually perform
+ // the construction, as it was set before several async calls
+ if (cache.has(item.id) && !forced)
+ return cache.get(item.id).promise;
+ else if (cache.has(item.id))
+ deferred = cache.get(item.id);
+ else
+ cache.set(item.id, deferred);
+
+ // When parent group is found in cache, use
+ // the same deferred value
+ if (item.group && cache.has(item.group)) {
+ cache.get(item.group).promise.then(group => {
+ item.group = group;
+ deferred.resolve(item);
+ });
+
+ // If not in the cache, and a root group, return
+ // the premade instance
+ } else if (rootGroups.get(item.group)) {
+ item.group = rootGroups.get(item.group);
+ deferred.resolve(item);
+
+ // If not in the cache or a root group, fetch the parent
+ } else {
+ cache.set(item.group, defer());
+ fetchItem(item.group).then(group => {
+ return construct(group, cache, true);
+ }).then(group => {
+ item.group = group;
+ deferred.resolve(item);
+ }, deferred.reject);
+ }
+
+ return deferred.promise;
+}
+
+function instantiate (object) {
+ if (object.type === 'bookmark')
+ return Bookmark(object);
+ if (object.type === 'group')
+ return Group(object);
+ if (object.type === 'separator')
+ return Separator(object);
+ return null;
+}
+
+/**
+ * Validates a bookmark item; will throw an error if ininvalid,
+ * to be used with `promised`. As bookmark items check on their class,
+ * this only checks ducktypes
+ */
+function validate (object) {
+ if (!isDuckType(object)) return true;
+ let contract = object.type === 'bookmark' ? bookmarkContract :
+ object.type === 'group' ? groupContract :
+ object.type === 'separator' ? separatorContract :
+ null;
+ if (!contract) {
+ throw Error('No type specified');
+ }
+
+ // If object has a property set, and undefined,
+ // manually override with default as it'll fail otherwise
+ let withDefaults = Object.keys(defaults).reduce((obj, prop) => {
+ if (obj[prop] == null) obj[prop] = defaults[prop];
+ return obj;
+ }, extend(object));
+
+ contract(withDefaults);
+}
+
+function isDuckType (item) {
+ return !(item instanceof Bookmark) &&
+ !(item instanceof Group) &&
+ !(item instanceof Separator);
+}
+
+function saveId (unsaved, id) {
+ itemMap.set(unsaved, id);
+}
+
+// Fetches an item's ID from itself, or from the mapped items
+function getId (item) {
+ return typeof item === 'number' ? item :
+ item ? item.id || itemMap.get(item) :
+ null;
+}
+
+/*
+ * Set up the default, root groups
+ */
+
+var defaultGroupMap = {
+ MENU: bmsrv.bookmarksMenuFolder,
+ TOOLBAR: bmsrv.toolbarFolder,
+ UNSORTED: bmsrv.unfiledBookmarksFolder
+};
+
+var rootGroups = new Map();
+
+for (let i in defaultGroupMap) {
+ let group = Object.freeze(Group({ title: i, id: defaultGroupMap[i] }));
+ rootGroups.set(defaultGroupMap[i], group);
+ exports[i] = group;
+}
+
+var defaults = {
+ group: exports.UNSORTED,
+ index: -1
+};
diff --git a/toolkit/jetpack/sdk/places/contract.js b/toolkit/jetpack/sdk/places/contract.js
new file mode 100644
index 000000000..a3541c34d
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/contract.js
@@ -0,0 +1,73 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci } = require('chrome');
+const { isValidURI, URL } = require('../url');
+const { contract } = require('../util/contract');
+const { extend } = require('../util/object');
+
+// map of property validations
+const validItem = {
+ id: {
+ is: ['number', 'undefined', 'null'],
+ },
+ group: {
+ is: ['object', 'number', 'undefined', 'null'],
+ ok: function (value) {
+ return value &&
+ (value.toString && value.toString() === '[object Group]') ||
+ typeof value === 'number' ||
+ value.type === 'group';
+ },
+ msg: 'The `group` property must be a valid Group object'
+ },
+ index: {
+ is: ['undefined', 'null', 'number'],
+ map: value => value == null ? -1 : value,
+ msg: 'The `index` property must be a number.'
+ },
+ updated: {
+ is: ['number', 'undefined']
+ }
+};
+
+const validTitle = {
+ title: {
+ is: ['string'],
+ msg: 'The `title` property must be defined.'
+ }
+};
+
+const validURL = {
+ url: {
+ is: ['string'],
+ ok: isValidURI,
+ msg: 'The `url` property must be a valid URL.'
+ }
+};
+
+const validTags = {
+ tags: {
+ is: ['object'],
+ ok: tags => tags instanceof Set,
+ map: function (tags) {
+ if (Array.isArray(tags))
+ return new Set(tags);
+ if (tags == null)
+ return new Set();
+ return tags;
+ },
+ msg: 'The `tags` property must be a Set, or an array'
+ }
+};
+
+exports.bookmarkContract = contract(
+ extend(validItem, validTitle, validURL, validTags));
+exports.separatorContract = contract(validItem);
+exports.groupContract = contract(extend(validItem, validTitle));
diff --git a/toolkit/jetpack/sdk/places/events.js b/toolkit/jetpack/sdk/places/events.js
new file mode 100644
index 000000000..a3f95ee03
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/events.js
@@ -0,0 +1,128 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '*',
+ "SeaMonkey": '*'
+ }
+};
+
+const { Cc, Ci } = require('chrome');
+const { Unknown } = require('../platform/xpcom');
+const { Class } = require('../core/heritage');
+const { merge } = require('../util/object');
+const bookmarkService = Cc['@mozilla.org/browser/nav-bookmarks-service;1']
+ .getService(Ci.nsINavBookmarksService);
+const historyService = Cc['@mozilla.org/browser/nav-history-service;1']
+ .getService(Ci.nsINavHistoryService);
+const { mapBookmarkItemType } = require('./utils');
+const { EventTarget } = require('../event/target');
+const { emit } = require('../event/core');
+const { when } = require('../system/unload');
+
+const emitter = EventTarget();
+
+var HISTORY_ARGS = {
+ onBeginUpdateBatch: [],
+ onEndUpdateBatch: [],
+ onClearHistory: [],
+ onDeleteURI: ['url'],
+ onDeleteVisits: ['url', 'visitTime'],
+ onPageChanged: ['url', 'property', 'value'],
+ onTitleChanged: ['url', 'title'],
+ onVisit: [
+ 'url', 'visitId', 'time', 'sessionId', 'referringId', 'transitionType'
+ ]
+};
+
+var HISTORY_EVENTS = {
+ onBeginUpdateBatch: 'history-start-batch',
+ onEndUpdateBatch: 'history-end-batch',
+ onClearHistory: 'history-start-clear',
+ onDeleteURI: 'history-delete-url',
+ onDeleteVisits: 'history-delete-visits',
+ onPageChanged: 'history-page-changed',
+ onTitleChanged: 'history-title-changed',
+ onVisit: 'history-visit'
+};
+
+var BOOKMARK_ARGS = {
+ onItemAdded: [
+ 'id', 'parentId', 'index', 'type', 'url', 'title', 'dateAdded'
+ ],
+ onItemChanged: [
+ 'id', 'property', null, 'value', 'lastModified', 'type', 'parentId'
+ ],
+ onItemMoved: [
+ 'id', 'previousParentId', 'previousIndex', 'currentParentId',
+ 'currentIndex', 'type'
+ ],
+ onItemRemoved: ['id', 'parentId', 'index', 'type', 'url'],
+ onItemVisited: ['id', 'visitId', 'time', 'transitionType', 'url', 'parentId']
+};
+
+var BOOKMARK_EVENTS = {
+ onItemAdded: 'bookmark-item-added',
+ onItemChanged: 'bookmark-item-changed',
+ onItemMoved: 'bookmark-item-moved',
+ onItemRemoved: 'bookmark-item-removed',
+ onItemVisited: 'bookmark-item-visited',
+};
+
+function createHandler (type, propNames) {
+ propNames = propNames || [];
+ return function (...args) {
+ let data = propNames.reduce((acc, prop, i) => {
+ if (prop)
+ acc[prop] = formatValue(prop, args[i]);
+ return acc;
+ }, {});
+
+ emit(emitter, 'data', {
+ type: type,
+ data: data
+ });
+ };
+}
+
+/*
+ * Creates an observer, creating handlers based off of
+ * the `events` names, and ordering arguments from `propNames` hash
+ */
+function createObserverInstance (events, propNames) {
+ let definition = Object.keys(events).reduce((prototype, eventName) => {
+ prototype[eventName] = createHandler(events[eventName], propNames[eventName]);
+ return prototype;
+ }, {});
+
+ return Class(merge(definition, { extends: Unknown }))();
+}
+
+/*
+ * Formats `data` based off of the value of `type`
+ */
+function formatValue (type, data) {
+ if (type === 'type')
+ return mapBookmarkItemType(data);
+ if (type === 'url' && data)
+ return data.spec;
+ return data;
+}
+
+var historyObserver = createObserverInstance(HISTORY_EVENTS, HISTORY_ARGS);
+historyService.addObserver(historyObserver, false);
+
+var bookmarkObserver = createObserverInstance(BOOKMARK_EVENTS, BOOKMARK_ARGS);
+bookmarkService.addObserver(bookmarkObserver, false);
+
+when(() => {
+ historyService.removeObserver(historyObserver);
+ bookmarkService.removeObserver(bookmarkObserver);
+});
+
+exports.events = emitter;
diff --git a/toolkit/jetpack/sdk/places/favicon.js b/toolkit/jetpack/sdk/places/favicon.js
new file mode 100644
index 000000000..05b057db1
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/favicon.js
@@ -0,0 +1,49 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+const { Cc, Ci, Cu } = require("chrome");
+const { defer, reject } = require("../core/promise");
+const FaviconService = Cc["@mozilla.org/browser/favicon-service;1"].
+ getService(Ci.nsIFaviconService);
+const AsyncFavicons = FaviconService.QueryInterface(Ci.mozIAsyncFavicons);
+const { isValidURI } = require("../url");
+const { newURI, getURL } = require("../url/utils");
+
+/**
+ * Takes an object of several possible types and
+ * returns a promise that resolves to the page's favicon URI.
+ * @param {String|Tab} object
+ * @param {Function} (callback)
+ * @returns {Promise}
+ */
+
+function getFavicon (object, callback) {
+ let url = getURL(object);
+ let deferred = defer();
+
+ if (url && isValidURI(url)) {
+ AsyncFavicons.getFaviconURLForPage(newURI(url), function (aURI) {
+ if (aURI && aURI.spec)
+ deferred.resolve(aURI.spec.toString());
+ else
+ deferred.reject(null);
+ });
+ } else {
+ deferred.reject(null);
+ }
+
+ if (callback) deferred.promise.then(callback, callback);
+ return deferred.promise;
+}
+exports.getFavicon = getFavicon;
diff --git a/toolkit/jetpack/sdk/places/history.js b/toolkit/jetpack/sdk/places/history.js
new file mode 100644
index 000000000..b243b024c
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/history.js
@@ -0,0 +1,65 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+/*
+ * Requiring hosts so they can subscribe to client messages
+ */
+require('./host/host-bookmarks');
+require('./host/host-tags');
+require('./host/host-query');
+
+const { Cc, Ci } = require('chrome');
+const { Class } = require('../core/heritage');
+const { events, send } = require('../addon/events');
+const { defer, reject, all } = require('../core/promise');
+const { uuid } = require('../util/uuid');
+const { flatten } = require('../util/array');
+const { has, extend, merge, pick } = require('../util/object');
+const { emit } = require('../event/core');
+const { defer: async } = require('../lang/functional');
+const { EventTarget } = require('../event/target');
+const {
+ urlQueryParser, createQuery, createQueryOptions
+} = require('./utils');
+
+/*
+ * Constant used by nsIHistoryQuery; 0 is a history query
+ * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryQueryOptions
+ */
+const HISTORY_QUERY = 0;
+
+var search = function query (queries, options) {
+ queries = [].concat(queries);
+ let emitter = EventTarget();
+ let queryObjs = queries.map(createQuery.bind(null, HISTORY_QUERY));
+ let optionsObj = createQueryOptions(HISTORY_QUERY, options);
+
+ // Can remove after `Promise.jsm` is implemented in Bug 881047,
+ // which will guarantee next tick execution
+ async(() => {
+ send('sdk-places-query', {
+ query: queryObjs,
+ options: optionsObj
+ }).then(results => {
+ results.map(item => emit(emitter, 'data', item));
+ emit(emitter, 'end', results);
+ }, reason => {
+ emit(emitter, 'error', reason);
+ emit(emitter, 'end', []);
+ });
+ })();
+
+ return emitter;
+};
+exports.search = search;
diff --git a/toolkit/jetpack/sdk/places/host/host-bookmarks.js b/toolkit/jetpack/sdk/places/host/host-bookmarks.js
new file mode 100644
index 000000000..3245c4070
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/host/host-bookmarks.js
@@ -0,0 +1,238 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+const { Cc, Ci } = require('chrome');
+const browserHistory = Cc["@mozilla.org/browser/nav-history-service;1"].
+ getService(Ci.nsIBrowserHistory);
+const asyncHistory = Cc["@mozilla.org/browser/history;1"].
+ getService(Ci.mozIAsyncHistory);
+const bmsrv = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
+ getService(Ci.nsINavBookmarksService);
+const taggingService = Cc["@mozilla.org/browser/tagging-service;1"].
+ getService(Ci.nsITaggingService);
+const ios = Cc['@mozilla.org/network/io-service;1'].
+ getService(Ci.nsIIOService);
+const { query } = require('./host-query');
+const {
+ defer, all, resolve, promised, reject
+} = require('../../core/promise');
+const { request, response } = require('../../addon/host');
+const { send } = require('../../addon/events');
+const { on, emit } = require('../../event/core');
+const { filter } = require('../../event/utils');
+const { URL, isValidURI } = require('../../url');
+const { newURI } = require('../../url/utils');
+
+const DEFAULT_INDEX = bmsrv.DEFAULT_INDEX;
+const UNSORTED_ID = bmsrv.unfiledBookmarksFolder;
+const ROOT_FOLDERS = [
+ bmsrv.unfiledBookmarksFolder, bmsrv.toolbarFolder,
+ bmsrv.tagsFolder, bmsrv.bookmarksMenuFolder
+];
+
+const EVENT_MAP = {
+ 'sdk-places-bookmarks-create': createBookmarkItem,
+ 'sdk-places-bookmarks-save': saveBookmarkItem,
+ 'sdk-places-bookmarks-last-updated': getBookmarkLastUpdated,
+ 'sdk-places-bookmarks-get': getBookmarkItem,
+ 'sdk-places-bookmarks-remove': removeBookmarkItem,
+ 'sdk-places-bookmarks-get-all': getAllBookmarks,
+ 'sdk-places-bookmarks-get-children': getChildren
+};
+
+function typeMap (type) {
+ if (typeof type === 'number') {
+ if (bmsrv.TYPE_BOOKMARK === type) return 'bookmark';
+ if (bmsrv.TYPE_FOLDER === type) return 'group';
+ if (bmsrv.TYPE_SEPARATOR === type) return 'separator';
+ } else {
+ if ('bookmark' === type) return bmsrv.TYPE_BOOKMARK;
+ if ('group' === type) return bmsrv.TYPE_FOLDER;
+ if ('separator' === type) return bmsrv.TYPE_SEPARATOR;
+ }
+}
+
+function getBookmarkLastUpdated ({id}) {
+ return resolve(bmsrv.getItemLastModified(id));
+}
+exports.getBookmarkLastUpdated;
+
+function createBookmarkItem (data) {
+ let error;
+
+ if (data.group == null) data.group = UNSORTED_ID;
+ if (data.index == null) data.index = DEFAULT_INDEX;
+
+ if (data.type === 'group')
+ data.id = bmsrv.createFolder(
+ data.group, data.title, data.index
+ );
+ else if (data.type === 'separator')
+ data.id = bmsrv.insertSeparator(
+ data.group, data.index
+ );
+ else
+ data.id = bmsrv.insertBookmark(
+ data.group, newURI(data.url), data.index, data.title
+ );
+
+ // In the event where default or no index is provided (-1),
+ // query the actual index for the response
+ if (data.index === -1)
+ data.index = bmsrv.getItemIndex(data.id);
+
+ try {
+ data.updated = bmsrv.getItemLastModified(data.id);
+ }
+ catch (e) {
+ console.exception(e);
+ }
+
+ return tag(data, true).then(() => data);
+}
+exports.createBookmarkItem = createBookmarkItem;
+
+function saveBookmarkItem (data) {
+ let id = data.id;
+ if (!id)
+ reject('Item is missing id');
+
+ let group = bmsrv.getFolderIdForItem(id);
+ let index = bmsrv.getItemIndex(id);
+ let type = bmsrv.getItemType(id);
+ let title = typeMap(type) !== 'separator' ?
+ bmsrv.getItemTitle(id) :
+ undefined;
+ let url = typeMap(type) === 'bookmark' ?
+ bmsrv.getBookmarkURI(id).spec :
+ undefined;
+
+ if (url != data.url)
+ bmsrv.changeBookmarkURI(id, newURI(data.url));
+ else if (typeMap(type) === 'bookmark')
+ data.url = url;
+
+ if (title != data.title)
+ bmsrv.setItemTitle(id, data.title);
+ else if (typeMap(type) !== 'separator')
+ data.title = title;
+
+ if (data.group && data.group !== group)
+ bmsrv.moveItem(id, data.group, data.index || -1);
+ else if (data.index != null && data.index !== index) {
+ // We use moveItem here instead of setItemIndex
+ // so we don't have to manage the indicies of the siblings
+ bmsrv.moveItem(id, group, data.index);
+ } else if (data.index == null)
+ data.index = index;
+
+ data.updated = bmsrv.getItemLastModified(data.id);
+
+ return tag(data).then(() => data);
+}
+exports.saveBookmarkItem = saveBookmarkItem;
+
+function removeBookmarkItem (data) {
+ let id = data.id;
+
+ if (!id)
+ reject('Item is missing id');
+
+ bmsrv.removeItem(id);
+ return resolve(null);
+}
+exports.removeBookmarkItem = removeBookmarkItem;
+
+function getBookmarkItem (data) {
+ let id = data.id;
+
+ if (!id)
+ reject('Item is missing id');
+
+ let type = bmsrv.getItemType(id);
+
+ data.type = typeMap(type);
+
+ if (type === bmsrv.TYPE_BOOKMARK || type === bmsrv.TYPE_FOLDER)
+ data.title = bmsrv.getItemTitle(id);
+
+ if (type === bmsrv.TYPE_BOOKMARK) {
+ data.url = bmsrv.getBookmarkURI(id).spec;
+ // Should be moved into host-tags as a method
+ data.tags = taggingService.getTagsForURI(newURI(data.url), {});
+ }
+
+ data.group = bmsrv.getFolderIdForItem(id);
+ data.index = bmsrv.getItemIndex(id);
+ data.updated = bmsrv.getItemLastModified(data.id);
+
+ return resolve(data);
+}
+exports.getBookmarkItem = getBookmarkItem;
+
+function getAllBookmarks () {
+ return query({}, { queryType: 1 }).then(bookmarks =>
+ all(bookmarks.map(getBookmarkItem)));
+}
+exports.getAllBookmarks = getAllBookmarks;
+
+function getChildren ({ id }) {
+ if (typeMap(bmsrv.getItemType(id)) !== 'group') return [];
+ let ids = [];
+ for (let i = 0; ids[ids.length - 1] !== -1; i++)
+ ids.push(bmsrv.getIdForItemAt(id, i));
+ ids.pop();
+ return all(ids.map(id => getBookmarkItem({ id: id })));
+}
+exports.getChildren = getChildren;
+
+/*
+ * Hook into host
+ */
+
+var reqStream = filter(request, (data) => /sdk-places-bookmarks/.test(data.event));
+on(reqStream, 'data', ({ event, id, data }) => {
+ if (!EVENT_MAP[event]) return;
+
+ let resData = { id: id, event: event };
+
+ promised(EVENT_MAP[event])(data).
+ then(res => resData.data = res, e => resData.error = e).
+ then(() => emit(response, 'data', resData));
+});
+
+function tag (data, isNew) {
+ // If a new item, we can skip checking what other tags
+ // are on the item
+ if (data.type !== 'bookmark') {
+ return resolve();
+ }
+ else if (!isNew) {
+ return send('sdk-places-tags-get-tags-by-url', { url: data.url })
+ .then(tags => {
+ return send('sdk-places-tags-untag', {
+ tags: tags.filter(tag => !~data.tags.indexOf(tag)),
+ url: data.url
+ });
+ }).then(() => send('sdk-places-tags-tag', {
+ url: data.url, tags: data.tags
+ }));
+ }
+ else if (data.tags && data.tags.length) {
+ return send('sdk-places-tags-tag', { url: data.url, tags: data.tags });
+ }
+ else
+ return resolve();
+}
+
diff --git a/toolkit/jetpack/sdk/places/host/host-query.js b/toolkit/jetpack/sdk/places/host/host-query.js
new file mode 100644
index 000000000..f2dbd6550
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/host/host-query.js
@@ -0,0 +1,179 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+const { Cc, Ci } = require('chrome');
+const { all } = require('../../core/promise');
+const { safeMerge, omit } = require('../../util/object');
+const historyService = Cc['@mozilla.org/browser/nav-history-service;1']
+ .getService(Ci.nsINavHistoryService);
+const bookmarksService = Cc['@mozilla.org/browser/nav-bookmarks-service;1']
+ .getService(Ci.nsINavBookmarksService);
+const { request, response } = require('../../addon/host');
+const { newURI } = require('../../url/utils');
+const { send } = require('../../addon/events');
+const { on, emit } = require('../../event/core');
+const { filter } = require('../../event/utils');
+
+const ROOT_FOLDERS = [
+ bookmarksService.unfiledBookmarksFolder, bookmarksService.toolbarFolder,
+ bookmarksService.bookmarksMenuFolder
+];
+
+const EVENT_MAP = {
+ 'sdk-places-query': queryReceiver
+};
+
+// Properties that need to be manually
+// copied into a nsINavHistoryQuery object
+const MANUAL_QUERY_PROPERTIES = [
+ 'uri', 'folder', 'tags', 'url', 'folder'
+];
+
+const PLACES_PROPERTIES = [
+ 'uri', 'title', 'accessCount', 'time'
+];
+
+function execute (queries, options) {
+ return new Promise(resolve => {
+ let root = historyService
+ .executeQueries(queries, queries.length, options).root;
+ // Let's extract an eventual uri wildcard, if both domain and uri are set.
+ // See utils.js::urlQueryParser() for more details.
+ // In case of multiple queries, we only retain the first found wildcard.
+ let uriWildcard = queries.reduce((prev, query) => {
+ if (query.uri && query.domain) {
+ if (!prev)
+ prev = query.uri.spec;
+ query.uri = null;
+ }
+ return prev;
+ }, "");
+ resolve(collect([], root, uriWildcard));
+ });
+}
+
+function collect (acc, node, uriWildcard) {
+ node.containerOpen = true;
+ for (let i = 0; i < node.childCount; i++) {
+ let child = node.getChild(i);
+
+ if (!uriWildcard || child.uri.startsWith(uriWildcard)) {
+ acc.push(child);
+ }
+ if (child.type === child.RESULT_TYPE_FOLDER) {
+ let container = child.QueryInterface(Ci.nsINavHistoryContainerResultNode);
+ collect(acc, container, uriWildcard);
+ }
+ }
+ node.containerOpen = false;
+ return acc;
+}
+
+function query (queries, options) {
+ return new Promise((resolve, reject) => {
+ queries = queries || [];
+ options = options || {};
+ let optionsObj, queryObjs;
+
+ optionsObj = historyService.getNewQueryOptions();
+ queryObjs = [].concat(queries).map(createQuery);
+ if (!queryObjs.length) {
+ queryObjs = [historyService.getNewQuery()];
+ }
+ safeMerge(optionsObj, options);
+
+ /*
+ * Currently `places:` queries are not supported
+ */
+ optionsObj.excludeQueries = true;
+
+ execute(queryObjs, optionsObj).then((results) => {
+ if (optionsObj.queryType === 0) {
+ return results.map(normalize);
+ }
+ else if (optionsObj.queryType === 1) {
+ // Formats query results into more standard
+ // data structures for returning
+ return all(results.map(({itemId}) =>
+ send('sdk-places-bookmarks-get', { id: itemId })));
+ }
+ }).then(resolve, reject);
+ });
+}
+exports.query = query;
+
+function createQuery (query) {
+ query = query || {};
+ let queryObj = historyService.getNewQuery();
+
+ safeMerge(queryObj, omit(query, MANUAL_QUERY_PROPERTIES));
+
+ if (query.tags && Array.isArray(query.tags))
+ queryObj.tags = query.tags;
+ if (query.uri || query.url)
+ queryObj.uri = newURI(query.uri || query.url);
+ if (query.folder)
+ queryObj.setFolders([query.folder], 1);
+ return queryObj;
+}
+
+function queryReceiver (message) {
+ let queries = message.data.queries || message.data.query;
+ let options = message.data.options;
+ let resData = {
+ id: message.id,
+ event: message.event
+ };
+
+ query(queries, options).then(results => {
+ resData.data = results;
+ respond(resData);
+ }, reason => {
+ resData.error = reason;
+ respond(resData);
+ });
+}
+
+/*
+ * Converts a nsINavHistoryResultNode into a plain object
+ *
+ * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryResultNode
+ */
+function normalize (historyObj) {
+ return PLACES_PROPERTIES.reduce((obj, prop) => {
+ if (prop === 'uri')
+ obj.url = historyObj.uri;
+ else if (prop === 'time') {
+ // Cast from microseconds to milliseconds
+ obj.time = Math.floor(historyObj.time / 1000)
+ }
+ else if (prop === 'accessCount')
+ obj.visitCount = historyObj[prop];
+ else
+ obj[prop] = historyObj[prop];
+ return obj;
+ }, {});
+}
+
+/*
+ * Hook into host
+ */
+
+var reqStream = filter(request, data => /sdk-places-query/.test(data.event));
+on(reqStream, 'data', function (e) {
+ if (EVENT_MAP[e.event]) EVENT_MAP[e.event](e);
+});
+
+function respond (data) {
+ emit(response, 'data', data);
+}
diff --git a/toolkit/jetpack/sdk/places/host/host-tags.js b/toolkit/jetpack/sdk/places/host/host-tags.js
new file mode 100644
index 000000000..929a5d5af
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/host/host-tags.js
@@ -0,0 +1,92 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+const { Cc, Ci } = require('chrome');
+const taggingService = Cc["@mozilla.org/browser/tagging-service;1"].
+ getService(Ci.nsITaggingService);
+const ios = Cc['@mozilla.org/network/io-service;1'].
+ getService(Ci.nsIIOService);
+const { URL } = require('../../url');
+const { newURI } = require('../../url/utils');
+const { request, response } = require('../../addon/host');
+const { on, emit } = require('../../event/core');
+const { filter } = require('../../event/utils');
+
+const EVENT_MAP = {
+ 'sdk-places-tags-tag': tag,
+ 'sdk-places-tags-untag': untag,
+ 'sdk-places-tags-get-tags-by-url': getTagsByURL,
+ 'sdk-places-tags-get-urls-by-tag': getURLsByTag
+};
+
+function tag (message) {
+ let data = message.data;
+ let resData = {
+ id: message.id,
+ event: message.event
+ };
+
+ resData.data = taggingService.tagURI(newURI(data.url), data.tags);
+ respond(resData);
+}
+
+function untag (message) {
+ let data = message.data;
+ let resData = {
+ id: message.id,
+ event: message.event
+ };
+
+ resData.data = taggingService.untagURI(newURI(data.url), data.tags);
+ respond(resData);
+}
+
+function getURLsByTag (message) {
+ let data = message.data;
+ let resData = {
+ id: message.id,
+ event: message.event
+ };
+
+ resData.data = taggingService
+ .getURIsForTag(data.tag).map(uri => uri.spec);
+ respond(resData);
+}
+
+function getTagsByURL (message) {
+ let data = message.data;
+ let resData = {
+ id: message.id,
+ event: message.event
+ };
+
+ resData.data = taggingService.getTagsForURI(newURI(data.url), {});
+ respond(resData);
+}
+
+/*
+ * Hook into host
+ */
+
+var reqStream = filter(request, function (data) {
+ return /sdk-places-tags/.test(data.event);
+});
+
+on(reqStream, 'data', function (e) {
+ if (EVENT_MAP[e.event]) EVENT_MAP[e.event](e);
+});
+
+function respond (data) {
+ emit(response, 'data', data);
+}
diff --git a/toolkit/jetpack/sdk/places/utils.js b/toolkit/jetpack/sdk/places/utils.js
new file mode 100644
index 000000000..44366d2aa
--- /dev/null
+++ b/toolkit/jetpack/sdk/places/utils.js
@@ -0,0 +1,268 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+const { Cc, Ci, Cu } = require('chrome');
+const { Class } = require('../core/heritage');
+const { method } = require('../lang/functional');
+const { defer, promised, all } = require('../core/promise');
+const { send } = require('../addon/events');
+const { EventTarget } = require('../event/target');
+const { merge } = require('../util/object');
+const bmsrv = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
+ getService(Ci.nsINavBookmarksService);
+
+Cu.importGlobalProperties(["URL"]);
+
+/*
+ * TreeNodes are used to construct dependency trees
+ * for BookmarkItems
+ */
+var TreeNode = Class({
+ initialize: function (value) {
+ this.value = value;
+ this.children = [];
+ },
+ add: function (values) {
+ [].concat(values).forEach(value => {
+ this.children.push(value instanceof TreeNode ? value : TreeNode(value));
+ });
+ },
+ get length () {
+ let count = 0;
+ this.walk(() => count++);
+ // Do not count the current node
+ return --count;
+ },
+ get: method(get),
+ walk: method(walk),
+ toString: () => '[object TreeNode]'
+});
+exports.TreeNode = TreeNode;
+
+/*
+ * Descends down from `node` applying `fn` to each in order.
+ * `fn` can return values or promises -- if promise returned,
+ * children are not processed until resolved. `fn` is passed
+ * one argument, the current node, `curr`.
+ */
+function walk (curr, fn) {
+ return promised(fn)(curr).then(val => {
+ return all(curr.children.map(child => walk(child, fn)));
+ });
+}
+
+/*
+ * Descends from the TreeNode `node`, returning
+ * the node with value `value` if found or `null`
+ * otherwise
+ */
+function get (node, value) {
+ if (node.value === value) return node;
+ for (let child of node.children) {
+ let found = get(child, value);
+ if (found) return found;
+ }
+ return null;
+}
+
+/*
+ * Constructs a tree of bookmark nodes
+ * returning the root (value: null);
+ */
+
+function constructTree (items) {
+ let root = TreeNode(null);
+ items.forEach(treeify.bind(null, root));
+
+ function treeify (root, item) {
+ // If node already exists, skip
+ let node = root.get(item);
+ if (node) return node;
+ node = TreeNode(item);
+
+ let parentNode = item.group ? treeify(root, item.group) : root;
+ parentNode.add(node);
+
+ return node;
+ }
+
+ return root;
+}
+exports.constructTree = constructTree;
+
+/*
+ * Shortcut for converting an id, or an object with an id, into
+ * an object with corresponding bookmark data
+ */
+function fetchItem (item) {
+ return send('sdk-places-bookmarks-get', { id: item.id || item });
+}
+exports.fetchItem = fetchItem;
+
+/*
+ * Takes an ID or an object with ID and checks it against
+ * the root bookmark folders
+ */
+function isRootGroup (id) {
+ id = id && id.id;
+ return ~[bmsrv.bookmarksMenuFolder, bmsrv.toolbarFolder,
+ bmsrv.unfiledBookmarksFolder
+ ].indexOf(id);
+}
+exports.isRootGroup = isRootGroup;
+
+/*
+ * Merges appropriate options into query based off of url
+ * 4 scenarios:
+ *
+ * 'moz.com' // domain: moz.com, domainIsHost: true
+ * --> 'http://moz.com', 'http://moz.com/thunderbird'
+ * '*.moz.com' // domain: moz.com, domainIsHost: false
+ * --> 'http://moz.com', 'http://moz.com/index', 'http://ff.moz.com/test'
+ * 'http://moz.com' // uri: http://moz.com/
+ * --> 'http://moz.com/'
+ * 'http://moz.com/*' // uri: http://moz.com/, domain: moz.com, domainIsHost: true
+ * --> 'http://moz.com/', 'http://moz.com/thunderbird'
+ */
+
+function urlQueryParser (query, url) {
+ if (!url) return;
+ if (/^https?:\/\//.test(url)) {
+ query.uri = url.charAt(url.length - 1) === '/' ? url : url + '/';
+ if (/\*$/.test(url)) {
+ // Wildcard searches on URIs are not supported, so try to extract a
+ // domain and filter the data later.
+ url = url.replace(/\*$/, '');
+ try {
+ query.domain = new URL(url).hostname;
+ query.domainIsHost = true;
+ // Unfortunately here we cannot use an expando to store the wildcard,
+ // cause the query is a wrapped native XPCOM object, so we reuse uri.
+ // We clearly don't want to query for both uri and domain, thus we'll
+ // have to handle this in host-query.js::execute()
+ query.uri = url;
+ } catch (ex) {
+ // Cannot extract an host cause it's not a valid uri, the query will
+ // just return nothing.
+ }
+ }
+ } else {
+ if (/^\*/.test(url)) {
+ query.domain = url.replace(/^\*\./, '');
+ query.domainIsHost = false;
+ } else {
+ query.domain = url;
+ query.domainIsHost = true;
+ }
+ }
+}
+exports.urlQueryParser = urlQueryParser;
+
+/*
+ * Takes an EventEmitter and returns a promise that
+ * aggregates results and handles a bulk resolve and reject
+ */
+
+function promisedEmitter (emitter) {
+ let { promise, resolve, reject } = defer();
+ let errors = [];
+ emitter.on('error', error => errors.push(error));
+ emitter.on('end', (items) => {
+ if (errors.length) reject(errors[0]);
+ else resolve(items);
+ });
+ return promise;
+}
+exports.promisedEmitter = promisedEmitter;
+
+
+// https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryQueryOptions
+function createQuery (type, query) {
+ query = query || {};
+ let qObj = {
+ searchTerms: query.query
+ };
+
+ urlQueryParser(qObj, query.url);
+
+ // 0 === history
+ if (type === 0) {
+ // PRTime used by query is in microseconds, not milliseconds
+ qObj.beginTime = (query.from || 0) * 1000;
+ qObj.endTime = (query.to || new Date()) * 1000;
+
+ // Set reference time to Epoch
+ qObj.beginTimeReference = 0;
+ qObj.endTimeReference = 0;
+ }
+ // 1 === bookmarks
+ else if (type === 1) {
+ qObj.tags = query.tags;
+ qObj.folder = query.group && query.group.id;
+ }
+ // 2 === unified (not implemented on platform)
+ else if (type === 2) {
+
+ }
+
+ return qObj;
+}
+exports.createQuery = createQuery;
+
+// https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryQueryOptions
+
+const SORT_MAP = {
+ title: 1,
+ date: 3, // sort by visit date
+ url: 5,
+ visitCount: 7,
+ // keywords currently unsupported
+ // keyword: 9,
+ dateAdded: 11, // bookmarks only
+ lastModified: 13 // bookmarks only
+};
+
+function createQueryOptions (type, options) {
+ options = options || {};
+ let oObj = {};
+ oObj.sortingMode = SORT_MAP[options.sort] || 0;
+ if (options.descending && options.sort)
+ oObj.sortingMode++;
+
+ // Resolve to default sort if ineligible based on query type
+ if (type === 0 && // history
+ (options.sort === 'dateAdded' || options.sort === 'lastModified'))
+ oObj.sortingMode = 0;
+
+ oObj.maxResults = typeof options.count === 'number' ? options.count : 0;
+
+ oObj.queryType = type;
+
+ return oObj;
+}
+exports.createQueryOptions = createQueryOptions;
+
+
+function mapBookmarkItemType (type) {
+ if (typeof type === 'number') {
+ if (bmsrv.TYPE_BOOKMARK === type) return 'bookmark';
+ if (bmsrv.TYPE_FOLDER === type) return 'group';
+ if (bmsrv.TYPE_SEPARATOR === type) return 'separator';
+ } else {
+ if ('bookmark' === type) return bmsrv.TYPE_BOOKMARK;
+ if ('group' === type) return bmsrv.TYPE_FOLDER;
+ if ('separator' === type) return bmsrv.TYPE_SEPARATOR;
+ }
+}
+exports.mapBookmarkItemType = mapBookmarkItemType;
diff --git a/toolkit/jetpack/sdk/platform/xpcom.js b/toolkit/jetpack/sdk/platform/xpcom.js
new file mode 100644
index 000000000..383baf67a
--- /dev/null
+++ b/toolkit/jetpack/sdk/platform/xpcom.js
@@ -0,0 +1,241 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci, Cr, Cm, components: { classesByID } } = require('chrome');
+const { registerFactory, unregisterFactory, isCIDRegistered } =
+ Cm.QueryInterface(Ci.nsIComponentRegistrar);
+
+const { merge } = require('../util/object');
+const { Class, extend, mix } = require('../core/heritage');
+const { uuid } = require('../util/uuid');
+
+// This is a base prototype, that provides bare bones of XPCOM. JS based
+// components can be easily implement by extending it.
+const Unknown = new function() {
+ function hasInterface(component, iid) {
+ return component && component.interfaces &&
+ ( component.interfaces.some(id => iid.equals(Ci[id])) ||
+ component.implements.some($ => hasInterface($, iid)) ||
+ hasInterface(Object.getPrototypeOf(component), iid));
+ }
+
+ return Class({
+ /**
+ * The `QueryInterface` method provides runtime type discovery used by XPCOM.
+ * This method return queried instance of `this` if given `iid` is listed in
+ * the `interfaces` property or in equivalent properties of objects in it's
+ * prototype chain. In addition it will look up in the prototypes under
+ * `implements` array property, this ways compositions made via `Class`
+ * utility will carry interfaces implemented by composition components.
+ */
+ QueryInterface: function QueryInterface(iid) {
+ // For some reason there are cases when `iid` is `null`. In such cases we
+ // just return `this`. Otherwise we verify that component implements given
+ // `iid` interface. This will be no longer necessary once Bug 748003 is
+ // fixed.
+ if (iid && !hasInterface(this, iid))
+ throw Cr.NS_ERROR_NO_INTERFACE;
+
+ return this;
+ },
+ /**
+ * Array of `XPCOM` interfaces (as strings) implemented by this component.
+ * All components implement `nsISupports` by default which is default value
+ * here. Provide array of interfaces implemented by an object when
+ * extending, to append them to this list (Please note that there is no
+ * need to repeat interfaces implemented by super as they will be added
+ * automatically).
+ */
+ interfaces: Object.freeze([ 'nsISupports' ])
+ });
+}
+exports.Unknown = Unknown;
+
+// Base exemplar for creating instances implementing `nsIFactory` interface,
+// that maybe registered into runtime via `register` function. Instances of
+// this factory create instances of enclosed component on `createInstance`.
+const Factory = Class({
+ extends: Unknown,
+ interfaces: [ 'nsIFactory' ],
+ /**
+ * All the descendants will get auto generated `id` (also known as `classID`
+ * in XPCOM world) unless one is manually provided.
+ */
+ get id() { throw Error('Factory must implement `id` property') },
+ /**
+ * XPCOM `contractID` may optionally be provided to associate this factory
+ * with it. `contract` is a unique string that has a following format:
+ * '@vendor.com/unique/id;1'.
+ */
+ contract: null,
+ /**
+ * Class description that is being registered. This value is intended as a
+ * human-readable description for the given class and does not needs to be
+ * globally unique.
+ */
+ description: 'Jetpack generated factory',
+ /**
+ * This method is required by `nsIFactory` interfaces, but as in most
+ * implementations it does nothing interesting.
+ */
+ lockFactory: function lockFactory(lock) {
+ return undefined;
+ },
+ /**
+ * If property is `true` XPCOM service / factory will be registered
+ * automatically on creation.
+ */
+ register: true,
+ /**
+ * If property is `true` XPCOM factory will be unregistered prior to add-on
+ * unload.
+ */
+ unregister: true,
+ /**
+ * Method is called on `Service.new(options)` passing given `options` to
+ * it. Options is expected to have `component` property holding XPCOM
+ * component implementation typically decedent of `Unknown` or any custom
+ * implementation with a `new` method and optional `register`, `unregister`
+ * flags. Unless `register` is `false` Service / Factory will be
+ * automatically registered. Unless `unregister` is `false` component will
+ * be automatically unregistered on add-on unload.
+ */
+ initialize: function initialize(options) {
+ merge(this, {
+ id: 'id' in options ? options.id : uuid(),
+ register: 'register' in options ? options.register : this.register,
+ unregister: 'unregister' in options ? options.unregister : this.unregister,
+ contract: 'contract' in options ? options.contract : null,
+ Component: options.Component
+ });
+
+ // If service / factory has auto registration enabled then register.
+ if (this.register)
+ register(this);
+ },
+ /**
+ * Creates an instance of the class associated with this factory.
+ */
+ createInstance: function createInstance(outer, iid) {
+ try {
+ if (outer)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return this.create().QueryInterface(iid);
+ }
+ catch (error) {
+ throw error instanceof Ci.nsIException ? error : Cr.NS_ERROR_FAILURE;
+ }
+ },
+ create: function create() {
+ return this.Component();
+ }
+});
+exports.Factory = Factory;
+
+// Exemplar for creating services that implement `nsIFactory` interface, that
+// can be registered into runtime via call to `register`. This services return
+// enclosed `component` on `getService`.
+const Service = Class({
+ extends: Factory,
+ initialize: function initialize(options) {
+ this.component = options.Component();
+ Factory.prototype.initialize.call(this, options);
+ },
+ description: 'Jetpack generated service',
+ /**
+ * Creates an instance of the class associated with this factory.
+ */
+ create: function create() {
+ return this.component;
+ }
+});
+exports.Service = Service;
+
+function isRegistered({ id }) {
+ return isCIDRegistered(id);
+}
+exports.isRegistered = isRegistered;
+
+/**
+ * Registers given `component` object to be used to instantiate a particular
+ * class identified by `component.id`, and creates an association of class
+ * name and `component.contract` with the class.
+ */
+function register(factory) {
+ if (!(factory instanceof Factory)) {
+ throw new Error("xpcom.register() expect a Factory instance.\n" +
+ "Please refactor your code to new xpcom module if you" +
+ " are repacking an addon from SDK <= 1.5:\n" +
+ "https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/platform_xpcom");
+ }
+
+ registerFactory(factory.id, factory.description, factory.contract, factory);
+
+ if (factory.unregister)
+ require('../system/unload').when(unregister.bind(null, factory));
+}
+exports.register = register;
+
+/**
+ * Unregister a factory associated with a particular class identified by
+ * `factory.classID`.
+ */
+function unregister(factory) {
+ if (isRegistered(factory))
+ unregisterFactory(factory.id, factory);
+}
+exports.unregister = unregister;
+
+function autoRegister(path) {
+ // TODO: This assumes that the url points to a directory
+ // that contains subdirectories corresponding to OS/ABI and then
+ // further subdirectories corresponding to Gecko platform version.
+ // we should probably either behave intelligently here or allow
+ // the caller to pass-in more options if e.g. there aren't
+ // Gecko-specific binaries for a component (which will be the case
+ // if only frozen interfaces are used).
+
+ var runtime = require("../system/runtime");
+ var osDirName = runtime.OS + "_" + runtime.XPCOMABI;
+ var platformVersion = require("../system/xul-app").platformVersion.substring(0, 5);
+
+ var file = Cc['@mozilla.org/file/local;1']
+ .createInstance(Ci.nsILocalFile);
+ file.initWithPath(path);
+ file.append(osDirName);
+ file.append(platformVersion);
+
+ if (!(file.exists() && file.isDirectory()))
+ throw new Error("component not available for OS/ABI " +
+ osDirName + " and platform " + platformVersion);
+
+ Cm.QueryInterface(Ci.nsIComponentRegistrar);
+ Cm.autoRegister(file);
+}
+exports.autoRegister = autoRegister;
+
+/**
+ * Returns registered factory that has a given `id` or `null` if not found.
+ */
+function factoryByID(id) {
+ return classesByID[id] || null;
+}
+exports.factoryByID = factoryByID;
+
+/**
+ * Returns factory registered with a given `contract` or `null` if not found.
+ * In contrast to `Cc[contract]` that does ignores new factory registration
+ * with a given `contract` this will return a factory currently associated
+ * with a `contract`.
+ */
+function factoryByContract(contract) {
+ return factoryByID(Cm.contractIDToCID(contract));
+}
+exports.factoryByContract = factoryByContract;
diff --git a/toolkit/jetpack/sdk/preferences/event-target.js b/toolkit/jetpack/sdk/preferences/event-target.js
new file mode 100644
index 000000000..b64ba303c
--- /dev/null
+++ b/toolkit/jetpack/sdk/preferences/event-target.js
@@ -0,0 +1,61 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci } = require('chrome');
+const { Class } = require('../core/heritage');
+const { EventTarget } = require('../event/target');
+const { Branch } = require('./service');
+const { emit, off } = require('../event/core');
+const { when: unload } = require('../system/unload');
+
+const prefTargetNS = require('../core/namespace').ns();
+
+const PrefsTarget = Class({
+ extends: EventTarget,
+ initialize: function(options) {
+ options = options || {};
+ EventTarget.prototype.initialize.call(this, options);
+
+ let branchName = options.branchName || '';
+ let branch = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefService).
+ getBranch(branchName).
+ QueryInterface(Ci.nsIPrefBranch2);
+ prefTargetNS(this).branch = branch;
+
+ // provides easy access to preference values
+ this.prefs = Branch(branchName);
+
+ // start listening to preference changes
+ let observer = prefTargetNS(this).observer = onChange.bind(this);
+ branch.addObserver('', observer, false);
+
+ // Make sure to destroy this on unload
+ unload(destroy.bind(this));
+ }
+});
+exports.PrefsTarget = PrefsTarget;
+
+/* HELPERS */
+
+function onChange(subject, topic, name) {
+ if (topic === 'nsPref:changed') {
+ emit(this, name, name);
+ emit(this, '', name);
+ }
+}
+
+function destroy() {
+ off(this);
+
+ // stop listening to preference changes
+ let branch = prefTargetNS(this).branch;
+ branch.removeObserver('', prefTargetNS(this).observer, false);
+ prefTargetNS(this).observer = null;
+}
diff --git a/toolkit/jetpack/sdk/preferences/native-options.js b/toolkit/jetpack/sdk/preferences/native-options.js
new file mode 100644
index 000000000..840997df9
--- /dev/null
+++ b/toolkit/jetpack/sdk/preferences/native-options.js
@@ -0,0 +1,193 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci, Cu } = require('chrome');
+const { on } = require('../system/events');
+const { id, preferencesBranch } = require('../self');
+const { localizeInlineOptions } = require('../l10n/prefs');
+const { Services } = require("resource://gre/modules/Services.jsm");
+const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
+const { defer } = require("sdk/core/promise");
+
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";;
+const DEFAULT_OPTIONS_URL = 'data:text/xml,<placeholder/>';
+
+const VALID_PREF_TYPES = ['bool', 'boolint', 'integer', 'string', 'color',
+ 'file', 'directory', 'control', 'menulist', 'radio'];
+
+const isFennec = require("sdk/system/xul-app").is("Fennec");
+
+function enable({ preferences, id }) {
+ let enabled = defer();
+
+ validate(preferences);
+
+ setDefaults(preferences, preferencesBranch);
+
+ // allow the use of custom options.xul
+ AddonManager.getAddonByID(id, (addon) => {
+ on('addon-options-displayed', onAddonOptionsDisplayed, true);
+ enabled.resolve({ id: id });
+ });
+
+ function onAddonOptionsDisplayed({ subject: doc, data }) {
+ if (data === id) {
+ let parent;
+
+ if (isFennec) {
+ parent = doc.querySelector('.options-box');
+
+ // NOTE: This disable the CSS rule that makes the options invisible
+ let item = doc.querySelector('#addons-details .addon-item');
+ item.removeAttribute("optionsURL");
+ } else {
+ parent = doc.getElementById('detail-downloads').parentNode;
+ }
+
+ if (parent) {
+ injectOptions({
+ preferences: preferences,
+ preferencesBranch: preferencesBranch,
+ document: doc,
+ parent: parent,
+ id: id
+ });
+ localizeInlineOptions(doc);
+ } else {
+ throw Error("Preferences parent node not found in Addon Details. The configured custom preferences will not be visible.");
+ }
+ }
+ }
+
+ return enabled.promise;
+}
+exports.enable = enable;
+
+// centralized sanity checks
+function validate(preferences) {
+ for (let { name, title, type, label, options } of preferences) {
+ // make sure the title is set and non-empty
+ if (!title)
+ throw Error("The '" + name + "' pref requires a title");
+
+ // make sure that pref type is a valid inline option type
+ if (!~VALID_PREF_TYPES.indexOf(type))
+ throw Error("The '" + name + "' pref must be of valid type");
+
+ // if it's a control, make sure it has a label
+ if (type === 'control' && !label)
+ throw Error("The '" + name + "' control requires a label");
+
+ // if it's a menulist or radio, make sure it has options
+ if (type === 'menulist' || type === 'radio') {
+ if (!options)
+ throw Error("The '" + name + "' pref requires options");
+
+ // make sure each option has a value and a label
+ for (let item of options) {
+ if (!('value' in item) || !('label' in item))
+ throw Error("Each option requires both a value and a label");
+ }
+ }
+
+ // TODO: check that pref type matches default value type
+ }
+}
+exports.validate = validate;
+
+// initializes default preferences, emulates defaults/prefs.js
+function setDefaults(preferences, preferencesBranch) {
+ const branch = Cc['@mozilla.org/preferences-service;1'].
+ getService(Ci.nsIPrefService).
+ getDefaultBranch('extensions.' + preferencesBranch + '.');
+ for (let { name, value } of preferences) {
+ switch (typeof value) {
+ case 'boolean':
+ branch.setBoolPref(name, value);
+ break;
+ case 'number':
+ // must be integer, ignore otherwise
+ if (value % 1 === 0) {
+ branch.setIntPref(name, value);
+ }
+ break;
+ case 'string':
+ let str = Cc["@mozilla.org/supports-string;1"].
+ createInstance(Ci.nsISupportsString);
+ str.data = value;
+ branch.setComplexValue(name, Ci.nsISupportsString, str);
+ break;
+ }
+ }
+}
+exports.setDefaults = setDefaults;
+
+// dynamically injects inline options into about:addons page at runtime
+// NOTE: on Firefox Desktop the about:addons page is a xul page document,
+// on Firefox for Android the about:addons page is an xhtml page, to support both
+// the XUL xml namespace have to be enforced.
+function injectOptions({ preferences, preferencesBranch, document, parent, id }) {
+ preferences.forEach(({name, type, hidden, title, description, label, options, on, off}) => {
+ if (hidden) {
+ return;
+ }
+
+ let setting = document.createElementNS(XUL_NS, 'setting');
+ setting.setAttribute('pref-name', name);
+ setting.setAttribute('data-jetpack-id', id);
+ setting.setAttribute('pref', 'extensions.' + preferencesBranch + '.' + name);
+ setting.setAttribute('type', type);
+ setting.setAttribute('title', title);
+ if (description)
+ setting.setAttribute('desc', description);
+
+ if (type === 'file' || type === 'directory') {
+ setting.setAttribute('fullpath', 'true');
+ }
+ else if (type === 'control') {
+ let button = document.createElementNS(XUL_NS, 'button');
+ button.setAttribute('pref-name', name);
+ button.setAttribute('data-jetpack-id', id);
+ button.setAttribute('label', label);
+ button.addEventListener('command', function() {
+ Services.obs.notifyObservers(null, `${id}-cmdPressed`, name);
+ }, true);
+ setting.appendChild(button);
+ }
+ else if (type === 'boolint') {
+ setting.setAttribute('on', on);
+ setting.setAttribute('off', off);
+ }
+ else if (type === 'menulist') {
+ let menulist = document.createElementNS(XUL_NS, 'menulist');
+ let menupopup = document.createElementNS(XUL_NS, 'menupopup');
+ for (let { value, label } of options) {
+ let menuitem = document.createElementNS(XUL_NS, 'menuitem');
+ menuitem.setAttribute('value', value);
+ menuitem.setAttribute('label', label);
+ menupopup.appendChild(menuitem);
+ }
+ menulist.appendChild(menupopup);
+ setting.appendChild(menulist);
+ }
+ else if (type === 'radio') {
+ let radiogroup = document.createElementNS(XUL_NS, 'radiogroup');
+ for (let { value, label } of options) {
+ let radio = document.createElementNS(XUL_NS, 'radio');
+ radio.setAttribute('value', value);
+ radio.setAttribute('label', label);
+ radiogroup.appendChild(radio);
+ }
+ setting.appendChild(radiogroup);
+ }
+
+ parent.appendChild(setting);
+ });
+}
+exports.injectOptions = injectOptions;
diff --git a/toolkit/jetpack/sdk/preferences/service.js b/toolkit/jetpack/sdk/preferences/service.js
new file mode 100644
index 000000000..231cd8e14
--- /dev/null
+++ b/toolkit/jetpack/sdk/preferences/service.js
@@ -0,0 +1,137 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+// The minimum and maximum integers that can be set as preferences.
+// The range of valid values is narrower than the range of valid JS values
+// because the native preferences code treats integers as NSPR PRInt32s,
+// which are 32-bit signed integers on all platforms.
+const MAX_INT = 0x7FFFFFFF;
+const MIN_INT = -0x80000000;
+
+const {Cc,Ci,Cr} = require("chrome");
+
+const prefService = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefService);
+const prefSvc = prefService.getBranch(null);
+const defaultBranch = prefService.getDefaultBranch(null);
+
+const { Preferences } = require("resource://gre/modules/Preferences.jsm");
+const prefs = new Preferences({});
+
+const branchKeys = branchName =>
+ keys(branchName).map($ => $.replace(branchName, ""));
+
+const Branch = function(branchName) {
+ return new Proxy(Branch.prototype, {
+ getOwnPropertyDescriptor(target, name, receiver) {
+ return {
+ configurable: true,
+ enumerable: true,
+ writable: false,
+ value: this.get(target, name, receiver)
+ };
+ },
+ ownKeys(target) {
+ return branchKeys(branchName);
+ },
+ get(target, name, receiver) {
+ return get(`${branchName}${name}`);
+ },
+ set(target, name, value, receiver) {
+ set(`${branchName}${name}`, value);
+ return true;
+ },
+ has(target, name) {
+ return this.hasOwn(target, name);
+ },
+ hasOwn(target, name) {
+ return has(`${branchName}${name}`);
+ },
+ deleteProperty(target, name) {
+ reset(`${branchName}${name}`);
+ return true;
+ }
+ });
+}
+
+
+function get(name, defaultValue) {
+ return prefs.get(name, defaultValue);
+}
+exports.get = get;
+
+
+function set(name, value) {
+ var prefType;
+ if (typeof value != "undefined" && value != null)
+ prefType = value.constructor.name;
+
+ switch (prefType) {
+ case "Number":
+ if (value % 1 != 0)
+ throw new Error("cannot store non-integer number: " + value);
+ }
+
+ prefs.set(name, value);
+}
+exports.set = set;
+
+const has = prefs.has.bind(prefs)
+exports.has = has;
+
+function keys(root) {
+ return prefSvc.getChildList(root);
+}
+exports.keys = keys;
+
+const isSet = prefs.isSet.bind(prefs);
+exports.isSet = isSet;
+
+function reset(name) {
+ try {
+ prefSvc.clearUserPref(name);
+ }
+ catch (e) {
+ // The pref service throws NS_ERROR_UNEXPECTED when the caller tries
+ // to reset a pref that doesn't exist or is already set to its default
+ // value. This interface fails silently in those cases, so callers
+ // can unconditionally reset a pref without having to check if it needs
+ // resetting first or trap exceptions after the fact. It passes through
+ // other exceptions, however, so callers know about them, since we don't
+ // know what other exceptions might be thrown and what they might mean.
+ if (e.result != Cr.NS_ERROR_UNEXPECTED) {
+ throw e;
+ }
+ }
+}
+exports.reset = reset;
+
+function getLocalized(name, defaultValue) {
+ let value = null;
+ try {
+ value = prefSvc.getComplexValue(name, Ci.nsIPrefLocalizedString).data;
+ }
+ finally {
+ return value || defaultValue;
+ }
+}
+exports.getLocalized = getLocalized;
+
+function setLocalized(name, value) {
+ // We can't use `prefs.set` here as we have to use `getDefaultBranch`
+ // (instead of `getBranch`) in order to have `mIsDefault` set to true, here:
+ // http://mxr.mozilla.org/mozilla-central/source/modules/libpref/src/nsPrefBranch.cpp#233
+ // Otherwise, we do not enter into this expected condition:
+ // http://mxr.mozilla.org/mozilla-central/source/modules/libpref/src/nsPrefBranch.cpp#244
+ defaultBranch.setCharPref(name, value);
+}
+exports.setLocalized = setLocalized;
+
+exports.Branch = Branch;
+
diff --git a/toolkit/jetpack/sdk/preferences/utils.js b/toolkit/jetpack/sdk/preferences/utils.js
new file mode 100644
index 000000000..1d5769c37
--- /dev/null
+++ b/toolkit/jetpack/sdk/preferences/utils.js
@@ -0,0 +1,42 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { openTab, getBrowserForTab, getTabId } = require("sdk/tabs/utils");
+const { on, off } = require("sdk/system/events");
+const { getMostRecentBrowserWindow } = require('../window/utils');
+
+// Opens about:addons in a new tab, then displays the inline
+// preferences of the provided add-on
+const open = ({ id }) => new Promise((resolve, reject) => {
+ // opening the about:addons page in a new tab
+ let tab = openTab(getMostRecentBrowserWindow(), "about:addons");
+ let browser = getBrowserForTab(tab);
+
+ // waiting for the about:addons page to load
+ browser.addEventListener("load", function onPageLoad() {
+ browser.removeEventListener("load", onPageLoad, true);
+ let window = browser.contentWindow;
+
+ // wait for the add-on's "addon-options-displayed"
+ on("addon-options-displayed", function onPrefDisplayed({ subject: doc, data }) {
+ if (data === id) {
+ off("addon-options-displayed", onPrefDisplayed);
+ resolve({
+ id: id,
+ tabId: getTabId(tab),
+ "document": doc
+ });
+ }
+ }, true);
+
+ // display the add-on inline preferences page
+ window.gViewController.commands.cmd_showItemDetails.doCommand({ id: id }, true);
+ }, true);
+});
+exports.open = open;
diff --git a/toolkit/jetpack/sdk/private-browsing.js b/toolkit/jetpack/sdk/private-browsing.js
new file mode 100644
index 000000000..29ca16185
--- /dev/null
+++ b/toolkit/jetpack/sdk/private-browsing.js
@@ -0,0 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { isPrivate } = require('./private-browsing/utils');
+
+exports.isPrivate = isPrivate;
diff --git a/toolkit/jetpack/sdk/private-browsing/utils.js b/toolkit/jetpack/sdk/private-browsing/utils.js
new file mode 100644
index 000000000..8b012f0ce
--- /dev/null
+++ b/toolkit/jetpack/sdk/private-browsing/utils.js
@@ -0,0 +1,54 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci, Cu } = require('chrome');
+const { is } = require('../system/xul-app');
+const { isWindowPrivate } = require('../window/utils');
+const { isPrivateBrowsingSupported } = require('../self');
+const { dispatcher } = require("../util/dispatcher");
+
+var PrivateBrowsingUtils;
+
+// Private browsing is only supported in Fx
+try {
+ PrivateBrowsingUtils = Cu.import('resource://gre/modules/PrivateBrowsingUtils.jsm', {}).PrivateBrowsingUtils;
+}
+catch (e) {}
+
+exports.isGlobalPBSupported = false;
+
+// checks that per-window private browsing is implemented
+var isWindowPBSupported = exports.isWindowPBSupported =
+ !!PrivateBrowsingUtils && is('Firefox');
+
+// checks that per-tab private browsing is implemented
+var isTabPBSupported = exports.isTabPBSupported =
+ !!PrivateBrowsingUtils && is('Fennec');
+
+function isPermanentPrivateBrowsing() {
+ return !!(PrivateBrowsingUtils && PrivateBrowsingUtils.permanentPrivateBrowsing);
+}
+exports.isPermanentPrivateBrowsing = isPermanentPrivateBrowsing;
+
+function ignoreWindow(window) {
+ return !isPrivateBrowsingSupported && isWindowPrivate(window);
+}
+exports.ignoreWindow = ignoreWindow;
+
+var getMode = function getMode(chromeWin) {
+ return (chromeWin !== undefined && isWindowPrivate(chromeWin));
+};
+exports.getMode = getMode;
+
+const isPrivate = dispatcher("isPrivate");
+isPrivate.when(isPermanentPrivateBrowsing, _ => true);
+isPrivate.when(x => x instanceof Ci.nsIDOMWindow, isWindowPrivate);
+isPrivate.when(x => Ci.nsIPrivateBrowsingChannel && x instanceof Ci.nsIPrivateBrowsingChannel, x => x.isChannelPrivate);
+isPrivate.define(() => false);
+exports.isPrivate = isPrivate;
diff --git a/toolkit/jetpack/sdk/querystring.js b/toolkit/jetpack/sdk/querystring.js
new file mode 100644
index 000000000..9982a00ab
--- /dev/null
+++ b/toolkit/jetpack/sdk/querystring.js
@@ -0,0 +1,121 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+var unescape = decodeURIComponent;
+exports.unescape = unescape;
+
+// encodes a string safely for application/x-www-form-urlencoded
+// adheres to RFC 3986
+// see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent
+function escape(query) {
+ return encodeURIComponent(query).
+ replace(/%20/g, '+').
+ replace(/!/g, '%21').
+ replace(/'/g, '%27').
+ replace(/\(/g, '%28').
+ replace(/\)/g, '%29').
+ replace(/\*/g, '%2A');
+}
+exports.escape = escape;
+
+// Converts an object of unordered key-vals to a string that can be passed
+// as part of a request
+function stringify(options, separator, assigner) {
+ separator = separator || '&';
+ assigner = assigner || '=';
+ // Explicitly return null if we have null, and empty string, or empty object.
+ if (!options)
+ return '';
+
+ // If content is already a string, just return it as is.
+ if (typeof(options) == 'string')
+ return options;
+
+ // At this point we have a k:v object. Iterate over it and encode each value.
+ // Arrays and nested objects will get encoded as needed. For example...
+ //
+ // { foo: [1, 2, { omg: 'bbq', 'all your base!': 'are belong to us' }], bar: 'baz' }
+ //
+ // will be encoded as
+ //
+ // foo[0]=1&foo[1]=2&foo[2][omg]=bbq&foo[2][all+your+base!]=are+belong+to+us&bar=baz
+ //
+ // Keys (including '[' and ']') and values will be encoded with
+ // `escape` before returning.
+ //
+ // Execution was inspired by jQuery, but some details have changed and numeric
+ // array keys are included (whereas they are not in jQuery).
+
+ let encodedContent = [];
+ function add(key, val) {
+ encodedContent.push(escape(key) + assigner + escape(val));
+ }
+
+ function make(key, value) {
+ if (value && typeof(value) === 'object')
+ Object.keys(value).forEach(function(name) {
+ make(key + '[' + name + ']', value[name]);
+ });
+ else
+ add(key, value);
+ }
+
+ Object.keys(options).forEach(function(name) { make(name, options[name]); });
+ return encodedContent.join(separator);
+
+ //XXXzpao In theory, we can just use a FormData object on 1.9.3, but I had
+ // trouble getting that working. It would also be nice to stay
+ // backwards-compat as long as possible. Keeping this in for now...
+ // let formData = Cc['@mozilla.org/files/formdata;1'].
+ // createInstance(Ci.nsIDOMFormData);
+ // for ([k, v] in Iterator(content)) {
+ // formData.append(k, v);
+ // }
+ // return formData;
+}
+exports.stringify = stringify;
+
+// Exporting aliases that nodejs implements just for the sake of
+// interoperability.
+exports.encode = stringify;
+exports.serialize = stringify;
+
+// Note: That `stringify` and `parse` aren't bijective as we use `stringify`
+// as it was implement in request module, but implement `parse` to match nodejs
+// behavior.
+// TODO: Make `stringify` implement API as in nodejs and figure out backwards
+// compatibility.
+function parse(query, separator, assigner) {
+ separator = separator || '&';
+ assigner = assigner || '=';
+ let result = {};
+
+ if (typeof query !== 'string' || query.length === 0)
+ return result;
+
+ query.split(separator).forEach(function(chunk) {
+ let pair = chunk.split(assigner);
+ let key = unescape(pair[0]);
+ let value = unescape(pair.slice(1).join(assigner));
+
+ if (!(key in result))
+ result[key] = value;
+ else if (Array.isArray(result[key]))
+ result[key].push(value);
+ else
+ result[key] = [result[key], value];
+ });
+
+ return result;
+};
+exports.parse = parse;
+// Exporting aliases that nodejs implements just for the sake of
+// interoperability.
+exports.decode = parse;
diff --git a/toolkit/jetpack/sdk/remote/child.js b/toolkit/jetpack/sdk/remote/child.js
new file mode 100644
index 000000000..4ccfa661a
--- /dev/null
+++ b/toolkit/jetpack/sdk/remote/child.js
@@ -0,0 +1,284 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { isChildLoader } = require('./core');
+if (!isChildLoader)
+ throw new Error("Cannot load sdk/remote/child in a main process loader.");
+
+const { Ci, Cc, Cu } = require('chrome');
+const runtime = require('../system/runtime');
+const { Class } = require('../core/heritage');
+const { Namespace } = require('../core/namespace');
+const { omit } = require('../util/object');
+const { when } = require('../system/unload');
+const { EventTarget } = require('../event/target');
+const { emit } = require('../event/core');
+const { Disposable } = require('../core/disposable');
+const { EventParent } = require('./utils');
+const { addListItem, removeListItem } = require('../util/list');
+
+const loaderID = require('@loader/options').loaderID;
+
+const MAIN_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
+
+const mm = Cc['@mozilla.org/childprocessmessagemanager;1'].
+ getService(Ci.nsISyncMessageSender);
+
+const ns = Namespace();
+
+const process = {
+ port: new EventTarget(),
+ get id() {
+ return runtime.processID;
+ },
+ get isRemote() {
+ return runtime.processType != MAIN_PROCESS;
+ }
+};
+exports.process = process;
+
+function definePort(obj, name) {
+ obj.port.emit = (event, ...args) => {
+ let manager = ns(obj).messageManager;
+ if (!manager)
+ return;
+
+ manager.sendAsyncMessage(name, { loaderID, event, args });
+ };
+}
+
+function messageReceived({ data, objects }) {
+ // Ignore messages from other loaders
+ if (data.loaderID != loaderID)
+ return;
+
+ let keys = Object.keys(objects);
+ if (keys.length) {
+ // If any objects are CPOWs then ignore this message. We don't want child
+ // processes interracting with CPOWs
+ if (!keys.every(name => !Cu.isCrossProcessWrapper(objects[name])))
+ return;
+
+ data.args.push(objects);
+ }
+
+ emit(this.port, data.event, this, ...data.args);
+}
+
+ns(process).messageManager = mm;
+definePort(process, 'sdk/remote/process/message');
+let processMessageReceived = messageReceived.bind(process);
+mm.addMessageListener('sdk/remote/process/message', processMessageReceived);
+
+when(() => {
+ mm.removeMessageListener('sdk/remote/process/message', processMessageReceived);
+ frames = null;
+});
+
+process.port.on('sdk/remote/require', (process, uri) => {
+ require(uri);
+});
+
+function listenerEquals(a, b) {
+ for (let prop of ["type", "callback", "isCapturing"]) {
+ if (a[prop] != b[prop])
+ return false;
+ }
+ return true;
+}
+
+function listenerFor(type, callback, isCapturing = false) {
+ return {
+ type,
+ callback,
+ isCapturing,
+ registeredCallback: undefined,
+ get args() {
+ return [
+ this.type,
+ this.registeredCallback ? this.registeredCallback : this.callback,
+ this.isCapturing
+ ];
+ }
+ };
+}
+
+function removeListenerFromArray(array, listener) {
+ let index = array.findIndex(l => listenerEquals(l, listener));
+ if (index < 0)
+ return;
+ array.splice(index, 1);
+}
+
+function getListenerFromArray(array, listener) {
+ return array.find(l => listenerEquals(l, listener));
+}
+
+function arrayContainsListener(array, listener) {
+ return !!getListenerFromArray(array, listener);
+}
+
+function makeFrameEventListener(frame, callback) {
+ return callback.bind(frame);
+}
+
+var FRAME_ID = 0;
+var tabMap = new Map();
+
+const Frame = Class({
+ implements: [ Disposable ],
+ extends: EventTarget,
+ setup: function(contentFrame) {
+ // This ID should be unique for this loader across all processes
+ let priv = ns(this);
+
+ priv.id = runtime.processID + ":" + FRAME_ID++;
+
+ priv.contentFrame = contentFrame;
+ priv.messageManager = contentFrame;
+ priv.domListeners = [];
+
+ tabMap.set(contentFrame.docShell, this);
+
+ priv.messageReceived = messageReceived.bind(this);
+ priv.messageManager.addMessageListener('sdk/remote/frame/message', priv.messageReceived);
+
+ this.port = new EventTarget();
+ definePort(this, 'sdk/remote/frame/message');
+
+ priv.messageManager.sendAsyncMessage('sdk/remote/frame/attach', {
+ loaderID,
+ frameID: priv.id,
+ processID: runtime.processID
+ });
+
+ frames.attachItem(this);
+ },
+
+ dispose: function() {
+ let priv = ns(this);
+
+ emit(this, 'detach', this);
+
+ for (let listener of priv.domListeners)
+ priv.contentFrame.removeEventListener(...listener.args);
+
+ priv.messageManager.removeMessageListener('sdk/remote/frame/message', priv.messageReceived);
+ tabMap.delete(priv.contentFrame.docShell);
+ priv.contentFrame = null;
+ },
+
+ get content() {
+ return ns(this).contentFrame.content;
+ },
+
+ get isTab() {
+ let docShell = ns(this).contentFrame.docShell;
+ if (process.isRemote) {
+ // We don't want to roundtrip to the main process to get this property.
+ // This hack relies on the host app having defined webBrowserChrome only
+ // in frames that are part of the tabs. Since only Firefox has remote
+ // processes right now and does this this works.
+ let tabchild = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsITabChild);
+ return !!tabchild.webBrowserChrome;
+ }
+ else {
+ // This is running in the main process so we can break out to the browser
+ // And check we can find a tab for the browser element directly.
+ let browser = docShell.chromeEventHandler;
+ let tab = require('../tabs/utils').getTabForBrowser(browser);
+ return !!tab;
+ }
+ },
+
+ addEventListener: function(...args) {
+ let priv = ns(this);
+
+ let listener = listenerFor(...args);
+ if (arrayContainsListener(priv.domListeners, listener))
+ return;
+
+ listener.registeredCallback = makeFrameEventListener(this, listener.callback);
+
+ priv.domListeners.push(listener);
+ priv.contentFrame.addEventListener(...listener.args);
+ },
+
+ removeEventListener: function(...args) {
+ let priv = ns(this);
+
+ let listener = getListenerFromArray(priv.domListeners, listenerFor(...args));
+ if (!listener)
+ return;
+
+ removeListenerFromArray(priv.domListeners, listener);
+ priv.contentFrame.removeEventListener(...listener.args);
+ }
+});
+
+const FrameList = Class({
+ implements: [ EventParent, Disposable ],
+ extends: EventTarget,
+ setup: function() {
+ EventParent.prototype.initialize.call(this);
+
+ this.port = new EventTarget();
+ ns(this).domListeners = [];
+
+ this.on('attach', frame => {
+ for (let listener of ns(this).domListeners)
+ frame.addEventListener(...listener.args);
+ });
+ },
+
+ dispose: function() {
+ // The only case where we get destroyed is when the loader is unloaded in
+ // which case each frame will clean up its own event listeners.
+ ns(this).domListeners = null;
+ },
+
+ getFrameForWindow: function(window) {
+ let docShell = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDocShell);
+
+ return tabMap.get(docShell) || null;
+ },
+
+ addEventListener: function(...args) {
+ let listener = listenerFor(...args);
+ if (arrayContainsListener(ns(this).domListeners, listener))
+ return;
+
+ ns(this).domListeners.push(listener);
+ for (let frame of this)
+ frame.addEventListener(...listener.args);
+ },
+
+ removeEventListener: function(...args) {
+ let listener = listenerFor(...args);
+ if (!arrayContainsListener(ns(this).domListeners, listener))
+ return;
+
+ removeListenerFromArray(ns(this).domListeners, listener);
+ for (let frame of this)
+ frame.removeEventListener(...listener.args);
+ }
+});
+var frames = exports.frames = new FrameList();
+
+function registerContentFrame(contentFrame) {
+ let frame = new Frame(contentFrame);
+}
+exports.registerContentFrame = registerContentFrame;
+
+function unregisterContentFrame(contentFrame) {
+ let frame = tabMap.get(contentFrame.docShell);
+ if (!frame)
+ return;
+
+ frame.destroy();
+}
+exports.unregisterContentFrame = unregisterContentFrame;
diff --git a/toolkit/jetpack/sdk/remote/core.js b/toolkit/jetpack/sdk/remote/core.js
new file mode 100644
index 000000000..78bb673fd
--- /dev/null
+++ b/toolkit/jetpack/sdk/remote/core.js
@@ -0,0 +1,8 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const options = require("@loader/options");
+
+exports.isChildLoader = options.childLoader;
diff --git a/toolkit/jetpack/sdk/remote/parent.js b/toolkit/jetpack/sdk/remote/parent.js
new file mode 100644
index 000000000..f110fe3f6
--- /dev/null
+++ b/toolkit/jetpack/sdk/remote/parent.js
@@ -0,0 +1,338 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { isChildLoader } = require('./core');
+if (isChildLoader)
+ throw new Error("Cannot load sdk/remote/parent in a child loader.");
+
+const { Cu, Ci, Cc } = require('chrome');
+const runtime = require('../system/runtime');
+
+const MAIN_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
+
+if (runtime.processType != MAIN_PROCESS) {
+ throw new Error('Cannot use sdk/remote/parent in a child process.');
+}
+
+const { Class } = require('../core/heritage');
+const { Namespace } = require('../core/namespace');
+const { Disposable } = require('../core/disposable');
+const { omit } = require('../util/object');
+const { when } = require('../system/unload');
+const { EventTarget } = require('../event/target');
+const { emit } = require('../event/core');
+const system = require('../system/events');
+const { EventParent } = require('./utils');
+const options = require('@loader/options');
+const loaderModule = require('toolkit/loader');
+const { getTabForBrowser } = require('../tabs/utils');
+
+const appInfo = Cc["@mozilla.org/xre/app-info;1"].
+ getService(Ci.nsIXULRuntime);
+
+exports.useRemoteProcesses = appInfo.browserTabsRemoteAutostart;
+
+// Chose the right function for resolving relative a module id
+var moduleResolve;
+if (options.isNative) {
+ moduleResolve = (id, requirer) => loaderModule.nodeResolve(id, requirer, { rootURI: options.rootURI });
+}
+else {
+ moduleResolve = loaderModule.resolve;
+}
+// Build the sorted path mapping structure that resolveURI requires
+var pathMapping = Object.keys(options.paths)
+ .sort((a, b) => b.length - a.length)
+ .map(p => [p, options.paths[p]]);
+
+// Load the scripts in the child processes
+var { getNewLoaderID } = require('../../framescript/FrameScriptManager.jsm');
+var PATH = options.paths[''];
+
+const childOptions = omit(options, ['modules', 'globals', 'resolve', 'load']);
+childOptions.modules = {};
+// @l10n/data is just JSON data and can be safely sent across to the child loader
+try {
+ childOptions.modules["@l10n/data"] = require("@l10n/data");
+}
+catch (e) {
+ // There may be no l10n data
+}
+const loaderID = getNewLoaderID();
+childOptions.loaderID = loaderID;
+childOptions.childLoader = true;
+
+const ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1'].
+ getService(Ci.nsIMessageBroadcaster);
+const gmm = Cc['@mozilla.org/globalmessagemanager;1'].
+ getService(Ci.nsIMessageBroadcaster);
+
+const ns = Namespace();
+
+var processMap = new Map();
+
+function definePort(obj, name) {
+ obj.port.emitCPOW = (event, args, cpows = {}) => {
+ let manager = ns(obj).messageManager;
+ if (!manager)
+ return;
+
+ let method = manager instanceof Ci.nsIMessageBroadcaster ?
+ "broadcastAsyncMessage" : "sendAsyncMessage";
+
+ manager[method](name, { loaderID, event, args }, cpows);
+ };
+
+ obj.port.emit = (event, ...args) => obj.port.emitCPOW(event, args);
+}
+
+function messageReceived({ target, data }) {
+ // Ignore messages from other loaders
+ if (data.loaderID != loaderID)
+ return;
+
+ emit(this.port, data.event, this, ...data.args);
+}
+
+// Process represents a gecko process that can load webpages. Each process
+// contains a number of Frames. This class is used to send and receive messages
+// from a single process.
+const Process = Class({
+ implements: [ Disposable ],
+ extends: EventTarget,
+ setup: function(id, messageManager, isRemote) {
+ ns(this).id = id;
+ ns(this).isRemote = isRemote;
+ ns(this).messageManager = messageManager;
+ ns(this).messageReceived = messageReceived.bind(this);
+ this.destroy = this.destroy.bind(this);
+ ns(this).messageManager.addMessageListener('sdk/remote/process/message', ns(this).messageReceived);
+ ns(this).messageManager.addMessageListener('child-process-shutdown', this.destroy);
+
+ this.port = new EventTarget();
+ definePort(this, 'sdk/remote/process/message');
+
+ // Load any remote modules
+ for (let module of remoteModules.values())
+ this.port.emit('sdk/remote/require', module);
+
+ processMap.set(ns(this).id, this);
+ processes.attachItem(this);
+ },
+
+ dispose: function() {
+ emit(this, 'detach', this);
+ processMap.delete(ns(this).id);
+ ns(this).messageManager.removeMessageListener('sdk/remote/process/message', ns(this).messageReceived);
+ ns(this).messageManager.removeMessageListener('child-process-shutdown', this.destroy);
+ ns(this).messageManager = null;
+ },
+
+ // Returns true if this process is a child process
+ get isRemote() {
+ return ns(this).isRemote;
+ }
+});
+
+// Processes gives an API for enumerating an sending and receiving messages from
+// all processes as well as detecting when a new process starts.
+const Processes = Class({
+ implements: [ EventParent ],
+ extends: EventTarget,
+ initialize: function() {
+ EventParent.prototype.initialize.call(this);
+ ns(this).messageManager = ppmm;
+
+ this.port = new EventTarget();
+ definePort(this, 'sdk/remote/process/message');
+ },
+
+ getById: function(id) {
+ return processMap.get(id);
+ }
+});
+var processes = exports.processes = new Processes();
+
+var frameMap = new Map();
+
+function setFrameProcess(frame, process) {
+ ns(frame).process = process;
+ frames.attachItem(frame);
+}
+
+// Frames display webpages in a process. In the main process every Frame is
+// linked with a <browser> or <iframe> element.
+const Frame = Class({
+ implements: [ Disposable ],
+ extends: EventTarget,
+ setup: function(id, node) {
+ ns(this).id = id;
+ ns(this).node = node;
+
+ let frameLoader = node.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
+ ns(this).messageManager = frameLoader.messageManager;
+
+ ns(this).messageReceived = messageReceived.bind(this);
+ ns(this).messageManager.addMessageListener('sdk/remote/frame/message', ns(this).messageReceived);
+
+ this.port = new EventTarget();
+ definePort(this, 'sdk/remote/frame/message');
+
+ frameMap.set(ns(this).messageManager, this);
+ },
+
+ dispose: function() {
+ emit(this, 'detach', this);
+ ns(this).messageManager.removeMessageListener('sdk/remote/frame/message', ns(this).messageReceived);
+
+ frameMap.delete(ns(this).messageManager);
+ ns(this).messageManager = null;
+ },
+
+ // Returns the browser or iframe element this frame displays in
+ get frameElement() {
+ return ns(this).node;
+ },
+
+ // Returns the process that this frame loads in
+ get process() {
+ return ns(this).process;
+ },
+
+ // Returns true if this frame is a tab in a main browser window
+ get isTab() {
+ let tab = getTabForBrowser(ns(this).node);
+ return !!tab;
+ }
+});
+
+function managerDisconnected({ subject: manager }) {
+ let frame = frameMap.get(manager);
+ if (frame)
+ frame.destroy();
+}
+system.on('message-manager-disconnect', managerDisconnected);
+
+// Provides an API for enumerating and sending and receiving messages from all
+// Frames
+const FrameList = Class({
+ implements: [ EventParent ],
+ extends: EventTarget,
+ initialize: function() {
+ EventParent.prototype.initialize.call(this);
+ ns(this).messageManager = gmm;
+
+ this.port = new EventTarget();
+ definePort(this, 'sdk/remote/frame/message');
+ },
+
+ // Returns the frame for a browser element
+ getFrameForBrowser: function(browser) {
+ for (let frame of this) {
+ if (frame.frameElement == browser)
+ return frame;
+ }
+ return null;
+ },
+});
+var frames = exports.frames = new FrameList();
+
+// Create the module loader in any existing processes
+ppmm.broadcastAsyncMessage('sdk/remote/process/load', {
+ modulePath: PATH,
+ loaderID,
+ options: childOptions,
+ reason: "broadcast"
+});
+
+// A loader has started in a remote process
+function processLoaderStarted({ target, data }) {
+ if (data.loaderID != loaderID)
+ return;
+
+ if (processMap.has(data.processID)) {
+ console.error("Saw the same process load the same loader twice. This is a bug in the SDK.");
+ return;
+ }
+
+ let process = new Process(data.processID, target, data.isRemote);
+
+ if (pendingFrames.has(data.processID)) {
+ for (let frame of pendingFrames.get(data.processID))
+ setFrameProcess(frame, process);
+ pendingFrames.delete(data.processID);
+ }
+}
+
+// A new process has started
+function processStarted({ target, data: { modulePath } }) {
+ if (modulePath != PATH)
+ return;
+
+ // Have it load a loader if it hasn't already
+ target.sendAsyncMessage('sdk/remote/process/load', {
+ modulePath,
+ loaderID,
+ options: childOptions,
+ reason: "response"
+ });
+}
+
+var pendingFrames = new Map();
+
+// A new frame has been created in the remote process
+function frameAttached({ target, data }) {
+ if (data.loaderID != loaderID)
+ return;
+
+ let frame = new Frame(data.frameID, target);
+
+ let process = processMap.get(data.processID);
+ if (process) {
+ setFrameProcess(frame, process);
+ return;
+ }
+
+ // In some cases frame messages can arrive earlier than process messages
+ // causing us to see a new frame appear before its process. In this case
+ // cache the frame data until we see the process. See bug 1131375.
+ if (!pendingFrames.has(data.processID))
+ pendingFrames.set(data.processID, [frame]);
+ else
+ pendingFrames.get(data.processID).push(frame);
+}
+
+// Wait for new processes and frames
+ppmm.addMessageListener('sdk/remote/process/attach', processLoaderStarted);
+ppmm.addMessageListener('sdk/remote/process/start', processStarted);
+gmm.addMessageListener('sdk/remote/frame/attach', frameAttached);
+
+when(reason => {
+ ppmm.removeMessageListener('sdk/remote/process/attach', processLoaderStarted);
+ ppmm.removeMessageListener('sdk/remote/process/start', processStarted);
+ gmm.removeMessageListener('sdk/remote/frame/attach', frameAttached);
+
+ ppmm.broadcastAsyncMessage('sdk/remote/process/unload', { loaderID, reason });
+});
+
+var remoteModules = new Set();
+
+// Ensures a module is loaded in every child process. It is safe to send
+// messages to this module immediately after calling this.
+// Pass a module to resolve the id relatively.
+function remoteRequire(id, module = null) {
+ // Resolve relative to calling module if passed
+ if (module)
+ id = moduleResolve(id, module.id);
+ let uri = loaderModule.resolveURI(id, pathMapping);
+
+ // Don't reload the same module
+ if (remoteModules.has(uri))
+ return;
+
+ remoteModules.add(uri);
+ processes.port.emit('sdk/remote/require', uri);
+}
+exports.remoteRequire = remoteRequire;
diff --git a/toolkit/jetpack/sdk/remote/utils.js b/toolkit/jetpack/sdk/remote/utils.js
new file mode 100644
index 000000000..5a5e39198
--- /dev/null
+++ b/toolkit/jetpack/sdk/remote/utils.js
@@ -0,0 +1,39 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Class } = require('../core/heritage');
+const { List, addListItem, removeListItem } = require('../util/list');
+const { emit } = require('../event/core');
+const { pipe } = require('../event/utils');
+
+// A helper class that maintains a list of EventTargets. Any events emitted
+// to an EventTarget are also emitted by the EventParent. Likewise for an
+// EventTarget's port property.
+const EventParent = Class({
+ implements: [ List ],
+
+ attachItem: function(item) {
+ addListItem(this, item);
+
+ pipe(item.port, this.port);
+ pipe(item, this);
+
+ item.once('detach', () => {
+ removeListItem(this, item);
+ })
+
+ emit(this, 'attach', item);
+ },
+
+ // Calls listener for every object already in the list and every object
+ // subsequently added to the list.
+ forEvery: function(listener) {
+ for (let item of this)
+ listener(item);
+
+ this.on('attach', listener);
+ }
+});
+exports.EventParent = EventParent;
diff --git a/toolkit/jetpack/sdk/request.js b/toolkit/jetpack/sdk/request.js
new file mode 100644
index 000000000..96bb1e6d7
--- /dev/null
+++ b/toolkit/jetpack/sdk/request.js
@@ -0,0 +1,248 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { ns } = require("./core/namespace");
+const { emit } = require("./event/core");
+const { merge } = require("./util/object");
+const { stringify } = require("./querystring");
+const { EventTarget } = require("./event/target");
+const { Class } = require("./core/heritage");
+const { XMLHttpRequest, forceAllowThirdPartyCookie } = require("./net/xhr");
+const apiUtils = require("./deprecated/api-utils");
+const { isValidURI } = require("./url.js");
+
+const response = ns();
+const request = ns();
+
+// Instead of creating a new validator for each request, just make one and
+// reuse it.
+const { validateOptions, validateSingleOption } = new OptionsValidator({
+ url: {
+ // Also converts a URL instance to string, bug 857902
+ map: url => url.toString(),
+ ok: isValidURI
+ },
+ headers: {
+ map: v => v || {},
+ is: ["object"],
+ },
+ content: {
+ map: v => v || null,
+ is: ["string", "object", "null"],
+ },
+ contentType: {
+ map: v => v || "application/x-www-form-urlencoded",
+ is: ["string"],
+ },
+ overrideMimeType: {
+ map: v => v || null,
+ is: ["string", "null"],
+ },
+ anonymous: {
+ map: v => v || false,
+ is: ["boolean", "null"],
+ }
+});
+
+const REUSE_ERROR = "This request object has been used already. You must " +
+ "create a new one to make a new request."
+
+// Utility function to prep the request since it's the same between
+// request types
+function runRequest(mode, target) {
+ let source = request(target)
+ let { xhr, url, content, contentType, headers, overrideMimeType, anonymous } = source;
+
+ let isGetOrHead = (mode == "GET" || mode == "HEAD");
+
+ // If this request has already been used, then we can't reuse it.
+ // Throw an error.
+ if (xhr)
+ throw new Error(REUSE_ERROR);
+
+ xhr = source.xhr = new XMLHttpRequest({
+ mozAnon: anonymous
+ });
+
+ // Build the data to be set. For GET or HEAD requests, we want to append that
+ // to the URL before opening the request.
+ let data = stringify(content);
+ // If the URL already has ? in it, then we want to just use &
+ if (isGetOrHead && data)
+ url = url + (/\?/.test(url) ? "&" : "?") + data;
+
+ // open the request
+ xhr.open(mode, url);
+
+
+ forceAllowThirdPartyCookie(xhr);
+
+ // request header must be set after open, but before send
+ xhr.setRequestHeader("Content-Type", contentType);
+
+ // set other headers
+ Object.keys(headers).forEach(function(name) {
+ xhr.setRequestHeader(name, headers[name]);
+ });
+
+ // set overrideMimeType
+ if (overrideMimeType)
+ xhr.overrideMimeType(overrideMimeType);
+
+ // handle the readystate, create the response, and call the callback
+ xhr.onreadystatechange = function onreadystatechange() {
+ if (xhr.readyState === 4) {
+ let response = Response(xhr);
+ source.response = response;
+ emit(target, 'complete', response);
+ }
+ };
+
+ // actually send the request.
+ // We don't want to send data on GET or HEAD requests.
+ xhr.send(!isGetOrHead ? data : null);
+}
+
+const Request = Class({
+ extends: EventTarget,
+ initialize: function initialize(options) {
+ // `EventTarget.initialize` will set event listeners that are named
+ // like `onEvent` in this case `onComplete` listener will be set to
+ // `complete` event.
+ EventTarget.prototype.initialize.call(this, options);
+
+ // Copy normalized options.
+ merge(request(this), validateOptions(options));
+ },
+ get url() { return request(this).url; },
+ set url(value) { request(this).url = validateSingleOption('url', value); },
+ get headers() { return request(this).headers; },
+ set headers(value) {
+ return request(this).headers = validateSingleOption('headers', value);
+ },
+ get content() { return request(this).content; },
+ set content(value) {
+ request(this).content = validateSingleOption('content', value);
+ },
+ get contentType() { return request(this).contentType; },
+ set contentType(value) {
+ request(this).contentType = validateSingleOption('contentType', value);
+ },
+ get anonymous() { return request(this).anonymous; },
+ get response() { return request(this).response; },
+ delete: function() {
+ runRequest('DELETE', this);
+ return this;
+ },
+ get: function() {
+ runRequest('GET', this);
+ return this;
+ },
+ post: function() {
+ runRequest('POST', this);
+ return this;
+ },
+ put: function() {
+ runRequest('PUT', this);
+ return this;
+ },
+ head: function() {
+ runRequest('HEAD', this);
+ return this;
+ }
+});
+exports.Request = Request;
+
+const Response = Class({
+ initialize: function initialize(request) {
+ response(this).request = request;
+ },
+ // more about responseURL: https://bugzilla.mozilla.org/show_bug.cgi?id=998076
+ get url() {
+ return response(this).request.responseURL;
+ },
+ get text() {
+ return response(this).request.responseText;
+ },
+ get xml() {
+ throw new Error("Sorry, the 'xml' property is no longer available. " +
+ "see bug 611042 for more information.");
+ },
+ get status() {
+ return response(this).request.status;
+ },
+ get statusText() {
+ return response(this).request.statusText;
+ },
+ get json() {
+ try {
+ return JSON.parse(this.text);
+ } catch(error) {
+ return null;
+ }
+ },
+ get headers() {
+ let headers = {}, lastKey;
+ // Since getAllResponseHeaders() will return null if there are no headers,
+ // defend against it by defaulting to ""
+ let rawHeaders = response(this).request.getAllResponseHeaders() || "";
+ rawHeaders.split("\n").forEach(function (h) {
+ // According to the HTTP spec, the header string is terminated by an empty
+ // line, so we can just skip it.
+ if (!h.length) {
+ return;
+ }
+
+ let index = h.indexOf(":");
+ // The spec allows for leading spaces, so instead of assuming a single
+ // leading space, just trim the values.
+ let key = h.substring(0, index).trim(),
+ val = h.substring(index + 1).trim();
+
+ // For empty keys, that means that the header value spanned multiple lines.
+ // In that case we should append the value to the value of lastKey with a
+ // new line. We'll assume lastKey will be set because there should never
+ // be an empty key on the first pass.
+ if (key) {
+ headers[key] = val;
+ lastKey = key;
+ }
+ else {
+ headers[lastKey] += "\n" + val;
+ }
+ });
+ return headers;
+ },
+ get anonymous() {
+ return response(this).request.mozAnon;
+ }
+});
+
+// apiUtils.validateOptions doesn't give the ability to easily validate single
+// options, so this is a wrapper that provides that ability.
+function OptionsValidator(rules) {
+ return {
+ validateOptions: function (options) {
+ return apiUtils.validateOptions(options, rules);
+ },
+ validateSingleOption: function (field, value) {
+ // We need to create a single rule object from our listed rules. To avoid
+ // JavaScript String warnings, check for the field & default to an empty object.
+ let singleRule = {};
+ if (field in rules) {
+ singleRule[field] = rules[field];
+ }
+ let singleOption = {};
+ singleOption[field] = value;
+ // This should throw if it's invalid, which will bubble up & out.
+ return apiUtils.validateOptions(singleOption, singleRule)[field];
+ }
+ };
+}
diff --git a/toolkit/jetpack/sdk/selection.js b/toolkit/jetpack/sdk/selection.js
new file mode 100644
index 000000000..8682e8c6d
--- /dev/null
+++ b/toolkit/jetpack/sdk/selection.js
@@ -0,0 +1,470 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "stable",
+ "engines": {
+ "Firefox": "*",
+ "SeaMonkey": "*"
+ }
+};
+
+const { Ci, Cc } = require("chrome"),
+ { setTimeout } = require("./timers"),
+ { emit, off } = require("./event/core"),
+ { Class, obscure } = require("./core/heritage"),
+ { EventTarget } = require("./event/target"),
+ { ns } = require("./core/namespace"),
+ { when: unload } = require("./system/unload"),
+ { ignoreWindow } = require('./private-browsing/utils'),
+ { getTabs, getTabForContentWindow,
+ getAllTabContentWindows } = require('./tabs/utils'),
+ winUtils = require("./window/utils"),
+ events = require("./system/events");
+
+// The selection types
+const HTML = 0x01,
+ TEXT = 0x02,
+ DOM = 0x03; // internal use only
+
+// A more developer-friendly message than the caught exception when is not
+// possible change a selection.
+const ERR_CANNOT_CHANGE_SELECTION =
+ "It isn't possible to change the selection, as there isn't currently a selection";
+
+const selections = ns();
+
+const Selection = Class({
+ /**
+ * Creates an object from which a selection can be set, get, etc. Each
+ * object has an associated with a range number. Range numbers are the
+ * 0-indexed counter of selection ranges as explained at
+ * https://developer.mozilla.org/en/DOM/Selection.
+ *
+ * @param rangeNumber
+ * The zero-based range index into the selection
+ */
+ initialize: function initialize(rangeNumber) {
+ // In order to hide the private `rangeNumber` argument from API consumers
+ // while still enabling Selection getters/setters to access it, we define
+ // it as non enumerable, non configurable property. While consumers still
+ // may discover it they won't be able to do any harm which is good enough
+ // in this case.
+ Object.defineProperties(this, {
+ rangeNumber: {
+ enumerable: false,
+ configurable: false,
+ value: rangeNumber
+ }
+ });
+ },
+ get text() { return getSelection(TEXT, this.rangeNumber); },
+ set text(value) { setSelection(TEXT, value, this.rangeNumber); },
+ get html() { return getSelection(HTML, this.rangeNumber); },
+ set html(value) { setSelection(HTML, value, this.rangeNumber); },
+ get isContiguous() {
+
+ // If there are multiple non empty ranges, the selection is definitely
+ // discontiguous. It returns `false` also if there are no valid selection.
+ let count = 0;
+ for (let sel in selectionIterator)
+ if (++count > 1)
+ break;
+
+ return count === 1;
+ }
+});
+
+const selectionListener = {
+ notifySelectionChanged: function (document, selection, reason) {
+ if (!["SELECTALL", "KEYPRESS", "MOUSEUP"].some(type => reason &
+ Ci.nsISelectionListener[type + "_REASON"]) || selection.toString() == "")
+ return;
+
+ this.onSelect();
+ },
+
+ onSelect: function() {
+ emit(module.exports, "select");
+ }
+}
+
+/**
+ * Defines iterators so that discontiguous selections can be iterated.
+ * Empty selections are skipped - see `safeGetRange` for further details.
+ *
+ * If discontiguous selections are in a text field, only the first one
+ * is returned because the text field selection APIs doesn't support
+ * multiple selections.
+ */
+function* forOfIterator() {
+ let selection = getSelection(DOM);
+ let count = 0;
+
+ if (selection)
+ count = selection.rangeCount || (getElementWithSelection() ? 1 : 0);
+
+ for (let i = 0; i < count; i++) {
+ let sel = Selection(i);
+
+ if (sel.text)
+ yield Selection(i);
+ }
+}
+
+const selectionIteratorOptions = {
+ __iterator__: function() {
+ for (let item of this)
+ yield item;
+ }
+}
+selectionIteratorOptions[Symbol.iterator] = forOfIterator;
+const selectionIterator = obscure(selectionIteratorOptions);
+
+/**
+ * Returns the most recent focused window.
+ * if private browsing window is most recent and not supported,
+ * then ignore it and return `null`, because the focused window
+ * can't be targeted.
+ */
+function getFocusedWindow() {
+ let window = winUtils.getFocusedWindow();
+
+ return ignoreWindow(window) ? null : window;
+}
+
+/**
+ * Returns the focused element in the most recent focused window
+ * if private browsing window is most recent and not supported,
+ * then ignore it and return `null`, because the focused element
+ * can't be targeted.
+ */
+function getFocusedElement() {
+ let element = winUtils.getFocusedElement();
+
+ if (!element || ignoreWindow(element.ownerDocument.defaultView))
+ return null;
+
+ return element;
+}
+
+/**
+ * Returns the current selection from most recent content window. Depending on
+ * the specified |type|, the value returned can be a string of text, stringified
+ * HTML, or a DOM selection object as described at
+ * https://developer.mozilla.org/en/DOM/Selection.
+ *
+ * @param type
+ * Specifies the return type of the selection. Valid values are the one
+ * of the constants HTML, TEXT, or DOM.
+ *
+ * @param rangeNumber
+ * Specifies the zero-based range index of the returned selection.
+ */
+function getSelection(type, rangeNumber) {
+ let window, selection;
+ try {
+ window = getFocusedWindow();
+ selection = window.getSelection();
+ }
+ catch (e) {
+ return null;
+ }
+
+ // Get the selected content as the specified type
+ if (type == DOM) {
+ return selection;
+ }
+ else if (type == TEXT) {
+ let range = safeGetRange(selection, rangeNumber);
+
+ if (range)
+ return range.toString();
+
+ let node = getElementWithSelection();
+
+ if (!node)
+ return null;
+
+ return node.value.substring(node.selectionStart, node.selectionEnd);
+ }
+ else if (type == HTML) {
+ let range = safeGetRange(selection, rangeNumber);
+ // Another way, but this includes the xmlns attribute for all elements in
+ // Gecko 1.9.2+ :
+ // return Cc["@mozilla.org/xmlextras/xmlserializer;1"].
+ // createInstance(Ci.nsIDOMSerializer).serializeToSTring(range.
+ // cloneContents());
+ if (!range)
+ return null;
+
+ let node = window.document.createElement("span");
+ node.appendChild(range.cloneContents());
+ return node.innerHTML;
+ }
+
+ throw new Error("Type " + type + " is unrecognized.");
+}
+
+/**
+ * Sets the current selection of the most recent content document by changing
+ * the existing selected text/HTML range to the specified value.
+ *
+ * @param val
+ * The value for the new selection
+ *
+ * @param rangeNumber
+ * The zero-based range index of the selection to be set
+ *
+ */
+function setSelection(type, val, rangeNumber) {
+ // Make sure we have a window context & that there is a current selection.
+ // Selection cannot be set unless there is an existing selection.
+ let window, selection;
+
+ try {
+ window = getFocusedWindow();
+ selection = window.getSelection();
+ }
+ catch (e) {
+ throw new Error(ERR_CANNOT_CHANGE_SELECTION);
+ }
+
+ let range = safeGetRange(selection, rangeNumber);
+
+ if (range) {
+ let fragment;
+
+ if (type === HTML)
+ fragment = range.createContextualFragment(val);
+ else {
+ fragment = range.createContextualFragment("");
+ fragment.textContent = val;
+ }
+
+ range.deleteContents();
+ range.insertNode(fragment);
+ }
+ else {
+ let node = getElementWithSelection();
+
+ if (!node)
+ throw new Error(ERR_CANNOT_CHANGE_SELECTION);
+
+ let { value, selectionStart, selectionEnd } = node;
+
+ let newSelectionEnd = selectionStart + val.length;
+
+ node.value = value.substring(0, selectionStart) +
+ val +
+ value.substring(selectionEnd, value.length);
+
+ node.setSelectionRange(selectionStart, newSelectionEnd);
+ }
+}
+
+/**
+ * Returns the specified range in a selection without throwing an exception.
+ *
+ * @param selection
+ * A selection object as described at
+ * https://developer.mozilla.org/en/DOM/Selection
+ *
+ * @param [rangeNumber]
+ * Specifies the zero-based range index of the returned selection.
+ * If it's not provided the function will return the first non empty
+ * range, if any.
+ */
+function safeGetRange(selection, rangeNumber) {
+ try {
+ let { rangeCount } = selection;
+ let range = null;
+
+ if (typeof rangeNumber === "undefined")
+ rangeNumber = 0;
+ else
+ rangeCount = rangeNumber + 1;
+
+ for (; rangeNumber < rangeCount; rangeNumber++ ) {
+ range = selection.getRangeAt(rangeNumber);
+
+ if (range && range.toString())
+ break;
+
+ range = null;
+ }
+
+ return range;
+ }
+ catch (e) {
+ return null;
+ }
+}
+
+/**
+ * Returns a reference of the DOM's active element for the window given, if it
+ * supports the text field selection API and has a text selected.
+ *
+ * Note:
+ * we need this method because window.getSelection doesn't return a selection
+ * for text selected in a form field (see bug 85686)
+ */
+function getElementWithSelection() {
+ let element = getFocusedElement();
+
+ if (!element)
+ return null;
+
+ try {
+ // Accessing selectionStart and selectionEnd on e.g. a button
+ // results in an exception thrown as per the HTML5 spec. See
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#textFieldSelection
+
+ let { value, selectionStart, selectionEnd } = element;
+
+ let hasSelection = typeof value === "string" &&
+ !isNaN(selectionStart) &&
+ !isNaN(selectionEnd) &&
+ selectionStart !== selectionEnd;
+
+ return hasSelection ? element : null;
+ }
+ catch (err) {
+ return null;
+ }
+
+}
+
+/**
+ * Adds the Selection Listener to the content's window given
+ */
+function addSelectionListener(window) {
+ let selection = window.getSelection();
+
+ // Don't add the selection's listener more than once to the same window,
+ // if the selection object is the same
+ if ("selection" in selections(window) && selections(window).selection === selection)
+ return;
+
+ // We ensure that the current selection is an instance of
+ // `nsISelectionPrivate` before working on it, in case is `null`.
+ //
+ // If it's `null` it's likely too early to add the listener, and we demand
+ // that operation to `document-shown` - it can easily happens for frames
+ if (selection instanceof Ci.nsISelectionPrivate)
+ selection.addSelectionListener(selectionListener);
+
+ // nsISelectionListener implementation seems not fire a notification if
+ // a selection is in a text field, therefore we need to add a listener to
+ // window.onselect, that is fired only for text fields.
+ // For consistency, we add it only when the nsISelectionListener is added.
+ //
+ // https://developer.mozilla.org/en/DOM/window.onselect
+ window.addEventListener("select", selectionListener.onSelect, true);
+
+ selections(window).selection = selection;
+};
+
+/**
+ * Removes the Selection Listener to the content's window given
+ */
+function removeSelectionListener(window) {
+ // Don't remove the selection's listener to a window that wasn't handled.
+ if (!("selection" in selections(window)))
+ return;
+
+ let selection = window.getSelection();
+ let isSameSelection = selection === selections(window).selection;
+
+ // Before remove the listener, we ensure that the current selection is an
+ // instance of `nsISelectionPrivate` (it could be `null`), and that is still
+ // the selection we managed for this window (it could be detached).
+ if (selection instanceof Ci.nsISelectionPrivate && isSameSelection)
+ selection.removeSelectionListener(selectionListener);
+
+ window.removeEventListener("select", selectionListener.onSelect, true);
+
+ delete selections(window).selection;
+};
+
+function onContent(event) {
+ let window = event.subject.defaultView;
+
+ // We are not interested in documents without valid defaultView (e.g. XML)
+ // that aren't in a tab (e.g. Panel); or in private windows
+ if (window && getTabForContentWindow(window) && !ignoreWindow(window)) {
+ addSelectionListener(window);
+ }
+}
+
+// Adds Selection listener to new documents
+// Note that strong reference is needed for documents that are loading slowly or
+// where the server didn't close the connection (e.g. "comet").
+events.on("document-element-inserted", onContent, true);
+
+// Adds Selection listeners to existing documents
+getAllTabContentWindows().forEach(addSelectionListener);
+
+// When a document is not visible anymore the selection object is detached, and
+// a new selection object is created when it becomes visible again.
+// That makes the previous selection's listeners added previously totally
+// useless – the listeners are not notified anymore.
+// To fix that we're listening for `document-shown` event in order to add
+// the listeners to the new selection object created.
+//
+// See bug 665386 for further details.
+
+function onShown(event) {
+ let window = event.subject.defaultView;
+
+ // We are not interested in documents without valid defaultView.
+ // For example XML documents don't have windows and we don't yet support them.
+ if (!window)
+ return;
+
+ // We want to handle only the windows where we added selection's listeners
+ if ("selection" in selections(window)) {
+ let currentSelection = window.getSelection();
+ let { selection } = selections(window);
+
+ // If the current selection for the window given is different from the one
+ // stored in the namespace, we need to add the listeners again, and replace
+ // the previous selection in our list with the new one.
+ //
+ // Notice that we don't have to remove the listeners from the old selection,
+ // because is detached. An attempt to remove the listener, will raise an
+ // error (see http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsSelection.cpp#5343 )
+ //
+ // We ensure that the current selection is an instance of
+ // `nsISelectionPrivate` before working on it, in case is `null`.
+ if (currentSelection instanceof Ci.nsISelectionPrivate &&
+ currentSelection !== selection) {
+
+ window.addEventListener("select", selectionListener.onSelect, true);
+ currentSelection.addSelectionListener(selectionListener);
+ selections(window).selection = currentSelection;
+ }
+ }
+}
+
+events.on("document-shown", onShown, true);
+
+// Removes Selection listeners when the add-on is unloaded
+unload(function(){
+ getAllTabContentWindows().forEach(removeSelectionListener);
+
+ events.off("document-element-inserted", onContent);
+ events.off("document-shown", onShown);
+
+ off(exports);
+});
+
+const selection = Class({
+ extends: EventTarget,
+ implements: [ Selection, selectionIterator ]
+})();
+
+module.exports = selection;
diff --git a/toolkit/jetpack/sdk/self.js b/toolkit/jetpack/sdk/self.js
new file mode 100644
index 000000000..c2114a926
--- /dev/null
+++ b/toolkit/jetpack/sdk/self.js
@@ -0,0 +1,61 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { CC } = require('chrome');
+const options = require('@loader/options');
+
+const { get } = require("./preferences/service");
+const { readURISync } = require('./net/url');
+
+const id = options.id;
+
+const readPref = key => get("extensions." + id + ".sdk." + key);
+
+const name = readPref("name") || options.name;
+const version = readPref("version") || options.version;
+const loadReason = readPref("load.reason") || options.loadReason;
+const rootURI = readPref("rootURI") || options.rootURI || "";
+const baseURI = readPref("baseURI") || options.prefixURI + name + "/"
+const addonDataURI = baseURI + "data/";
+const metadata = options.metadata || {};
+const permissions = metadata.permissions || {};
+const isPacked = rootURI && rootURI.indexOf("jar:") === 0;
+
+const isPrivateBrowsingSupported = 'private-browsing' in permissions &&
+ permissions['private-browsing'] === true;
+
+const uri = (path="") =>
+ path.includes(":") ? path : addonDataURI + path.replace(/^\.\//, "");
+
+var preferencesBranch = ("preferences-branch" in metadata)
+ ? metadata["preferences-branch"]
+ : options.preferencesBranch
+
+if (/[^\w{@}.-]/.test(preferencesBranch)) {
+ preferencesBranch = id;
+ console.warn("Ignoring preferences-branch (not a valid branch name)");
+}
+
+// Some XPCOM APIs require valid URIs as an argument for certain operations
+// (see `nsILoginManager` for example). This property represents add-on
+// associated unique URI string that can be used for that.
+exports.uri = 'addon:' + id;
+exports.id = id;
+exports.preferencesBranch = preferencesBranch || id;
+exports.name = name;
+exports.loadReason = loadReason;
+exports.version = version;
+exports.packed = isPacked;
+exports.data = Object.freeze({
+ url: uri,
+ load: function read(path) {
+ return readURISync(uri(path));
+ }
+});
+exports.isPrivateBrowsingSupported = isPrivateBrowsingSupported;
diff --git a/toolkit/jetpack/sdk/simple-prefs.js b/toolkit/jetpack/sdk/simple-prefs.js
new file mode 100644
index 000000000..3472f4418
--- /dev/null
+++ b/toolkit/jetpack/sdk/simple-prefs.js
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { emit, off } = require("./event/core");
+const { PrefsTarget } = require("./preferences/event-target");
+const { preferencesBranch, id } = require("./self");
+const { on } = require("./system/events");
+
+const ADDON_BRANCH = "extensions." + preferencesBranch + ".";
+const BUTTON_PRESSED = id + "-cmdPressed";
+
+const target = PrefsTarget({ branchName: ADDON_BRANCH });
+
+// Listen to clicks on buttons
+function buttonClick({ data }) {
+ emit(target, data);
+}
+on(BUTTON_PRESSED, buttonClick);
+
+module.exports = target;
diff --git a/toolkit/jetpack/sdk/simple-storage.js b/toolkit/jetpack/sdk/simple-storage.js
new file mode 100644
index 000000000..bcf9b1cb9
--- /dev/null
+++ b/toolkit/jetpack/sdk/simple-storage.js
@@ -0,0 +1,235 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { Cc, Ci } = require("chrome");
+const file = require("./io/file");
+const prefs = require("./preferences/service");
+const jpSelf = require("./self");
+const timer = require("./timers");
+const unload = require("./system/unload");
+const { emit, on, off } = require("./event/core");
+
+const WRITE_PERIOD_PREF = "extensions.addon-sdk.simple-storage.writePeriod";
+const WRITE_PERIOD_DEFAULT = 300000; // 5 minutes
+
+const QUOTA_PREF = "extensions.addon-sdk.simple-storage.quota";
+const QUOTA_DEFAULT = 5242880; // 5 MiB
+
+const JETPACK_DIR_BASENAME = "jetpack";
+
+Object.defineProperties(exports, {
+ storage: {
+ enumerable: true,
+ get: function() { return manager.root; },
+ set: function(value) { manager.root = value; }
+ },
+ quotaUsage: {
+ get: function() { return manager.quotaUsage; }
+ }
+});
+
+// A generic JSON store backed by a file on disk. This should be isolated
+// enough to move to its own module if need be...
+function JsonStore(options) {
+ this.filename = options.filename;
+ this.quota = options.quota;
+ this.writePeriod = options.writePeriod;
+ this.onOverQuota = options.onOverQuota;
+ this.onWrite = options.onWrite;
+
+ unload.ensure(this);
+
+ this.writeTimer = timer.setInterval(this.write.bind(this),
+ this.writePeriod);
+}
+
+JsonStore.prototype = {
+ // The store's root.
+ get root() {
+ return this.isRootInited ? this._root : {};
+ },
+
+ // Performs some type checking.
+ set root(val) {
+ let types = ["array", "boolean", "null", "number", "object", "string"];
+ if (types.indexOf(typeof(val)) < 0) {
+ throw new Error("storage must be one of the following types: " +
+ types.join(", "));
+ }
+ this._root = val;
+ return val;
+ },
+
+ // True if the root has ever been set (either via the root setter or by the
+ // backing file's having been read).
+ get isRootInited() {
+ return this._root !== undefined;
+ },
+
+ // Percentage of quota used, as a number [0, Inf). > 1 implies over quota.
+ // Undefined if there is no quota.
+ get quotaUsage() {
+ return this.quota > 0 ?
+ JSON.stringify(this.root).length / this.quota :
+ undefined;
+ },
+
+ // Removes the backing file and all empty subdirectories.
+ purge: function JsonStore_purge() {
+ try {
+ // This'll throw if the file doesn't exist.
+ file.remove(this.filename);
+ let parentPath = this.filename;
+ do {
+ parentPath = file.dirname(parentPath);
+ // This'll throw if the dir isn't empty.
+ file.rmdir(parentPath);
+ } while (file.basename(parentPath) !== JETPACK_DIR_BASENAME);
+ }
+ catch (err) {}
+ },
+
+ // Initializes the root by reading the backing file.
+ read: function JsonStore_read() {
+ try {
+ let str = file.read(this.filename);
+
+ // Ideally we'd log the parse error with console.error(), but logged
+ // errors cause tests to fail. Supporting "known" errors in the test
+ // harness appears to be non-trivial. Maybe later.
+ this.root = JSON.parse(str);
+ }
+ catch (err) {
+ this.root = {};
+ }
+ },
+
+ // If the store is under quota, writes the root to the backing file.
+ // Otherwise quota observers are notified and nothing is written.
+ write: function JsonStore_write() {
+ if (this.quotaUsage > 1)
+ this.onOverQuota(this);
+ else
+ this._write();
+ },
+
+ // Cleans up on unload. If unloading because of uninstall, the store is
+ // purged; otherwise it's written.
+ unload: function JsonStore_unload(reason) {
+ timer.clearInterval(this.writeTimer);
+ this.writeTimer = null;
+
+ if (reason === "uninstall")
+ this.purge();
+ else
+ this._write();
+ },
+
+ // True if the root is an empty object.
+ get _isEmpty() {
+ if (this.root && typeof(this.root) === "object") {
+ let empty = true;
+ for (let key in this.root) {
+ empty = false;
+ break;
+ }
+ return empty;
+ }
+ return false;
+ },
+
+ // Writes the root to the backing file, notifying write observers when
+ // complete. If the store is over quota or if it's empty and the store has
+ // never been written, nothing is written and write observers aren't notified.
+ _write: function JsonStore__write() {
+ // Don't write if the root is uninitialized or if the store is empty and the
+ // backing file doesn't yet exist.
+ if (!this.isRootInited || (this._isEmpty && !file.exists(this.filename)))
+ return;
+
+ // If the store is over quota, don't write. The current under-quota state
+ // should persist.
+ if (this.quotaUsage > 1)
+ return;
+
+ // Finally, write.
+ let stream = file.open(this.filename, "w");
+ try {
+ stream.writeAsync(JSON.stringify(this.root), function writeAsync(err) {
+ if (err)
+ console.error("Error writing simple storage file: " + this.filename);
+ else if (this.onWrite)
+ this.onWrite(this);
+ }.bind(this));
+ }
+ catch (err) {
+ // writeAsync closes the stream after it's done, so only close on error.
+ stream.close();
+ }
+ }
+};
+
+
+// This manages a JsonStore singleton and tailors its use to simple storage.
+// The root of the JsonStore is lazy-loaded: The backing file is only read the
+// first time the root's gotten.
+var manager = ({
+ jsonStore: null,
+
+ // The filename of the store, based on the profile dir and extension ID.
+ get filename() {
+ let storeFile = Cc["@mozilla.org/file/directory_service;1"].
+ getService(Ci.nsIProperties).
+ get("ProfD", Ci.nsIFile);
+ storeFile.append(JETPACK_DIR_BASENAME);
+ storeFile.append(jpSelf.id);
+ storeFile.append("simple-storage");
+ file.mkpath(storeFile.path);
+ storeFile.append("store.json");
+ return storeFile.path;
+ },
+
+ get quotaUsage() {
+ return this.jsonStore.quotaUsage;
+ },
+
+ get root() {
+ if (!this.jsonStore.isRootInited)
+ this.jsonStore.read();
+ return this.jsonStore.root;
+ },
+
+ set root(val) {
+ return this.jsonStore.root = val;
+ },
+
+ unload: function manager_unload() {
+ off(this);
+ },
+
+ new: function manager_constructor() {
+ let manager = Object.create(this);
+ unload.ensure(manager);
+
+ manager.jsonStore = new JsonStore({
+ filename: manager.filename,
+ writePeriod: prefs.get(WRITE_PERIOD_PREF, WRITE_PERIOD_DEFAULT),
+ quota: prefs.get(QUOTA_PREF, QUOTA_DEFAULT),
+ onOverQuota: emit.bind(null, exports, "OverQuota")
+ });
+
+ return manager;
+ }
+}).new();
+
+exports.on = on.bind(null, exports);
+exports.removeListener = function(type, listener) {
+ off(exports, type, listener);
+};
diff --git a/toolkit/jetpack/sdk/stylesheet/style.js b/toolkit/jetpack/sdk/stylesheet/style.js
new file mode 100644
index 000000000..7ec0787e1
--- /dev/null
+++ b/toolkit/jetpack/sdk/stylesheet/style.js
@@ -0,0 +1,71 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci } = require("chrome");
+const { Class } = require("../core/heritage");
+const { URL, isLocalURL } = require('../url');
+const events = require("../system/events");
+const { loadSheet, removeSheet, isTypeValid } = require("./utils");
+const { isString } = require("../lang/type");
+const { attachTo, detachFrom } = require("../content/mod");
+const { data } = require('../self');
+
+const { freeze, create } = Object;
+
+function Style({ source, uri, type }) {
+ source = source == null ? null : freeze([].concat(source));
+ uri = uri == null ? null : freeze([].concat(uri));
+ type = type == null ? "author" : type;
+
+ if (source && !source.every(isString))
+ throw new Error('Style.source must be a string or an array of strings.');
+
+ if (uri && !uri.every(isLocalURL))
+ throw new Error('Style.uri must be a local URL or an array of local URLs');
+
+ if (type && !isTypeValid(type))
+ throw new Error('Style.type must be "agent", "user" or "author"');
+
+ return freeze(create(Style.prototype, {
+ "source": { value: source, enumerable: true },
+ "uri": { value: uri, enumerable: true },
+ "type": { value: type, enumerable: true }
+ }));
+};
+
+exports.Style = Style;
+
+attachTo.define(Style, function (style, window) {
+ if (style.uri) {
+ for (let uri of style.uri)
+ loadSheet(window, data.url(uri), style.type);
+ }
+
+ if (style.source) {
+ let uri = "data:text/css;charset=utf-8,";
+
+ uri += encodeURIComponent(style.source.join(""));
+
+ loadSheet(window, uri, style.type);
+ }
+});
+
+detachFrom.define(Style, function (style, window) {
+ if (style.uri)
+ for (let uri of style.uri)
+ removeSheet(window, data.url(uri));
+
+ if (style.source) {
+ let uri = "data:text/css;charset=utf-8,";
+
+ uri += encodeURIComponent(style.source.join(""));
+
+ removeSheet(window, uri, style.type);
+ }
+});
diff --git a/toolkit/jetpack/sdk/stylesheet/utils.js b/toolkit/jetpack/sdk/stylesheet/utils.js
new file mode 100644
index 000000000..844996bf3
--- /dev/null
+++ b/toolkit/jetpack/sdk/stylesheet/utils.js
@@ -0,0 +1,75 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Ci } = require("chrome");
+
+const SHEET_TYPE = {
+ "agent": "AGENT_SHEET",
+ "user": "USER_SHEET",
+ "author": "AUTHOR_SHEET"
+};
+
+function getDOMWindowUtils(window) {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDOMWindowUtils);
+};
+
+/**
+ * Synchronously loads a style sheet from `uri` and adds it to the list of
+ * additional style sheets of the document.
+ * The sheets added takes effect immediately, and only on the document of the
+ * `window` given.
+ */
+function loadSheet(window, url, type) {
+ if (!(type && type in SHEET_TYPE))
+ type = "author";
+
+ type = SHEET_TYPE[type];
+
+ if (url instanceof Ci.nsIURI)
+ url = url.spec;
+
+ let winUtils = getDOMWindowUtils(window);
+ try {
+ winUtils.loadSheetUsingURIString(url, winUtils[type]);
+ }
+ catch (e) {};
+};
+exports.loadSheet = loadSheet;
+
+/**
+ * Remove the document style sheet at `sheetURI` from the list of additional
+ * style sheets of the document. The removal takes effect immediately.
+ */
+function removeSheet(window, url, type) {
+ if (!(type && type in SHEET_TYPE))
+ type = "author";
+
+ type = SHEET_TYPE[type];
+
+ if (url instanceof Ci.nsIURI)
+ url = url.spec;
+
+ let winUtils = getDOMWindowUtils(window);
+
+ try {
+ winUtils.removeSheetUsingURIString(url, winUtils[type]);
+ }
+ catch (e) {};
+};
+exports.removeSheet = removeSheet;
+
+/**
+ * Returns `true` if the `type` given is valid, otherwise `false`.
+ * The values currently accepted are: "agent", "user" and "author".
+ */
+function isTypeValid(type) {
+ return type in SHEET_TYPE;
+}
+exports.isTypeValid = isTypeValid;
diff --git a/toolkit/jetpack/sdk/system.js b/toolkit/jetpack/sdk/system.js
new file mode 100644
index 000000000..1acfe8c8c
--- /dev/null
+++ b/toolkit/jetpack/sdk/system.js
@@ -0,0 +1,172 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci, CC } = require('chrome');
+const options = require('@loader/options');
+const runtime = require("./system/runtime");
+const { when: unload } = require("./system/unload");
+
+const appStartup = Cc['@mozilla.org/toolkit/app-startup;1'].
+ getService(Ci.nsIAppStartup);
+const appInfo = Cc["@mozilla.org/xre/app-info;1"].
+ getService(Ci.nsIXULAppInfo);
+const directoryService = Cc['@mozilla.org/file/directory_service;1'].
+ getService(Ci.nsIProperties);
+
+const PR_WRONLY = parseInt("0x02");
+const PR_CREATE_FILE = parseInt("0x08");
+const PR_APPEND = parseInt("0x10");
+const PR_TRUNCATE = parseInt("0x20");
+
+function openFile(path, mode) {
+ let file = Cc["@mozilla.org/file/local;1"].
+ createInstance(Ci.nsILocalFile);
+ file.initWithPath(path);
+ let stream = Cc["@mozilla.org/network/file-output-stream;1"].
+ createInstance(Ci.nsIFileOutputStream);
+ stream.init(file, mode, -1, 0);
+ return stream
+}
+
+const { eAttemptQuit: E_ATTEMPT, eForceQuit: E_FORCE } = appStartup;
+
+/**
+ * Parsed JSON object that was passed via `cfx --static-args "{ foo: 'bar' }"`
+ */
+exports.staticArgs = options.staticArgs;
+
+/**
+ * Environment variables. Environment variables are non-enumerable properties
+ * of this object (key is name and value is value).
+ */
+exports.env = require('./system/environment').env;
+
+/**
+ * Ends the process with the specified `code`. If omitted, exit uses the
+ * 'success' code 0. To exit with failure use `1`.
+ * TODO: Improve platform to actually quit with an exit code.
+ */
+var forcedExit = false;
+exports.exit = function exit(code) {
+ if (forcedExit) {
+ // a forced exit was already tried
+ // NOTE: exit(0) is called twice sometimes (ex when using cfx testaddons)
+ return;
+ }
+
+ let resultsFile = 'resultFile' in options && options.resultFile;
+ function unloader() {
+ if (!options.resultFile) {
+ return;
+ }
+
+ // This is used by 'cfx' to find out exit code.
+ let mode = PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE;
+ let stream = openFile(options.resultFile, mode);
+ let status = code ? 'FAIL' : 'OK';
+ stream.write(status, status.length);
+ stream.flush();
+ stream.close();
+ return;
+ }
+
+ if (code == 0) {
+ forcedExit = true;
+ }
+
+ // Bug 856999: Prevent automatic kill of Firefox when running tests
+ if (options.noQuit) {
+ return unload(unloader);
+ }
+
+ unloader();
+ appStartup.quit(code ? E_ATTEMPT : E_FORCE);
+};
+
+// Adapter for nodejs's stdout & stderr:
+// http://nodejs.org/api/process.html#process_process_stdout
+var stdout = Object.freeze({ write: dump, end: dump });
+exports.stdout = stdout;
+exports.stderr = stdout;
+
+/**
+ * Returns a path of the system's or application's special directory / file
+ * associated with a given `id`. For list of possible `id`s please see:
+ * https://developer.mozilla.org/en-US/docs/Code_snippets/File_I_O#Getting_files_in_special_directories
+ * http://dxr.mozilla.org/mozilla-central/source/xpcom/io/nsAppDirectoryServiceDefs.h
+ * @example
+ *
+ * // get firefox profile path
+ * let profilePath = require('system').pathFor('ProfD');
+ * // get OS temp files directory (/tmp)
+ * let temps = require('system').pathFor('TmpD');
+ * // get OS desktop path for an active user (~/Desktop on linux
+ * // or C:\Documents and Settings\username\Desktop on windows).
+ * let desktopPath = require('system').pathFor('Desk');
+ */
+exports.pathFor = function pathFor(id) {
+ return directoryService.get(id, Ci.nsIFile).path;
+};
+
+/**
+ * What platform you're running on (all lower case string).
+ * For possible values see:
+ * https://developer.mozilla.org/en/OS_TARGET
+ */
+exports.platform = runtime.OS.toLowerCase();
+
+const [, architecture, compiler] = runtime.XPCOMABI ?
+ runtime.XPCOMABI.match(/^([^-]*)-(.*)$/) :
+ [, null, null];
+
+/**
+ * What processor architecture you're running on:
+ * `'arm', 'ia32', or 'x64'`.
+ */
+exports.architecture = architecture;
+
+/**
+ * What compiler used for build:
+ * `'msvc', 'n32', 'gcc2', 'gcc3', 'sunc', 'ibmc'...`
+ */
+exports.compiler = compiler;
+
+/**
+ * The application's build ID/date, for example "2004051604".
+ */
+exports.build = appInfo.appBuildID;
+
+/**
+ * The XUL application's UUID.
+ * This has traditionally been in the form
+ * `{AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}` but for some applications it may
+ * be: "appname@vendor.tld".
+ */
+exports.id = appInfo.ID;
+
+/**
+ * The name of the application.
+ */
+exports.name = appInfo.name;
+
+/**
+ * The XUL application's version, for example "0.8.0+" or "3.7a1pre".
+ */
+exports.version = appInfo.version;
+
+/**
+ * XULRunner version.
+ */
+exports.platformVersion = appInfo.platformVersion;
+
+
+/**
+ * The name of the application vendor, for example "Mozilla".
+ */
+exports.vendor = appInfo.vendor;
diff --git a/toolkit/jetpack/sdk/system/child_process.js b/toolkit/jetpack/sdk/system/child_process.js
new file mode 100644
index 000000000..8ea1f4f80
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/child_process.js
@@ -0,0 +1,332 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental'
+};
+
+var { Ci } = require('chrome');
+var subprocess = require('./child_process/subprocess');
+var { EventTarget } = require('../event/target');
+var { Stream } = require('../io/stream');
+var { on, emit, off } = require('../event/core');
+var { Class } = require('../core/heritage');
+var { platform } = require('../system');
+var { isFunction, isArray } = require('../lang/type');
+var { delay } = require('../lang/functional');
+var { merge } = require('../util/object');
+var { setTimeout, clearTimeout } = require('../timers');
+var isWindows = platform.indexOf('win') === 0;
+
+var processes = new WeakMap();
+
+
+/**
+ * The `Child` class wraps a subprocess command, exposes
+ * the stdio streams, and methods to manipulate the subprocess
+ */
+var Child = Class({
+ implements: [EventTarget],
+ initialize: function initialize (options) {
+ let child = this;
+ let proc;
+
+ this.killed = false;
+ this.exitCode = undefined;
+ this.signalCode = undefined;
+
+ this.stdin = Stream();
+ this.stdout = Stream();
+ this.stderr = Stream();
+
+ try {
+ proc = subprocess.call({
+ command: options.file,
+ arguments: options.cmdArgs,
+ environment: serializeEnv(options.env),
+ workdir: options.cwd,
+ charset: options.encoding,
+ stdout: data => emit(child.stdout, 'data', data),
+ stderr: data => emit(child.stderr, 'data', data),
+ stdin: stream => {
+ child.stdin.on('data', pumpStdin);
+ child.stdin.on('end', function closeStdin () {
+ child.stdin.off('data', pumpStdin);
+ child.stdin.off('end', closeStdin);
+ stream.close();
+ });
+ function pumpStdin (data) {
+ stream.write(data);
+ }
+ },
+ done: function (result, error) {
+ if (error)
+ return handleError(error);
+
+ // Only emit if child is not killed; otherwise,
+ // the `kill` method will handle this
+ if (!child.killed) {
+ child.exitCode = result.exitCode;
+ child.signalCode = null;
+
+ // If process exits with < 0, there was an error
+ if (child.exitCode < 0) {
+ handleError(new Error('Process exited with exit code ' + child.exitCode));
+ }
+ else {
+ // Also do 'exit' event as there's not much of
+ // a difference in our implementation as we're not using
+ // node streams
+ emit(child, 'exit', child.exitCode, child.signalCode);
+ }
+
+ // Emit 'close' event with exit code and signal,
+ // which is `null`, as it was not a killed process
+ emit(child, 'close', child.exitCode, child.signalCode);
+ }
+ }
+ });
+ processes.set(child, proc);
+ } catch (e) {
+ // Delay the error handling so an error handler can be set
+ // during the same tick that the Child was created
+ delay(() => handleError(e));
+ }
+
+ // `handleError` is called when process could not even
+ // be spawned
+ function handleError (e) {
+ // If error is an nsIObject, make a fresh error object
+ // so we're not exposing nsIObjects, and we can modify it
+ // with additional process information, like node
+ let error = e;
+ if (e instanceof Ci.nsISupports) {
+ error = new Error(e.message, e.filename, e.lineNumber);
+ }
+ emit(child, 'error', error);
+ child.exitCode = -1;
+ child.signalCode = null;
+ emit(child, 'close', child.exitCode, child.signalCode);
+ }
+ },
+ kill: function kill (signal) {
+ let proc = processes.get(this);
+ proc.kill(signal);
+ this.killed = true;
+ this.exitCode = null;
+ this.signalCode = signal;
+ emit(this, 'exit', this.exitCode, this.signalCode);
+ emit(this, 'close', this.exitCode, this.signalCode);
+ },
+ get pid() { return processes.get(this, {}).pid || -1; }
+});
+
+function spawn (file, ...args) {
+ let cmdArgs = [];
+ // Default options
+ let options = {
+ cwd: null,
+ env: null,
+ encoding: 'UTF-8'
+ };
+
+ if (args[1]) {
+ merge(options, args[1]);
+ cmdArgs = args[0];
+ }
+ else {
+ if (isArray(args[0]))
+ cmdArgs = args[0];
+ else
+ merge(options, args[0]);
+ }
+
+ if ('gid' in options)
+ console.warn('`gid` option is not yet supported for `child_process`');
+ if ('uid' in options)
+ console.warn('`uid` option is not yet supported for `child_process`');
+ if ('detached' in options)
+ console.warn('`detached` option is not yet supported for `child_process`');
+
+ options.file = file;
+ options.cmdArgs = cmdArgs;
+
+ return Child(options);
+}
+
+exports.spawn = spawn;
+
+/**
+ * exec(command, options, callback)
+ */
+function exec (cmd, ...args) {
+ let file, cmdArgs, callback, options = {};
+
+ if (isFunction(args[0]))
+ callback = args[0];
+ else {
+ merge(options, args[0]);
+ callback = args[1];
+ }
+
+ if (isWindows) {
+ file = 'C:\\Windows\\System32\\cmd.exe';
+ cmdArgs = ['/S/C', cmd || ''];
+ }
+ else {
+ file = '/bin/sh';
+ cmdArgs = ['-c', cmd];
+ }
+
+ // Undocumented option from node being able to specify shell
+ if (options && options.shell)
+ file = options.shell;
+
+ return execFile(file, cmdArgs, options, callback);
+}
+exports.exec = exec;
+/**
+ * execFile (file, args, options, callback)
+ */
+function execFile (file, ...args) {
+ let cmdArgs = [], callback;
+ // Default options
+ let options = {
+ cwd: null,
+ env: null,
+ encoding: 'utf8',
+ timeout: 0,
+ maxBuffer: 204800, //200 KB (200*1024 bytes)
+ killSignal: 'SIGTERM'
+ };
+
+ if (isFunction(args[args.length - 1]))
+ callback = args[args.length - 1];
+
+ if (isArray(args[0])) {
+ cmdArgs = args[0];
+ merge(options, args[1]);
+ } else if (!isFunction(args[0]))
+ merge(options, args[0]);
+
+ let child = spawn(file, cmdArgs, options);
+ let exited = false;
+ let stdout = '';
+ let stderr = '';
+ let error = null;
+ let timeoutId = null;
+
+ child.stdout.setEncoding(options.encoding);
+ child.stderr.setEncoding(options.encoding);
+
+ on(child.stdout, 'data', pumpStdout);
+ on(child.stderr, 'data', pumpStderr);
+ on(child, 'close', exitHandler);
+ on(child, 'error', errorHandler);
+
+ if (options.timeout > 0) {
+ setTimeout(() => {
+ kill();
+ timeoutId = null;
+ }, options.timeout);
+ }
+
+ function exitHandler (code, signal) {
+
+ // Return if exitHandler called previously, occurs
+ // when multiple maxBuffer errors thrown and attempt to kill multiple
+ // times
+ if (exited) return;
+ exited = true;
+
+ if (!isFunction(callback)) return;
+
+ if (timeoutId) {
+ clearTimeout(timeoutId);
+ timeoutId = null;
+ }
+
+ if (!error && (code !== 0 || signal !== null))
+ error = createProcessError(new Error('Command failed: ' + stderr), {
+ code: code,
+ signal: signal,
+ killed: !!child.killed
+ });
+
+ callback(error, stdout, stderr);
+
+ off(child.stdout, 'data', pumpStdout);
+ off(child.stderr, 'data', pumpStderr);
+ off(child, 'close', exitHandler);
+ off(child, 'error', errorHandler);
+ }
+
+ function errorHandler (e) {
+ error = e;
+ exitHandler();
+ }
+
+ function kill () {
+ try {
+ child.kill(options.killSignal);
+ } catch (e) {
+ // In the scenario where the kill signal happens when
+ // the process is already closing, just abort the kill fail
+ if (/library is not open/.test(e))
+ return;
+ error = e;
+ exitHandler(-1, options.killSignal);
+ }
+ }
+
+ function pumpStdout (data) {
+ stdout += data;
+ if (stdout.length > options.maxBuffer) {
+ error = new Error('stdout maxBuffer exceeded');
+ kill();
+ }
+ }
+
+ function pumpStderr (data) {
+ stderr += data;
+ if (stderr.length > options.maxBuffer) {
+ error = new Error('stderr maxBuffer exceeded');
+ kill();
+ }
+ }
+
+ return child;
+}
+exports.execFile = execFile;
+
+exports.fork = function fork () {
+ throw new Error("child_process#fork is not currently supported");
+};
+
+function serializeEnv (obj) {
+ return Object.keys(obj || {}).map(prop => prop + '=' + obj[prop]);
+}
+
+function createProcessError (err, options = {}) {
+ // If code and signal look OK, this was probably a failure
+ // attempting to spawn the process (like ENOENT in node) -- use
+ // the code from the error message
+ if (!options.code && !options.signal) {
+ let match = err.message.match(/(NS_ERROR_\w*)/);
+ if (match && match.length > 1)
+ err.code = match[1];
+ else {
+ // If no good error message found, use the passed in exit code;
+ // this occurs when killing a process that's already closing,
+ // where we want both a valid exit code (0) and the error
+ err.code = options.code != null ? options.code : null;
+ }
+ }
+ else
+ err.code = options.code != null ? options.code : null;
+ err.signal = options.signal || null;
+ err.killed = options.killed || false;
+ return err;
+}
diff --git a/toolkit/jetpack/sdk/system/child_process/subprocess.js b/toolkit/jetpack/sdk/system/child_process/subprocess.js
new file mode 100644
index 000000000..e3454e95b
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/child_process/subprocess.js
@@ -0,0 +1,186 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+const { Ci, Cu } = require("chrome");
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/Subprocess.jsm");
+Cu.import("resource://gre/modules/Task.jsm");
+
+const Runtime = require("sdk/system/runtime");
+const Environment = require("sdk/system/environment").env;
+const DEFAULT_ENVIRONMENT = [];
+if (Runtime.OS == "Linux" && "DISPLAY" in Environment) {
+ DEFAULT_ENVIRONMENT.push("DISPLAY=" + Environment.DISPLAY);
+}
+
+function awaitPromise(promise) {
+ let value;
+ let resolved = null;
+ promise.then(val => {
+ resolved = true;
+ value = val;
+ }, val => {
+ resolved = false;
+ value = val;
+ });
+
+ while (resolved === null)
+ Services.tm.mainThread.processNextEvent(true);
+
+ if (resolved === true)
+ return value;
+ throw value;
+}
+
+let readAllData = Task.async(function* (pipe, read, callback) {
+ let string;
+ while (string = yield read(pipe))
+ callback(string);
+});
+
+let write = (pipe, data) => {
+ let buffer = new Uint8Array(Array.from(data, c => c.charCodeAt(0)));
+ return pipe.write(data);
+};
+
+var subprocess = {
+ call: function(options) {
+ var result;
+
+ let procPromise = Task.spawn(function*() {
+ let opts = {};
+
+ if (options.mergeStderr) {
+ opts.stderr = "stdout"
+ } else if (options.stderr) {
+ opts.stderr = "pipe";
+ }
+
+ if (options.command instanceof Ci.nsIFile) {
+ opts.command = options.command.path;
+ } else {
+ opts.command = yield Subprocess.pathSearch(options.command);
+ }
+
+ if (options.workdir) {
+ opts.workdir = options.workdir;
+ }
+
+ opts.arguments = options.arguments || [];
+
+
+ // Set up environment
+
+ let envVars = options.environment || DEFAULT_ENVIRONMENT;
+ if (envVars.length) {
+ let environment = {};
+ for (let val of envVars) {
+ let idx = val.indexOf("=");
+ if (idx >= 0)
+ environment[val.slice(0, idx)] = val.slice(idx + 1);
+ }
+
+ opts.environment = environment;
+ }
+
+
+ let proc = yield Subprocess.call(opts);
+
+ Object.defineProperty(result, "pid", {
+ value: proc.pid,
+ enumerable: true,
+ configurable: true,
+ });
+
+
+ let promises = [];
+
+ // Set up IO handlers.
+
+ let read = pipe => pipe.readString();
+ if (options.charset === null) {
+ read = pipe => {
+ return pipe.read().then(buffer => {
+ return String.fromCharCode(...buffer);
+ });
+ };
+ }
+
+ if (options.stdout)
+ promises.push(readAllData(proc.stdout, read, options.stdout));
+
+ if (options.stderr && proc.stderr)
+ promises.push(readAllData(proc.stderr, read, options.stderr));
+
+ // Process stdin
+
+ if (typeof options.stdin === "string") {
+ write(proc.stdin, options.stdin);
+ proc.stdin.close();
+ }
+
+
+ // Handle process completion
+
+ if (options.done)
+ Promise.all(promises)
+ .then(() => proc.wait())
+ .then(options.done);
+
+ return proc;
+ });
+
+ procPromise.catch(e => {
+ if (options.done)
+ options.done({exitCode: -1}, e);
+ else
+ Cu.reportError(e instanceof Error ? e : e.message || e);
+ });
+
+ if (typeof options.stdin === "function") {
+ // Unfortunately, some callers (child_process.js) depend on this
+ // being called synchronously.
+ options.stdin({
+ write(val) {
+ procPromise.then(proc => {
+ write(proc.stdin, val);
+ });
+ },
+
+ close() {
+ procPromise.then(proc => {
+ proc.stdin.close();
+ });
+ },
+ });
+ }
+
+ result = {
+ get pid() {
+ return awaitPromise(procPromise.then(proc => {
+ return proc.pid;
+ }));
+ },
+
+ wait() {
+ return awaitPromise(procPromise.then(proc => {
+ return proc.wait().then(({exitCode}) => exitCode);
+ }));
+ },
+
+ kill(hard = false) {
+ procPromise.then(proc => {
+ proc.kill(hard ? 0 : undefined);
+ });
+ },
+ };
+
+ return result;
+ },
+};
+
+module.exports = subprocess;
diff --git a/toolkit/jetpack/sdk/system/environment.js b/toolkit/jetpack/sdk/system/environment.js
new file mode 100644
index 000000000..13621a696
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/environment.js
@@ -0,0 +1,33 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { Cc, Ci } = require('chrome');
+const { get, set, exists } = Cc['@mozilla.org/process/environment;1'].
+ getService(Ci.nsIEnvironment);
+
+exports.env = new Proxy({}, {
+ deleteProperty(target, property) {
+ set(property, null);
+ return true;
+ },
+
+ get(target, property, receiver) {
+ return get(property) || undefined;
+ },
+
+ has(target, property) {
+ return exists(property);
+ },
+
+ set(target, property, value, receiver) {
+ set(property, value);
+ return true;
+ }
+});
diff --git a/toolkit/jetpack/sdk/system/events-shimmed.js b/toolkit/jetpack/sdk/system/events-shimmed.js
new file mode 100644
index 000000000..14496f1f0
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/events-shimmed.js
@@ -0,0 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+const events = require('./events.js');
+
+exports.emit = (type, event) => events.emit(type, event, true);
+exports.on = (type, listener, strong) => events.on(type, listener, strong, true);
+exports.once = (type, listener) => events.once(type, listener, true);
+exports.off = (type, listener) => events.off(type, listener, true);
diff --git a/toolkit/jetpack/sdk/system/events.js b/toolkit/jetpack/sdk/system/events.js
new file mode 100644
index 000000000..0cf525aa1
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/events.js
@@ -0,0 +1,181 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+const { Cc, Ci, Cu } = require('chrome');
+const { Unknown } = require('../platform/xpcom');
+const { Class } = require('../core/heritage');
+const { ns } = require('../core/namespace');
+const observerService =
+ Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
+const { addObserver, removeObserver, notifyObservers } = observerService;
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+const addObserverNoShim = ShimWaiver.getProperty(observerService, "addObserver");
+const removeObserverNoShim = ShimWaiver.getProperty(observerService, "removeObserver");
+const notifyObserversNoShim = ShimWaiver.getProperty(observerService, "notifyObservers");
+const unloadSubject = require('@loader/unload');
+
+const Subject = Class({
+ extends: Unknown,
+ initialize: function initialize(object) {
+ // Double-wrap the object and set a property identifying the
+ // wrappedJSObject as one of our wrappers to distinguish between
+ // subjects that are one of our wrappers (which we should unwrap
+ // when notifying our observers) and those that are real JS XPCOM
+ // components (which we should pass through unaltered).
+ this.wrappedJSObject = {
+ observersModuleSubjectWrapper: true,
+ object: object
+ };
+ },
+ getScriptableHelper: function() {},
+ getInterfaces: function() {}
+});
+
+function emit(type, event, shimmed = false) {
+ // From bug 910599
+ // We must test to see if 'subject' or 'data' is a defined property
+ // of the event object, but also allow primitives to be passed in,
+ // which the `in` operator breaks, yet `null` is an object, hence
+ // the long conditional
+ let subject = event && typeof event === 'object' && 'subject' in event ?
+ Subject(event.subject) :
+ null;
+ let data = event && typeof event === 'object' ?
+ // An object either returns its `data` property or null
+ ('data' in event ? event.data : null) :
+ // All other types return themselves (and cast to strings/null
+ // via observer service)
+ event;
+ if (shimmed) {
+ notifyObservers(subject, type, data);
+ } else {
+ notifyObserversNoShim(subject, type, data);
+ }
+}
+exports.emit = emit;
+
+const Observer = Class({
+ extends: Unknown,
+ initialize: function initialize(listener) {
+ this.listener = listener;
+ },
+ interfaces: [ 'nsIObserver', 'nsISupportsWeakReference' ],
+ observe: function(subject, topic, data) {
+ // Extract the wrapped object for subjects that are one of our
+ // wrappers around a JS object. This way we support both wrapped
+ // subjects created using this module and those that are real
+ // XPCOM components.
+ if (subject && typeof(subject) == 'object' &&
+ ('wrappedJSObject' in subject) &&
+ ('observersModuleSubjectWrapper' in subject.wrappedJSObject))
+ subject = subject.wrappedJSObject.object;
+
+ try {
+ this.listener({
+ type: topic,
+ subject: subject,
+ data: data
+ });
+ }
+ catch (error) {
+ console.exception(error);
+ }
+ }
+});
+
+const subscribers = ns();
+
+function on(type, listener, strong, shimmed = false) {
+ // Unless last optional argument is `true` we use a weak reference to a
+ // listener.
+ let weak = !strong;
+ // Take list of observers associated with given `listener` function.
+ let observers = subscribers(listener);
+ // If `observer` for the given `type` is not registered yet, then
+ // associate an `observer` and register it.
+ if (!(type in observers)) {
+ let observer = Observer(listener);
+ observers[type] = observer;
+ if (shimmed) {
+ addObserver(observer, type, weak);
+ } else {
+ addObserverNoShim(observer, type, weak);
+ }
+ // WeakRef gymnastics to remove all alive observers on unload
+ let ref = Cu.getWeakReference(observer);
+ weakRefs.set(observer, ref);
+ stillAlive.set(ref, type);
+ wasShimmed.set(ref, shimmed);
+ }
+}
+exports.on = on;
+
+function once(type, listener, shimmed = false) {
+ // Note: this code assumes order in which listeners are called, which is fine
+ // as long as dispatch happens in same order as listener registration which
+ // is the case now. That being said we should be aware that this may break
+ // in a future if order will change.
+ on(type, listener, shimmed);
+ on(type, function cleanup() {
+ off(type, listener, shimmed);
+ off(type, cleanup, shimmed);
+ }, true, shimmed);
+}
+exports.once = once;
+
+function off(type, listener, shimmed = false) {
+ // Take list of observers as with the given `listener`.
+ let observers = subscribers(listener);
+ // If `observer` for the given `type` is registered, then
+ // remove it & unregister.
+ if (type in observers) {
+ let observer = observers[type];
+ delete observers[type];
+ if (shimmed) {
+ removeObserver(observer, type);
+ } else {
+ removeObserverNoShim(observer, type);
+ }
+ stillAlive.delete(weakRefs.get(observer));
+ wasShimmed.delete(weakRefs.get(observer));
+ }
+}
+exports.off = off;
+
+// must use WeakMap to keep reference to all the WeakRefs (!), see bug 986115
+var weakRefs = new WeakMap();
+
+// and we're out of beta, we're releasing on time!
+var stillAlive = new Map();
+
+var wasShimmed = new Map();
+
+on('sdk:loader:destroy', function onunload({ subject, data: reason }) {
+ // using logic from ./unload, to avoid a circular module reference
+ if (subject.wrappedJSObject === unloadSubject) {
+ off('sdk:loader:destroy', onunload, false);
+
+ // don't bother
+ if (reason === 'shutdown')
+ return;
+
+ stillAlive.forEach( (type, ref) => {
+ let observer = ref.get();
+ if (observer) {
+ if (wasShimmed.get(ref)) {
+ removeObserver(observer, type);
+ } else {
+ removeObserverNoShim(observer, type);
+ }
+ }
+ })
+ }
+ // a strong reference
+}, true, false);
diff --git a/toolkit/jetpack/sdk/system/globals.js b/toolkit/jetpack/sdk/system/globals.js
new file mode 100644
index 000000000..a1a6cf9a2
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/globals.js
@@ -0,0 +1,46 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+var { Cc, Ci, CC } = require('chrome');
+var { PlainTextConsole } = require('../console/plain-text');
+var { stdout } = require('../system');
+var ScriptError = CC('@mozilla.org/scripterror;1', 'nsIScriptError');
+var consoleService = Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService);
+
+// On windows dump does not writes into stdout so cfx can't read thous dumps.
+// To workaround this issue we write to a special file from which cfx will
+// read and print to the console.
+// For more details see: bug-673383
+exports.dump = stdout.write;
+
+exports.console = new PlainTextConsole();
+
+// Provide CommonJS `define` to allow authoring modules in a format that can be
+// loaded both into jetpack and into browser via AMD loaders.
+Object.defineProperty(exports, 'define', {
+ // `define` is provided as a lazy getter that binds below defined `define`
+ // function to the module scope, so that require, exports and module
+ // variables remain accessible.
+ configurable: true,
+ get: function() {
+ let sandbox = this;
+ return function define(factory) {
+ factory = Array.slice(arguments).pop();
+ factory.call(sandbox, sandbox.require, sandbox.exports, sandbox.module);
+ }
+ },
+ set: function(value) {
+ Object.defineProperty(this, 'define', {
+ configurable: true,
+ enumerable: true,
+ value,
+ });
+ },
+});
diff --git a/toolkit/jetpack/sdk/system/process.js b/toolkit/jetpack/sdk/system/process.js
new file mode 100644
index 000000000..f44a36658
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/process.js
@@ -0,0 +1,62 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const {
+ exit, version, stdout, stderr, platform, architecture
+} = require("../system");
+
+/**
+ * Supported
+ */
+
+exports.stdout = stdout;
+exports.stderr = stderr;
+exports.version = version;
+exports.versions = {};
+exports.config = {};
+exports.arch = architecture;
+exports.platform = platform;
+exports.exit = exit;
+
+/**
+ * Partial support
+ */
+
+// An alias to `setTimeout(fn, 0)`, which isn't the same as node's `nextTick`,
+// but atleast ensures it'll occur asynchronously
+exports.nextTick = (callback) => setTimeout(callback, 0);
+
+/**
+ * Unsupported
+ */
+
+exports.maxTickDepth = 1000;
+exports.pid = 0;
+exports.title = "";
+exports.stdin = {};
+exports.argv = [];
+exports.execPath = "";
+exports.execArgv = [];
+exports.abort = function () {};
+exports.chdir = function () {};
+exports.cwd = function () {};
+exports.env = {};
+exports.getgid = function () {};
+exports.setgid = function () {};
+exports.getuid = function () {};
+exports.setuid = function () {};
+exports.getgroups = function () {};
+exports.setgroups = function () {};
+exports.initgroups = function () {};
+exports.kill = function () {};
+exports.memoryUsage = function () {};
+exports.umask = function () {};
+exports.uptime = function () {};
+exports.hrtime = function () {};
diff --git a/toolkit/jetpack/sdk/system/runtime.js b/toolkit/jetpack/sdk/system/runtime.js
new file mode 100644
index 000000000..9a70f142d
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/runtime.js
@@ -0,0 +1,28 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci } = require("chrome");
+const runtime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
+
+exports.inSafeMode = runtime.inSafeMode;
+exports.OS = runtime.OS;
+exports.processType = runtime.processType;
+exports.widgetToolkit = runtime.widgetToolkit;
+exports.processID = runtime.processID;
+
+// Attempt to access `XPCOMABI` may throw exception, in which case exported
+// `XPCOMABI` will be set to `null`.
+// https://mxr.mozilla.org/mozilla-central/source/toolkit/xre/nsAppRunner.cpp#732
+try {
+ exports.XPCOMABI = runtime.XPCOMABI;
+}
+catch (error) {
+ exports.XPCOMABI = null;
+}
diff --git a/toolkit/jetpack/sdk/system/unload.js b/toolkit/jetpack/sdk/system/unload.js
new file mode 100644
index 000000000..98ab5f8f3
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/unload.js
@@ -0,0 +1,104 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Parts of this module were taken from narwhal:
+//
+// http://narwhaljs.org
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cu } = require('chrome');
+const { on, off } = require('./events');
+const unloadSubject = require('@loader/unload');
+
+const observers = [];
+const unloaders = [];
+
+function WeakObserver(inner) {
+ this._inner = Cu.getWeakReference(inner);
+}
+
+Object.defineProperty(WeakObserver.prototype, 'value', {
+ get: function() { this._inner.get() }
+});
+
+var when = exports.when = function when(observer, opts) {
+ opts = opts || {};
+ for (var i = 0; i < observers.length; ++i) {
+ if (observers[i] === observer || observers[i].value === observer) {
+ return;
+ }
+ }
+ if (opts.weak) {
+ observers.unshift(new WeakObserver(observer));
+ } else {
+ observers.unshift(observer);
+ }
+};
+
+var ensure = exports.ensure = function ensure(obj, destructorName) {
+ if (!destructorName)
+ destructorName = "unload";
+ if (!(destructorName in obj))
+ throw new Error("object has no '" + destructorName + "' property");
+
+ let called = false;
+ let originalDestructor = obj[destructorName];
+
+ function unloadWrapper(reason) {
+ if (!called) {
+ called = true;
+ let index = unloaders.indexOf(unloadWrapper);
+ if (index == -1)
+ throw new Error("internal error: unloader not found");
+ unloaders.splice(index, 1);
+ originalDestructor.call(obj, reason);
+ originalDestructor = null;
+ destructorName = null;
+ obj = null;
+ }
+ };
+
+ // TODO: Find out why the order is inverted here. It seems that
+ // it may be causing issues!
+ unloaders.push(unloadWrapper);
+
+ obj[destructorName] = unloadWrapper;
+};
+
+function unload(reason) {
+ observers.forEach(function(observer) {
+ try {
+ if (observer instanceof WeakObserver) {
+ observer = observer.value;
+ }
+ if (typeof observer === 'function') {
+ observer(reason);
+ }
+ }
+ catch (error) {
+ console.exception(error);
+ }
+ });
+}
+
+when(function(reason) {
+ unloaders.slice().forEach(function(unloadWrapper) {
+ unloadWrapper(reason);
+ });
+});
+
+on('sdk:loader:destroy', function onunload({ subject, data: reason }) {
+ // If this loader is unload then `subject.wrappedJSObject` will be
+ // `destructor`.
+ if (subject.wrappedJSObject === unloadSubject) {
+ off('sdk:loader:destroy', onunload);
+ unload(reason);
+ }
+// Note that we use strong reference to listener here to make sure it's not
+// GC-ed, which may happen otherwise since nothing keeps reference to `onunolad`
+// function.
+}, true);
diff --git a/toolkit/jetpack/sdk/system/xul-app.js b/toolkit/jetpack/sdk/system/xul-app.js
new file mode 100644
index 000000000..612386f77
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/xul-app.js
@@ -0,0 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { XulApp } = require("./xul-app.jsm");
+
+Object.keys(XulApp).forEach(k => exports[k] = XulApp[k]);
diff --git a/toolkit/jetpack/sdk/system/xul-app.jsm b/toolkit/jetpack/sdk/system/xul-app.jsm
new file mode 100644
index 000000000..90681bb1b
--- /dev/null
+++ b/toolkit/jetpack/sdk/system/xul-app.jsm
@@ -0,0 +1,242 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+this.EXPORTED_SYMBOLS = [ "XulApp" ];
+
+var { classes: Cc, interfaces: Ci } = Components;
+
+var exports = {};
+this.XulApp = exports;
+
+var appInfo;
+
+// NOTE: below is required to avoid failing xpcshell tests,
+// which do not implement nsIXULAppInfo
+// See Bug 1114752 https://bugzilla.mozilla.org/show_bug.cgi?id=1114752
+try {
+ appInfo = Cc["@mozilla.org/xre/app-info;1"]
+ .getService(Ci.nsIXULAppInfo);
+}
+catch (e) {
+ // xpcshell test case
+ appInfo = {};
+}
+var vc = Cc["@mozilla.org/xpcom/version-comparator;1"]
+ .getService(Ci.nsIVersionComparator);
+
+var ID = exports.ID = appInfo.ID;
+var name = exports.name = appInfo.name;
+var version = exports.version = appInfo.version;
+var platformVersion = exports.platformVersion = appInfo.platformVersion;
+
+// The following mapping of application names to GUIDs was taken from:
+//
+// https://addons.mozilla.org/en-US/firefox/pages/appversions
+//
+// Using the GUID instead of the app's name is preferable because sometimes
+// re-branded versions of a product have different names: for instance,
+// Firefox, Minefield, Iceweasel, and Shiretoko all have the same
+// GUID.
+
+var ids = exports.ids = {
+ Firefox: "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ Mozilla: "{86c18b42-e466-45a9-ae7a-9b95ba6f5640}",
+ SeaMonkey: "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}",
+ Fennec: "{aa3c5121-dab2-40e2-81ca-7ea25febc110}",
+ Thunderbird: "{3550f703-e582-4d05-9a08-453d09bdfdc6}",
+ Instantbird: "{33cb9019-c295-46dd-be21-8c4936574bee}"
+};
+
+function is(name) {
+ if (!(name in ids))
+ throw new Error("Unkown Mozilla Application: " + name);
+ return ID == ids[name];
+};
+exports.is = is;
+
+function isOneOf(names) {
+ for (var i = 0; i < names.length; i++)
+ if (is(names[i]))
+ return true;
+ return false;
+};
+exports.isOneOf = isOneOf;
+
+/**
+ * Use this to check whether the given version (e.g. xulApp.platformVersion)
+ * is in the given range. Versions must be in version comparator-compatible
+ * format. See MDC for details:
+ * https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIVersionComparator
+ */
+var versionInRange = exports.versionInRange =
+function versionInRange(version, lowInclusive, highExclusive) {
+ return (vc.compare(version, lowInclusive) >= 0) &&
+ (vc.compare(version, highExclusive) < 0);
+}
+
+const reVersionRange = /^((?:<|>)?=?)?\s*((?:\d+[\S]*)|\*)(?:\s+((?:<|>)=?)?(\d+[\S]+))?$/;
+const reOnlyInifinity = /^[<>]?=?\s*[*x]$/;
+const reSubInfinity = /\.[*x]/g;
+const reHyphenRange = /^(\d+.*?)\s*-\s*(\d+.*?)$/;
+const reRangeSeparator = /\s*\|\|\s*/;
+
+const compares = {
+ "=": function (c) { return c === 0 },
+ ">=": function (c) { return c >= 0 },
+ "<=": function (c) { return c <= 0},
+ "<": function (c) { return c < 0 },
+ ">": function (c) { return c > 0 }
+}
+
+function normalizeRange(range) {
+ return range
+ .replace(reOnlyInifinity, "")
+ .replace(reSubInfinity, ".*")
+ .replace(reHyphenRange, ">=$1 <=$2")
+}
+
+/**
+ * Compare the versions given, using the comparison operator provided.
+ * Internal use only.
+ *
+ * @example
+ * compareVersion("1.2", "<=", "1.*") // true
+ *
+ * @param {String} version
+ * A version to compare
+ *
+ * @param {String} comparison
+ * The comparison operator
+ *
+ * @param {String} compareVersion
+ * A version to compare
+ */
+function compareVersion(version, comparison, compareVersion) {
+ let hasWildcard = compareVersion.indexOf("*") !== -1;
+
+ comparison = comparison || "=";
+
+ if (hasWildcard) {
+ switch (comparison) {
+ case "=":
+ let zeroVersion = compareVersion.replace(reSubInfinity, ".0");
+ return versionInRange(version, zeroVersion, compareVersion);
+ case ">=":
+ compareVersion = compareVersion.replace(reSubInfinity, ".0");
+ break;
+ }
+ }
+
+ let compare = compares[comparison];
+
+ return typeof compare === "function" && compare(vc.compare(version, compareVersion));
+}
+
+/**
+ * Returns `true` if `version` satisfies the `versionRange` given.
+ * If only an argument is passed, is used as `versionRange` and compared against
+ * `xulApp.platformVersion`.
+ *
+ * `versionRange` is either a string which has one or more space-separated
+ * descriptors, or a range like "fromVersion - toVersion".
+ * Version range descriptors may be any of the following styles:
+ *
+ * - "version" Must match `version` exactly
+ * - "=version" Same as just `version`
+ * - ">version" Must be greater than `version`
+ * - ">=version" Must be greater or equal than `version`
+ * - "<version" Must be less than `version`
+ * - "<=version" Must be less or equal than `version`
+ * - "1.2.x" or "1.2.*" See 'X version ranges' below
+ * - "*" or "" (just an empty string) Matches any version
+ * - "version1 - version2" Same as ">=version1 <=version2"
+ * - "range1 || range2" Passes if either `range1` or `range2` are satisfied
+ *
+ * For example, these are all valid:
+ * - "1.0.0 - 2.9999.9999"
+ * - ">=1.0.2 <2.1.2"
+ * - ">1.0.2 <=2.3.4"
+ * - "2.0.1"
+ * - "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0"
+ * - "2.x" (equivalent to "2.*")
+ * - "1.2.x" (equivalent to "1.2.*" and ">=1.2.0 <1.3.0")
+ */
+function satisfiesVersion(version, versionRange) {
+ if (arguments.length === 1) {
+ versionRange = version;
+ version = appInfo.version;
+ }
+
+ let ranges = versionRange.trim().split(reRangeSeparator);
+
+ return ranges.some(function(range) {
+ range = normalizeRange(range);
+
+ // No versions' range specified means that any version satisfies the
+ // requirements.
+ if (range === "")
+ return true;
+
+ let matches = range.match(reVersionRange);
+
+ if (!matches)
+ return false;
+
+ let [, lowMod, lowVer, highMod, highVer] = matches;
+
+ return compareVersion(version, lowMod, lowVer) && (highVer !== undefined
+ ? compareVersion(version, highMod, highVer)
+ : true);
+ });
+}
+exports.satisfiesVersion = satisfiesVersion;
+
+/**
+ * Ensure the current application satisfied the requirements specified in the
+ * module given. If not, an exception related to the incompatibility is
+ * returned; `null` otherwise.
+ *
+ * @param {Object} module
+ * The module to check
+ * @returns {Error}
+ */
+function incompatibility(module) {
+ let { metadata, id } = module;
+
+ // if metadata or engines are not specified we assume compatibility is not
+ // an issue.
+ if (!metadata || !("engines" in metadata))
+ return null;
+
+ let { engines } = metadata;
+
+ if (engines === null || typeof(engines) !== "object")
+ return new Error("Malformed engines' property in metadata");
+
+ let applications = Object.keys(engines);
+
+ let versionRange;
+ applications.forEach(function(name) {
+ if (is(name)) {
+ versionRange = engines[name];
+ // Continue iteration. We want to ensure the module doesn't
+ // contain a typo in the applications' name or some unknown
+ // application - `is` function throws an exception in that case.
+ }
+ });
+
+ if (typeof(versionRange) === "string") {
+ if (satisfiesVersion(versionRange))
+ return null;
+
+ return new Error("Unsupported Application version: The module " + id +
+ " currently supports only version " + versionRange + " of " +
+ name + ".");
+ }
+
+ return new Error("Unsupported Application: The module " + id +
+ " currently supports only " + applications.join(", ") + ".")
+}
+exports.incompatibility = incompatibility;
diff --git a/toolkit/jetpack/sdk/tab/events.js b/toolkit/jetpack/sdk/tab/events.js
new file mode 100644
index 000000000..e431cc9d2
--- /dev/null
+++ b/toolkit/jetpack/sdk/tab/events.js
@@ -0,0 +1,74 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+// This module provides temporary shim until Bug 843901 is shipped.
+// It basically registers tab event listeners on all windows that get
+// opened and forwards them through observer notifications.
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Ci } = require("chrome");
+const { windows, isInteractive } = require("../window/utils");
+const { events } = require("../browser/events");
+const { open } = require("../event/dom");
+const { filter, map, merge, expand } = require("../event/utils");
+const isFennec = require("sdk/system/xul-app").is("Fennec");
+
+// Module provides event stream (in nodejs style) that emits data events
+// for all the tab events that happen in running firefox. At the moment
+// it does it by registering listeners on all browser windows and then
+// forwarding events when they occur to a stream. This will become obsolete
+// once Bug 843901 is fixed, and we'll just leverage observer notifications.
+
+// Set of tab events that this module going to aggregate and expose.
+const TYPES = ["TabOpen","TabClose","TabSelect","TabMove","TabPinned",
+ "TabUnpinned"];
+
+// Utility function that given a browser `window` returns stream of above
+// defined tab events for all tabs on the given window.
+function tabEventsFor(window) {
+ // Map supported event types to a streams of those events on the given
+ // `window` and than merge these streams into single form stream off
+ // all events.
+ let channels = TYPES.map(type => open(window, type));
+ return merge(channels);
+}
+
+// Create our event channels. We do this in a separate function to
+// minimize the chance of leaking intermediate objects on the global.
+function makeEvents() {
+ // Filter DOMContentLoaded events from all the browser events.
+ var readyEvents = filter(events, e => e.type === "DOMContentLoaded");
+ // Map DOMContentLoaded events to it's target browser windows.
+ var futureWindows = map(readyEvents, e => e.target);
+ // Expand all browsers that will become interactive to supported tab events
+ // on these windows. Result will be a tab events from all tabs of all windows
+ // that will become interactive.
+ var eventsFromFuture = expand(futureWindows, tabEventsFor);
+
+ // Above covers only windows that will become interactive in a future, but some
+ // windows may already be interactive so we pick those and expand to supported
+ // tab events for them too.
+ var interactiveWindows = windows("navigator:browser", { includePrivate: true }).
+ filter(isInteractive);
+ var eventsFromInteractive = merge(interactiveWindows.map(tabEventsFor));
+
+
+ // Finally merge stream of tab events from future windows and current windows
+ // to cover all tab events on all windows that will open.
+ return merge([eventsFromInteractive, eventsFromFuture]);
+}
+
+// Map events to Fennec format if necessary
+exports.events = map(makeEvents(), function (event) {
+ return !isFennec ? event : {
+ type: event.type,
+ target: event.target.ownerDocument.defaultView.BrowserApp
+ .getTabForBrowser(event.target)
+ };
+});
diff --git a/toolkit/jetpack/sdk/tabs.js b/toolkit/jetpack/sdk/tabs.js
new file mode 100644
index 000000000..f61cad478
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs.js
@@ -0,0 +1,17 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+if (require("./system/xul-app").is("Fennec")) {
+ module.exports = require("./windows/tabs-fennec").tabs;
+}
+else {
+ module.exports = require("./tabs/tabs-firefox");
+}
+
+const tabs = module.exports;
diff --git a/toolkit/jetpack/sdk/tabs/common.js b/toolkit/jetpack/sdk/tabs/common.js
new file mode 100644
index 000000000..9ee512a7b
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/common.js
@@ -0,0 +1,34 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { validateOptions } = require("../deprecated/api-utils");
+const { data } = require("../self");
+
+function Options(options) {
+ if ('string' === typeof options)
+ options = { url: options };
+
+ return validateOptions(options, {
+ url: {
+ is: ["string"],
+ map: (v) => v ? data.url(v) : v
+ },
+ inBackground: {
+ map: Boolean,
+ is: ["undefined", "boolean"]
+ },
+ isPinned: { is: ["undefined", "boolean"] },
+ isPrivate: { is: ["undefined", "boolean"] },
+ inNewWindow: { is: ["undefined", "boolean"] },
+ onOpen: { is: ["undefined", "function"] },
+ onClose: { is: ["undefined", "function"] },
+ onReady: { is: ["undefined", "function"] },
+ onLoad: { is: ["undefined", "function"] },
+ onPageShow: { is: ["undefined", "function"] },
+ onActivate: { is: ["undefined", "function"] },
+ onDeactivate: { is: ["undefined", "function"] }
+ });
+}
+exports.Options = Options;
diff --git a/toolkit/jetpack/sdk/tabs/events.js b/toolkit/jetpack/sdk/tabs/events.js
new file mode 100644
index 000000000..65650f9dc
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/events.js
@@ -0,0 +1,39 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const ON_PREFIX = "on";
+const TAB_PREFIX = "Tab";
+
+const EVENTS = {
+ ready: "DOMContentLoaded",
+ load: "load", // Used for non-HTML content
+ pageshow: "pageshow", // Used for cached content
+ open: "TabOpen",
+ close: "TabClose",
+ activate: "TabSelect",
+ deactivate: null,
+ pinned: "TabPinned",
+ unpinned: "TabUnpinned"
+}
+exports.EVENTS = EVENTS;
+
+Object.keys(EVENTS).forEach(function(name) {
+ EVENTS[name] = {
+ name: name,
+ listener: createListenerName(name),
+ dom: EVENTS[name]
+ }
+});
+
+function createListenerName (name) {
+ if (name === 'pageshow')
+ return 'onPageShow';
+ else
+ return ON_PREFIX + name.charAt(0).toUpperCase() + name.substr(1);
+}
diff --git a/toolkit/jetpack/sdk/tabs/helpers.js b/toolkit/jetpack/sdk/tabs/helpers.js
new file mode 100644
index 000000000..b2c8aa013
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/helpers.js
@@ -0,0 +1,22 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+
+// NOTE: This file should only export Tab instances
+
+
+const { getTabForBrowser: getRawTabForBrowser } = require('./utils');
+const { modelFor } = require('../model/core');
+
+exports.getTabForRawTab = modelFor;
+
+function getTabForBrowser(browser) {
+ return modelFor(getRawTabForBrowser(browser)) || null;
+}
+exports.getTabForBrowser = getTabForBrowser;
diff --git a/toolkit/jetpack/sdk/tabs/namespace.js b/toolkit/jetpack/sdk/tabs/namespace.js
new file mode 100644
index 000000000..3553b1a99
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/namespace.js
@@ -0,0 +1,10 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+var { ns } = require('../core/namespace');
+
+exports.tabsNS = ns();
+exports.tabNS = ns();
+exports.rawTabNS = ns();
diff --git a/toolkit/jetpack/sdk/tabs/observer.js b/toolkit/jetpack/sdk/tabs/observer.js
new file mode 100644
index 000000000..4e935cd62
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/observer.js
@@ -0,0 +1,113 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { EventTarget } = require("../event/target");
+const { emit } = require("../event/core");
+const { DOMEventAssembler } = require("../deprecated/events/assembler");
+const { Class } = require("../core/heritage");
+const { getActiveTab, getTabs } = require("./utils");
+const { browserWindowIterator } = require("../deprecated/window-utils");
+const { isBrowser, windows, getMostRecentBrowserWindow } = require("../window/utils");
+const { observer: windowObserver } = require("../windows/observer");
+const { when } = require("../system/unload");
+
+const EVENTS = {
+ "TabOpen": "open",
+ "TabClose": "close",
+ "TabSelect": "select",
+ "TabMove": "move",
+ "TabPinned": "pinned",
+ "TabUnpinned": "unpinned"
+};
+
+const selectedTab = Symbol("observer/state/selectedTab");
+
+// Event emitter objects used to register listeners and emit events on them
+// when they occur.
+const Observer = Class({
+ implements: [EventTarget, DOMEventAssembler],
+ initialize() {
+ this[selectedTab] = null;
+ // Currently Gecko does not dispatch any event on the previously selected
+ // tab before / after "TabSelect" is dispatched. In order to work around this
+ // limitation we keep track of selected tab and emit "deactivate" event with
+ // that before emitting "activate" on selected tab.
+ this.on("select", tab => {
+ const selected = this[selectedTab];
+ if (selected !== tab) {
+ if (selected) {
+ emit(this, 'deactivate', selected);
+ }
+
+ if (tab) {
+ this[selectedTab] = tab;
+ emit(this, 'activate', this[selectedTab]);
+ }
+ }
+ });
+
+
+ // We also observe opening / closing windows in order to add / remove it's
+ // containers to the observed list.
+ windowObserver.on("open", chromeWindow => {
+ if (isBrowser(chromeWindow)) {
+ this.observe(chromeWindow);
+ }
+ });
+
+ windowObserver.on("close", chromeWindow => {
+ if (isBrowser(chromeWindow)) {
+ // Bug 751546: Emit `deactivate` event on window close immediatly
+ // Otherwise we are going to face "dead object" exception on `select` event
+ if (getActiveTab(chromeWindow) === this[selectedTab]) {
+ emit(this, "deactivate", this[selectedTab]);
+ this[selectedTab] = null;
+ }
+ this.ignore(chromeWindow);
+ }
+ });
+
+
+ // Currently gecko does not dispatches "TabSelect" events when different
+ // window gets activated. To work around this limitation we emulate "select"
+ // event for this case.
+ windowObserver.on("activate", chromeWindow => {
+ if (isBrowser(chromeWindow)) {
+ emit(this, "select", getActiveTab(chromeWindow));
+ }
+ });
+
+ // We should synchronize state, since probably we already have at least one
+ // window open.
+ for (let chromeWindow of browserWindowIterator()) {
+ this.observe(chromeWindow);
+ }
+
+ when(_ => {
+ // Don't dispatch a deactivate event during unload.
+ this[selectedTab] = null;
+ });
+ },
+ /**
+ * Events that are supported and emitted by the module.
+ */
+ supportedEventsTypes: Object.keys(EVENTS),
+ /**
+ * Function handles all the supported events on all the windows that are
+ * observed. Method is used to proxy events to the listeners registered on
+ * this event emitter.
+ * @param {Event} event
+ * Keyboard event being emitted.
+ */
+ handleEvent: function handleEvent(event) {
+ emit(this, EVENTS[event.type], event.target, event);
+ }
+});
+
+exports.observer = new Observer();
diff --git a/toolkit/jetpack/sdk/tabs/tab-fennec.js b/toolkit/jetpack/sdk/tabs/tab-fennec.js
new file mode 100644
index 000000000..3927337f6
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/tab-fennec.js
@@ -0,0 +1,249 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { Cc, Ci } = require('chrome');
+const { Class } = require('../core/heritage');
+const { tabNS, rawTabNS } = require('./namespace');
+const { EventTarget } = require('../event/target');
+const { activateTab, getTabTitle, setTabTitle, closeTab, getTabURL,
+ getTabContentWindow, getTabForBrowser, setTabURL, getOwnerWindow,
+ getTabContentDocument, getTabContentType, getTabId, isTab } = require('./utils');
+const { emit } = require('../event/core');
+const { isPrivate } = require('../private-browsing/utils');
+const { isWindowPrivate } = require('../window/utils');
+const { when: unload } = require('../system/unload');
+const { BLANK } = require('../content/thumbnail');
+const { viewFor } = require('../view/core');
+const { EVENTS } = require('./events');
+const { modelFor } = require('../model/core');
+
+const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec';
+
+const Tab = Class({
+ extends: EventTarget,
+ initialize: function initialize(options) {
+ options = options.tab ? options : { tab: options };
+ let tab = options.tab;
+
+ EventTarget.prototype.initialize.call(this, options);
+ let tabInternals = tabNS(this);
+ rawTabNS(tab).tab = this;
+
+ let window = tabInternals.window = options.window || getOwnerWindow(tab);
+ tabInternals.tab = tab;
+
+ // TabReady
+ let onReady = tabInternals.onReady = onTabReady.bind(this);
+ tab.browser.addEventListener(EVENTS.ready.dom, onReady, false);
+
+ // TabPageShow
+ let onPageShow = tabInternals.onPageShow = onTabPageShow.bind(this);
+ tab.browser.addEventListener(EVENTS.pageshow.dom, onPageShow, false);
+
+ // TabLoad
+ let onLoad = tabInternals.onLoad = onTabLoad.bind(this);
+ tab.browser.addEventListener(EVENTS.load.dom, onLoad, true);
+
+ // TabClose
+ let onClose = tabInternals.onClose = onTabClose.bind(this);
+ window.BrowserApp.deck.addEventListener(EVENTS.close.dom, onClose, false);
+
+ unload(cleanupTab.bind(null, this));
+ },
+
+ /**
+ * The title of the page currently loaded in the tab.
+ * Changing this property changes an actual title.
+ * @type {String}
+ */
+ get title() {
+ return getTabTitle(tabNS(this).tab);
+ },
+ set title(title) {
+ setTabTitle(tabNS(this).tab, title);
+ },
+
+ /**
+ * Location of the page currently loaded in this tab.
+ * Changing this property will loads page under under the specified location.
+ * @type {String}
+ */
+ get url() {
+ return tabNS(this).closed ? undefined : getTabURL(tabNS(this).tab);
+ },
+ set url(url) {
+ setTabURL(tabNS(this).tab, url);
+ },
+
+ getThumbnail: function() {
+ // TODO: implement!
+ console.error(ERR_FENNEC_MSG);
+
+ // return 80x45 blank default
+ return BLANK;
+ },
+
+ /**
+ * tab's document readyState, or 'uninitialized' if it doesn't even exist yet.
+ */
+ get readyState() {
+ let doc = getTabContentDocument(tabNS(this).tab);
+ return doc && doc.readyState || 'uninitialized';
+ },
+
+ get id() {
+ return getTabId(tabNS(this).tab);
+ },
+
+ /**
+ * The index of the tab relative to other tabs in the application window.
+ * Changing this property will change order of the actual position of the tab.
+ * @type {Number}
+ */
+ get index() {
+ if (tabNS(this).closed) return undefined;
+
+ let tabs = tabNS(this).window.BrowserApp.tabs;
+ let tab = tabNS(this).tab;
+ for (var i = tabs.length; i >= 0; i--) {
+ if (tabs[i] === tab)
+ return i;
+ }
+ return null;
+ },
+ set index(value) {
+ console.error(ERR_FENNEC_MSG); // TODO
+ },
+
+ /**
+ * Whether or not tab is pinned (Is an app-tab).
+ * @type {Boolean}
+ */
+ get isPinned() {
+ console.error(ERR_FENNEC_MSG); // TODO
+ return false; // TODO
+ },
+ pin: function pin() {
+ console.error(ERR_FENNEC_MSG); // TODO
+ },
+ unpin: function unpin() {
+ console.error(ERR_FENNEC_MSG); // TODO
+ },
+
+ /**
+ * Returns the MIME type that the document loaded in the tab is being
+ * rendered as.
+ * @type {String}
+ */
+ get contentType() {
+ return getTabContentType(tabNS(this).tab);
+ },
+
+ /**
+ * Create a worker for this tab, first argument is options given to Worker.
+ * @type {Worker}
+ */
+ attach: function attach(options) {
+ // BUG 792946 https://bugzilla.mozilla.org/show_bug.cgi?id=792946
+ // TODO: fix this circular dependency
+ let { Worker } = require('./worker');
+ return Worker(options, getTabContentWindow(tabNS(this).tab));
+ },
+
+ /**
+ * Make this tab active.
+ */
+ activate: function activate() {
+ activateTab(tabNS(this).tab, tabNS(this).window);
+ },
+
+ /**
+ * Close the tab
+ */
+ close: function close(callback) {
+ let tab = this;
+ this.once(EVENTS.close.name, function () {
+ tabNS(tab).closed = true;
+ if (callback) callback();
+ });
+
+ closeTab(tabNS(this).tab);
+ },
+
+ /**
+ * Reload the tab
+ */
+ reload: function reload() {
+ tabNS(this).tab.browser.reload();
+ }
+});
+exports.Tab = Tab;
+
+// Implement `viewFor` polymorphic function for the Tab
+// instances.
+viewFor.define(Tab, x => tabNS(x).tab);
+
+function cleanupTab(tab) {
+ let tabInternals = tabNS(tab);
+ if (!tabInternals.tab)
+ return;
+
+ if (tabInternals.tab.browser) {
+ tabInternals.tab.browser.removeEventListener(EVENTS.ready.dom, tabInternals.onReady, false);
+ tabInternals.tab.browser.removeEventListener(EVENTS.pageshow.dom, tabInternals.onPageShow, false);
+ tabInternals.tab.browser.removeEventListener(EVENTS.load.dom, tabInternals.onLoad, true);
+ }
+ tabInternals.onReady = null;
+ tabInternals.onPageShow = null;
+ tabInternals.onLoad = null;
+ tabInternals.window.BrowserApp.deck.removeEventListener(EVENTS.close.dom, tabInternals.onClose, false);
+ tabInternals.onClose = null;
+ rawTabNS(tabInternals.tab).tab = null;
+ tabInternals.tab = null;
+ tabInternals.window = null;
+}
+
+function onTabReady(event) {
+ let win = event.target.defaultView;
+
+ // ignore frames
+ if (win === win.top) {
+ emit(this, 'ready', this);
+ }
+}
+
+function onTabLoad (event) {
+ let win = event.target.defaultView;
+
+ // ignore frames
+ if (win === win.top) {
+ emit(this, 'load', this);
+ }
+}
+
+function onTabPageShow(event) {
+ let win = event.target.defaultView;
+ if (win === win.top)
+ emit(this, 'pageshow', this, event.persisted);
+}
+
+// TabClose
+function onTabClose(event) {
+ let rawTab = getTabForBrowser(event.target);
+ if (tabNS(this).tab !== rawTab)
+ return;
+
+ emit(this, EVENTS.close.name, this);
+ cleanupTab(this);
+};
+
+isPrivate.implement(Tab, tab => {
+ return isWindowPrivate(getTabContentWindow(tabNS(tab).tab));
+});
+
+// Implement `modelFor` function for the Tab instances.
+modelFor.when(isTab, rawTab => {
+ return rawTabNS(rawTab).tab;
+});
diff --git a/toolkit/jetpack/sdk/tabs/tab-firefox.js b/toolkit/jetpack/sdk/tabs/tab-firefox.js
new file mode 100644
index 000000000..f1da92379
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/tab-firefox.js
@@ -0,0 +1,353 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { Class } = require('../core/heritage');
+const { observer } = require('./observer');
+const { observer: windowObserver } = require('../windows/observer');
+const { addListItem, removeListItem } = require('../util/list');
+const { viewFor } = require('../view/core');
+const { modelFor } = require('../model/core');
+const { emit, setListeners } = require('../event/core');
+const { EventTarget } = require('../event/target');
+const { getBrowserForTab, setTabURL, getTabId, getTabURL, getTabForBrowser,
+ getTabs, getTabTitle, setTabTitle, getIndex, closeTab, reload, move,
+ activateTab, pin, unpin, isTab } = require('./utils');
+const { isBrowser, getInnerId, isWindowPrivate } = require('../window/utils');
+const { getThumbnailURIForWindow, BLANK } = require("../content/thumbnail");
+const { when } = require('../system/unload');
+const { ignoreWindow, isPrivate } = require('../private-browsing/utils')
+const { defer } = require('../lang/functional');
+const { getURL } = require('../url/utils');
+const { frames, remoteRequire } = require('../remote/parent');
+remoteRequire('sdk/content/tab-events');
+
+const modelsFor = new WeakMap();
+const viewsFor = new WeakMap();
+const destroyed = new WeakMap();
+
+const tabEvents = {};
+exports.tabEvents = tabEvents;
+
+function browser(tab) {
+ return getBrowserForTab(viewsFor.get(tab));
+}
+
+function isDestroyed(tab) {
+ return destroyed.has(tab);
+}
+
+function isClosed(tab) {
+ if (!viewsFor.has(tab))
+ return true;
+ return viewsFor.get(tab).closing;
+}
+
+// private tab attribute where the remote cached value is stored
+const remoteReadyStateCached = Symbol("remoteReadyStateCached");
+
+const Tab = Class({
+ implements: [EventTarget],
+ initialize: function(tabElement, options = null) {
+ modelsFor.set(tabElement, this);
+ viewsFor.set(this, tabElement);
+
+ if (options) {
+ EventTarget.prototype.initialize.call(this, options);
+
+ if (options.isPinned)
+ this.pin();
+
+ // Note that activate is defered and so will run after any open event
+ // is sent out
+ if (!options.inBackground)
+ this.activate();
+ }
+
+ getURL.implement(this, tab => tab.url);
+ isPrivate.implement(this, tab => {
+ return isWindowPrivate(viewsFor.get(tab).ownerDocument.defaultView);
+ });
+ },
+
+ get id() {
+ return isDestroyed(this) ? undefined : getTabId(viewsFor.get(this));
+ },
+
+ get title() {
+ return isDestroyed(this) ? undefined : getTabTitle(viewsFor.get(this));
+ },
+
+ set title(val) {
+ if (isDestroyed(this))
+ return;
+
+ setTabTitle(viewsFor.get(this), val);
+ },
+
+ get url() {
+ return isDestroyed(this) ? undefined : getTabURL(viewsFor.get(this));
+ },
+
+ set url(val) {
+ if (isDestroyed(this))
+ return;
+
+ setTabURL(viewsFor.get(this), val);
+ },
+
+ get contentType() {
+ return isDestroyed(this) ? undefined : browser(this).documentContentType;
+ },
+
+ get index() {
+ return isDestroyed(this) ? undefined : getIndex(viewsFor.get(this));
+ },
+
+ set index(val) {
+ if (isDestroyed(this))
+ return;
+
+ move(viewsFor.get(this), val);
+ },
+
+ get isPinned() {
+ return isDestroyed(this) ? undefined : viewsFor.get(this).pinned;
+ },
+
+ get window() {
+ if (isClosed(this))
+ return undefined;
+
+ // TODO: Remove the dependency on the windows module, see bug 792670
+ require('../windows');
+ let tabElement = viewsFor.get(this);
+ let domWindow = tabElement.ownerDocument.defaultView;
+ return modelFor(domWindow);
+ },
+
+ get readyState() {
+ return isDestroyed(this) ? undefined : this[remoteReadyStateCached] || "uninitialized";
+ },
+
+ pin: function() {
+ if (isDestroyed(this))
+ return;
+
+ pin(viewsFor.get(this));
+ },
+
+ unpin: function() {
+ if (isDestroyed(this))
+ return;
+
+ unpin(viewsFor.get(this));
+ },
+
+ close: function(callback) {
+ let tabElement = viewsFor.get(this);
+
+ if (isDestroyed(this) || !tabElement || !tabElement.parentNode) {
+ if (callback)
+ callback();
+ return;
+ }
+
+ this.once('close', () => {
+ this.destroy();
+ if (callback)
+ callback();
+ });
+
+ closeTab(tabElement);
+ },
+
+ reload: function() {
+ if (isDestroyed(this))
+ return;
+
+ reload(viewsFor.get(this));
+ },
+
+ activate: defer(function() {
+ if (isDestroyed(this))
+ return;
+
+ activateTab(viewsFor.get(this));
+ }),
+
+ getThumbnail: function() {
+ if (isDestroyed(this))
+ return BLANK;
+
+ // TODO: This is unimplemented in e10s: bug 1148601
+ if (browser(this).isRemoteBrowser) {
+ console.error('This method is not supported with E10S');
+ return BLANK;
+ }
+ return getThumbnailURIForWindow(browser(this).contentWindow);
+ },
+
+ attach: function(options) {
+ if (isDestroyed(this))
+ return;
+
+ let { Worker } = require('../content/worker');
+ let { connect, makeChildOptions } = require('../content/utils');
+
+ let worker = Worker(options);
+ worker.once("detach", () => {
+ worker.destroy();
+ });
+
+ let attach = frame => {
+ let childOptions = makeChildOptions(options);
+ frame.port.emit("sdk/tab/attach", childOptions);
+ connect(worker, frame, { id: childOptions.id, url: this.url });
+ };
+
+ // Do this synchronously if possible
+ let frame = frames.getFrameForBrowser(browser(this));
+ if (frame) {
+ attach(frame);
+ }
+ else {
+ let listener = (frame) => {
+ if (frame.frameElement != browser(this))
+ return;
+
+ frames.off("attach", listener);
+ attach(frame);
+ };
+ frames.on("attach", listener);
+ }
+
+ return worker;
+ },
+
+ destroy: function() {
+ if (isDestroyed(this))
+ return;
+
+ destroyed.set(this, true);
+ }
+});
+exports.Tab = Tab;
+
+viewFor.define(Tab, tab => viewsFor.get(tab));
+
+// Returns the high-level window for this DOM window if the windows module has
+// ever been loaded otherwise returns null
+function maybeWindowFor(domWindow) {
+ try {
+ return modelFor(domWindow);
+ }
+ catch (e) {
+ return null;
+ }
+}
+
+function tabEmit(tab, event, ...args) {
+ // Don't emit events for destroyed tabs
+ if (isDestroyed(tab))
+ return;
+
+ // If the windows module was never loaded this will return null. We don't need
+ // to emit to the window.tabs object in this case as nothing can be listening.
+ let tabElement = viewsFor.get(tab);
+ let window = maybeWindowFor(tabElement.ownerDocument.defaultView);
+ if (window)
+ emit(window.tabs, event, tab, ...args);
+
+ emit(tabEvents, event, tab, ...args);
+ emit(tab, event, tab, ...args);
+}
+
+function windowClosed(domWindow) {
+ if (!isBrowser(domWindow))
+ return;
+
+ for (let tabElement of getTabs(domWindow)) {
+ tabEventListener("close", tabElement);
+ }
+}
+windowObserver.on('close', windowClosed);
+
+// Don't want to send close events after unloaded
+when(_ => {
+ windowObserver.off('close', windowClosed);
+});
+
+// Listen for tabbrowser events
+function tabEventListener(event, tabElement, ...args) {
+ let domWindow = tabElement.ownerDocument.defaultView;
+
+ if (ignoreWindow(domWindow))
+ return;
+
+ // Don't send events for tabs that are already closing
+ if (event != "close" && (tabElement.closing || !tabElement.parentNode))
+ return;
+
+ let tab = modelsFor.get(tabElement);
+ if (!tab)
+ tab = new Tab(tabElement);
+
+ let window = maybeWindowFor(domWindow);
+
+ if (event == "open") {
+ // Note, add to the window tabs first because if this is the first access to
+ // window.tabs it will be prefilling itself with everything from tabs
+ if (window)
+ addListItem(window.tabs, tab);
+ // The tabs module will take care of adding to its internal list
+ }
+ else if (event == "close") {
+ if (window)
+ removeListItem(window.tabs, tab);
+ // The tabs module will take care of removing from its internal list
+ }
+ else if (event == "init" || event == "create" || event == "ready" || event == "load") {
+ // Ignore load events from before browser windows have fully loaded, these
+ // are for about:blank in the initial tab
+ if (isBrowser(domWindow) && !domWindow.gBrowserInit.delayedStartupFinished)
+ return;
+
+ // update the cached remote readyState value
+ let { readyState } = args[0] || {};
+ tab[remoteReadyStateCached] = readyState;
+ }
+
+ if (event == "init") {
+ // Do not emit events for the detected existent tabs, we only need to cache
+ // their current document.readyState value.
+ return;
+ }
+
+ tabEmit(tab, event, ...args);
+
+ // The tab object shouldn't be reachable after closed
+ if (event == "close") {
+ viewsFor.delete(tab);
+ modelsFor.delete(tabElement);
+ }
+}
+observer.on('*', tabEventListener);
+
+// Listen for tab events from content
+frames.port.on('sdk/tab/event', (frame, event, ...args) => {
+ if (!frame.isTab)
+ return;
+
+ let tabElement = getTabForBrowser(frame.frameElement);
+ if (!tabElement)
+ return;
+
+ tabEventListener(event, tabElement, ...args);
+});
+
+// Implement `modelFor` function for the Tab instances..
+modelFor.when(isTab, view => {
+ return modelsFor.get(view);
+});
diff --git a/toolkit/jetpack/sdk/tabs/tab.js b/toolkit/jetpack/sdk/tabs/tab.js
new file mode 100644
index 000000000..fa2272494
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/tab.js
@@ -0,0 +1,24 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+const { getTargetWindow } = require("../content/mod");
+const { getTabContentWindow, isTab } = require("./utils");
+const { viewFor } = require("../view/core");
+
+if (require('../system/xul-app').name == 'Fennec') {
+ module.exports = require('./tab-fennec');
+}
+else {
+ module.exports = require('./tab-firefox');
+}
+
+getTargetWindow.when(isTab, tab => getTabContentWindow(tab));
+
+getTargetWindow.when(x => x instanceof module.exports.Tab,
+ tab => getTabContentWindow(viewFor(tab)));
diff --git a/toolkit/jetpack/sdk/tabs/tabs-firefox.js b/toolkit/jetpack/sdk/tabs/tabs-firefox.js
new file mode 100644
index 000000000..1eefecb4c
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/tabs-firefox.js
@@ -0,0 +1,135 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Class } = require('../core/heritage');
+const { Tab, tabEvents } = require('./tab');
+const { EventTarget } = require('../event/target');
+const { emit, setListeners } = require('../event/core');
+const { pipe } = require('../event/utils');
+const { observer: windowObserver } = require('../windows/observer');
+const { List, addListItem, removeListItem } = require('../util/list');
+const { modelFor } = require('../model/core');
+const { viewFor } = require('../view/core');
+const { getTabs, getSelectedTab } = require('./utils');
+const { getMostRecentBrowserWindow, isBrowser } = require('../window/utils');
+const { Options } = require('./common');
+const { isPrivate } = require('../private-browsing');
+const { ignoreWindow, isWindowPBSupported } = require('../private-browsing/utils')
+const { isPrivateBrowsingSupported } = require('sdk/self');
+
+const supportPrivateTabs = isPrivateBrowsingSupported && isWindowPBSupported;
+
+const Tabs = Class({
+ implements: [EventTarget],
+ extends: List,
+ initialize: function() {
+ List.prototype.initialize.call(this);
+
+ // We must do the list manipulation here where the object is extensible
+ this.on("open", tab => {
+ addListItem(this, tab);
+ });
+
+ this.on("close", tab => {
+ removeListItem(this, tab);
+ });
+ },
+
+ get activeTab() {
+ let activeDomWin = getMostRecentBrowserWindow();
+ if (!activeDomWin)
+ return null;
+ return modelFor(getSelectedTab(activeDomWin));
+ },
+
+ open: function(options) {
+ options = Options(options);
+
+ // TODO: Remove the dependency on the windows module: bug 792670
+ let windows = require('../windows').browserWindows;
+ let activeWindow = windows.activeWindow;
+
+ let privateState = supportPrivateTabs && options.isPrivate;
+ // When no isPrivate option was passed use the private state of the active
+ // window
+ if (activeWindow && privateState === undefined)
+ privateState = isPrivate(activeWindow);
+
+ function getWindow(privateState) {
+ for (let window of windows) {
+ if (privateState === isPrivate(window)) {
+ return window;
+ }
+ }
+ return null;
+ }
+
+ function openNewWindowWithTab() {
+ windows.open({
+ url: options.url,
+ isPrivate: privateState,
+ onOpen: function(newWindow) {
+ let tab = newWindow.tabs[0];
+ setListeners(tab, options);
+
+ if (options.isPinned)
+ tab.pin();
+
+ // We don't emit the open event for the first tab in a new window so
+ // do it now the listeners are attached
+ emit(tab, "open", tab);
+ }
+ });
+ }
+
+ if (options.inNewWindow)
+ return openNewWindowWithTab();
+
+ // if the active window is in the state that we need then use it
+ if (activeWindow && (privateState === isPrivate(activeWindow)))
+ return activeWindow.tabs.open(options);
+
+ // find a window in the state that we need
+ let window = getWindow(privateState);
+ if (window)
+ return window.tabs.open(options);
+
+ return openNewWindowWithTab();
+ }
+});
+
+const allTabs = new Tabs();
+// Export a new object with allTabs as the prototype, otherwise allTabs becomes
+// frozen and addListItem and removeListItem don't work correctly.
+module.exports = Object.create(allTabs);
+pipe(tabEvents, module.exports);
+
+function addWindowTab(window, tabElement) {
+ let tab = new Tab(tabElement);
+ if (window)
+ addListItem(window.tabs, tab);
+ addListItem(allTabs, tab);
+ emit(allTabs, "open", tab);
+}
+
+// Find tabs in already open windows
+for (let tabElement of getTabs())
+ addWindowTab(null, tabElement);
+
+// Detect tabs in new windows
+windowObserver.on('open', domWindow => {
+ if (!isBrowser(domWindow) || ignoreWindow(domWindow))
+ return;
+
+ let window = null;
+ try {
+ modelFor(domWindow);
+ }
+ catch (e) { }
+
+ for (let tabElement of getTabs(domWindow)) {
+ addWindowTab(window, tabElement);
+ }
+});
diff --git a/toolkit/jetpack/sdk/tabs/utils.js b/toolkit/jetpack/sdk/tabs/utils.js
new file mode 100644
index 000000000..eae3d41fe
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/utils.js
@@ -0,0 +1,370 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+
+// NOTE: This file should only deal with xul/native tabs
+
+
+const { Ci, Cu } = require('chrome');
+const { defer } = require("../lang/functional");
+const { windows, isBrowser } = require('../window/utils');
+const { isPrivateBrowsingSupported } = require('../self');
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+
+// Bug 834961: ignore private windows when they are not supported
+function getWindows() {
+ return windows(null, { includePrivate: isPrivateBrowsingSupported });
+}
+
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+
+// Define predicate functions that can be used to detech weather
+// we deal with fennec tabs or firefox tabs.
+
+// Predicate to detect whether tab is XUL "Tab" node.
+const isXULTab = tab =>
+ tab instanceof Ci.nsIDOMNode &&
+ tab.nodeName === "tab" &&
+ tab.namespaceURI === XUL_NS;
+exports.isXULTab = isXULTab;
+
+// Predicate to detecet whether given tab is a fettec tab.
+// Unfortunately we have to guess via duck typinng of:
+// http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#2583
+const isFennecTab = tab =>
+ tab &&
+ tab.QueryInterface &&
+ Ci.nsIBrowserTab &&
+ tab.QueryInterface(Ci.nsIBrowserTab) === tab;
+exports.isFennecTab = isFennecTab;
+
+const isTab = x => isXULTab(x) || isFennecTab(x);
+exports.isTab = isTab;
+
+function activateTab(tab, window) {
+ let gBrowser = getTabBrowserForTab(tab);
+
+ // normal case
+ if (gBrowser) {
+ gBrowser.selectedTab = tab;
+ }
+ // fennec ?
+ else if (window && window.BrowserApp) {
+ window.BrowserApp.selectTab(tab);
+ }
+ return null;
+}
+exports.activateTab = activateTab;
+
+function getTabBrowser(window) {
+ // bug 1009938 - may be null in SeaMonkey
+ return window.gBrowser || window.getBrowser();
+}
+exports.getTabBrowser = getTabBrowser;
+
+function getTabContainer(window) {
+ return getTabBrowser(window).tabContainer;
+}
+exports.getTabContainer = getTabContainer;
+
+/**
+ * Returns the tabs for the `window` if given, or the tabs
+ * across all the browser's windows otherwise.
+ *
+ * @param {nsIWindow} [window]
+ * A reference to a window
+ *
+ * @returns {Array} an array of Tab objects
+ */
+function getTabs(window) {
+ if (arguments.length === 0) {
+ return getWindows().
+ filter(isBrowser).
+ reduce((tabs, window) => tabs.concat(getTabs(window)), []);
+ }
+
+ // fennec
+ if (window.BrowserApp)
+ return window.BrowserApp.tabs;
+
+ // firefox - default
+ return Array.filter(getTabContainer(window).children, t => !t.closing);
+}
+exports.getTabs = getTabs;
+
+function getActiveTab(window) {
+ return getSelectedTab(window);
+}
+exports.getActiveTab = getActiveTab;
+
+function getOwnerWindow(tab) {
+ // normal case
+ if (tab.ownerDocument)
+ return tab.ownerDocument.defaultView;
+
+ // try fennec case
+ return getWindowHoldingTab(tab);
+}
+exports.getOwnerWindow = getOwnerWindow;
+
+// fennec
+function getWindowHoldingTab(rawTab) {
+ for (let window of getWindows()) {
+ // this function may be called when not using fennec,
+ // but BrowserApp is only defined on Fennec
+ if (!window.BrowserApp)
+ continue;
+
+ for (let tab of window.BrowserApp.tabs) {
+ if (tab === rawTab)
+ return window;
+ }
+ }
+
+ return null;
+}
+
+function openTab(window, url, options) {
+ options = options || {};
+
+ // fennec?
+ if (window.BrowserApp) {
+ return window.BrowserApp.addTab(url, {
+ selected: options.inBackground ? false : true,
+ pinned: options.isPinned || false,
+ isPrivate: options.isPrivate || false,
+ parentId: window.BrowserApp.selectedTab.id
+ });
+ }
+
+ // firefox
+ let newTab = window.gBrowser.addTab(url);
+ if (!options.inBackground) {
+ activateTab(newTab);
+ }
+ return newTab;
+};
+exports.openTab = openTab;
+
+function isTabOpen(tab) {
+ // try normal case then fennec case
+ return !!((tab.linkedBrowser) || getWindowHoldingTab(tab));
+}
+exports.isTabOpen = isTabOpen;
+
+function closeTab(tab) {
+ let gBrowser = getTabBrowserForTab(tab);
+ // normal case?
+ if (gBrowser) {
+ // Bug 699450: the tab may already have been detached
+ if (!tab.parentNode)
+ return;
+ return gBrowser.removeTab(tab);
+ }
+
+ let window = getWindowHoldingTab(tab);
+ // fennec?
+ if (window && window.BrowserApp) {
+ // Bug 699450: the tab may already have been detached
+ if (!tab.browser)
+ return;
+ return window.BrowserApp.closeTab(tab);
+ }
+ return null;
+}
+exports.closeTab = closeTab;
+
+function getURI(tab) {
+ if (tab.browser) // fennec
+ return tab.browser.currentURI.spec;
+ return tab.linkedBrowser.currentURI.spec;
+}
+exports.getURI = getURI;
+
+function getTabBrowserForTab(tab) {
+ let outerWin = getOwnerWindow(tab);
+ if (outerWin)
+ return getOwnerWindow(tab).gBrowser;
+ return null;
+}
+exports.getTabBrowserForTab = getTabBrowserForTab;
+
+function getBrowserForTab(tab) {
+ if (tab.browser) // fennec
+ return tab.browser;
+
+ return tab.linkedBrowser;
+}
+exports.getBrowserForTab = getBrowserForTab;
+
+function getTabId(tab) {
+ if (tab.browser) // fennec
+ return tab.id
+
+ return String.split(tab.linkedPanel, 'panel').pop();
+}
+exports.getTabId = getTabId;
+
+function getTabForId(id) {
+ return getTabs().find(tab => getTabId(tab) === id) || null;
+}
+exports.getTabForId = getTabForId;
+
+function getTabTitle(tab) {
+ return getBrowserForTab(tab).contentTitle || tab.label || "";
+}
+exports.getTabTitle = getTabTitle;
+
+function setTabTitle(tab, title) {
+ title = String(title);
+ if (tab.browser) {
+ // Fennec
+ tab.browser.contentDocument.title = title;
+ }
+ else {
+ let browser = getBrowserForTab(tab);
+ // Note that we aren't actually setting the document title in e10s, just
+ // the title the browser thinks the content has
+ if (browser.isRemoteBrowser)
+ browser._contentTitle = title;
+ else
+ browser.contentDocument.title = title;
+ }
+ tab.label = String(title);
+}
+exports.setTabTitle = setTabTitle;
+
+function getTabContentDocument(tab) {
+ return getBrowserForTab(tab).contentDocument;
+}
+exports.getTabContentDocument = getTabContentDocument;
+
+function getTabContentWindow(tab) {
+ return getBrowserForTab(tab).contentWindow;
+}
+exports.getTabContentWindow = getTabContentWindow;
+
+/**
+ * Returns all tabs' content windows across all the browsers' windows
+ */
+function getAllTabContentWindows() {
+ return getTabs().map(getTabContentWindow);
+}
+exports.getAllTabContentWindows = getAllTabContentWindows;
+
+// gets the tab containing the provided window
+function getTabForContentWindow(window) {
+ return getTabs().find(tab => getTabContentWindow(tab) === window.top) || null;
+}
+exports.getTabForContentWindow = getTabForContentWindow;
+
+// only sdk/selection.js is relying on shims
+function getTabForContentWindowNoShim(window) {
+ function getTabContentWindowNoShim(tab) {
+ let browser = getBrowserForTab(tab);
+ return ShimWaiver.getProperty(browser, "contentWindow");
+ }
+ return getTabs().find(tab => getTabContentWindowNoShim(tab) === window.top) || null;
+}
+exports.getTabForContentWindowNoShim = getTabForContentWindowNoShim;
+
+function getTabURL(tab) {
+ return String(getBrowserForTab(tab).currentURI.spec);
+}
+exports.getTabURL = getTabURL;
+
+function setTabURL(tab, url) {
+ let browser = getBrowserForTab(tab);
+ browser.loadURI(String(url));
+}
+// "TabOpen" event is fired when it's still "about:blank" is loaded in the
+// changing `location` property of the `contentDocument` has no effect since
+// seems to be either ignored or overridden by internal listener, there for
+// location change is enqueued for the next turn of event loop.
+exports.setTabURL = defer(setTabURL);
+
+function getTabContentType(tab) {
+ return getBrowserForTab(tab).contentDocument.contentType;
+}
+exports.getTabContentType = getTabContentType;
+
+function getSelectedTab(window) {
+ if (window.BrowserApp) // fennec?
+ return window.BrowserApp.selectedTab;
+ if (window.gBrowser)
+ return window.gBrowser.selectedTab;
+ return null;
+}
+exports.getSelectedTab = getSelectedTab;
+
+
+function getTabForBrowser(browser) {
+ for (let window of getWindows()) {
+ // this function may be called when not using fennec
+ if (!window.BrowserApp)
+ continue;
+
+ for (let tab of window.BrowserApp.tabs) {
+ if (tab.browser === browser)
+ return tab;
+ }
+ }
+
+ let tabbrowser = browser.getTabBrowser && browser.getTabBrowser()
+ return !!tabbrowser && tabbrowser.getTabForBrowser(browser);
+}
+exports.getTabForBrowser = getTabForBrowser;
+
+function pin(tab) {
+ let gBrowser = getTabBrowserForTab(tab);
+ // TODO: Implement Fennec support
+ if (gBrowser) gBrowser.pinTab(tab);
+}
+exports.pin = pin;
+
+function unpin(tab) {
+ let gBrowser = getTabBrowserForTab(tab);
+ // TODO: Implement Fennec support
+ if (gBrowser) gBrowser.unpinTab(tab);
+}
+exports.unpin = unpin;
+
+function isPinned(tab) {
+ return !!tab.pinned;
+}
+exports.isPinned = isPinned;
+
+function reload(tab) {
+ getBrowserForTab(tab).reload();
+}
+exports.reload = reload
+
+function getIndex(tab) {
+ let gBrowser = getTabBrowserForTab(tab);
+ // Firefox
+ if (gBrowser) {
+ return tab._tPos;
+ }
+ // Fennec
+ else {
+ let window = getWindowHoldingTab(tab)
+ let tabs = window.BrowserApp.tabs;
+ for (let i = tabs.length; i >= 0; i--)
+ if (tabs[i] === tab) return i;
+ }
+}
+exports.getIndex = getIndex;
+
+function move(tab, index) {
+ let gBrowser = getTabBrowserForTab(tab);
+ // Firefox
+ if (gBrowser) gBrowser.moveTabTo(tab, index);
+ // TODO: Implement fennec support
+}
+exports.move = move;
diff --git a/toolkit/jetpack/sdk/tabs/worker.js b/toolkit/jetpack/sdk/tabs/worker.js
new file mode 100644
index 000000000..d2ba33696
--- /dev/null
+++ b/toolkit/jetpack/sdk/tabs/worker.js
@@ -0,0 +1,17 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const ContentWorker = require('../content/worker').Worker;
+
+function Worker(options, window) {
+ options.window = window;
+
+ let worker = ContentWorker(options);
+ worker.once("detach", function detach() {
+ worker.destroy();
+ });
+ return worker;
+}
+exports.Worker = Worker; \ No newline at end of file
diff --git a/toolkit/jetpack/sdk/test.js b/toolkit/jetpack/sdk/test.js
new file mode 100644
index 000000000..e7e3df840
--- /dev/null
+++ b/toolkit/jetpack/sdk/test.js
@@ -0,0 +1,114 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cu } = require("chrome");
+const { Task } = require("resource://gre/modules/Task.jsm", {});
+const { defer } = require("sdk/core/promise");
+const BaseAssert = require("sdk/test/assert").Assert;
+const { isFunction, isObject, isGenerator } = require("sdk/lang/type");
+const { extend } = require("sdk/util/object");
+
+exports.Assert = BaseAssert;
+
+/**
+ * Function takes test `suite` object in CommonJS format and defines all of the
+ * tests from that suite and nested suites in a jetpack format on a given
+ * `target` object. Optionally third argument `prefix` can be passed to prefix
+ * all the test names.
+ */
+function defineTestSuite(target, suite, prefix) {
+ prefix = prefix || "";
+ // If suite defines `Assert` that's what `assert` object have to be created
+ // from and passed to a test function (This allows custom assertion functions)
+ // See for details: http://wiki.commonjs.org/wiki/Unit_Testing/1.1
+ let Assert = suite.Assert || BaseAssert;
+ // Going through each item in the test suite and wrapping it into a
+ // Jetpack test format.
+ Object.keys(suite).forEach(function(key) {
+ // If name starts with test then it's a test function or suite.
+ if (key.indexOf("test") === 0) {
+ let test = suite[key];
+
+ // For each test function so we create a wrapper test function in a
+ // jetpack format and copy that to a `target` exports.
+ if (isFunction(test)) {
+
+ // Since names of the test may match across suites we use full object
+ // path as a name to avoid overriding same function.
+ target[prefix + key] = function(options) {
+
+ // Creating `assert` functions for this test.
+ let assert = Assert(options);
+ assert.end = () => options.done();
+
+ // If test function is a generator use a task JS to allow yield-ing
+ // style test runs.
+ if (isGenerator(test)) {
+ options.waitUntilDone();
+ Task.spawn(test.bind(null, assert)).
+ catch(assert.fail).
+ then(assert.end);
+ }
+
+ // If CommonJS test function expects more than one argument
+ // it means that test is async and second argument is a callback
+ // to notify that test is finished.
+ else if (1 < test.length) {
+ // Letting test runner know that test is executed async and
+ // creating a callback function that CommonJS tests will call
+ // once it's done.
+ options.waitUntilDone();
+ test(assert, function() {
+ options.done();
+ });
+ }
+
+ // Otherwise CommonJS test is synchronous so we call it only with
+ // one argument.
+ else {
+ test(assert);
+ }
+ }
+ }
+
+ // If it's an object then it's a test suite containing test function
+ // and / or nested test suites. In that case we just extend prefix used
+ // and call this function to copy and wrap tests from nested suite.
+ else if (isObject(test)) {
+ // We need to clone `tests` instead of modifying it, since it's very
+ // likely that it is frozen (usually test suites imported modules).
+ test = extend(Object.prototype, test, {
+ Assert: test.Assert || Assert
+ });
+ defineTestSuite(target, test, prefix + key + ".");
+ }
+ }
+ });
+}
+
+/**
+ * This function is a CommonJS test runner function, but since Jetpack test
+ * runner and test format is different from CommonJS this function shims given
+ * `exports` with all its tests into a Jetpack test format so that the built-in
+ * test runner will be able to run CommonJS test without manual changes.
+ */
+exports.run = function run(exports) {
+ // We can't leave old properties on exports since those are test in a CommonJS
+ // format that why we move everything to a new `suite` object.
+ let suite = {};
+ Object.keys(exports).forEach(function(key) {
+ suite[key] = exports[key];
+ delete exports[key];
+ });
+
+ // Now we wrap all the CommonJS tests to a Jetpack format and define
+ // those to a given `exports` object since that where jetpack test runner
+ // will look for them.
+ defineTestSuite(exports, suite);
+};
diff --git a/toolkit/jetpack/sdk/test/assert.js b/toolkit/jetpack/sdk/test/assert.js
new file mode 100644
index 000000000..8478c8414
--- /dev/null
+++ b/toolkit/jetpack/sdk/test/assert.js
@@ -0,0 +1,366 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { isFunction, isNull, isObject, isString,
+ isRegExp, isArray, isDate, isPrimitive,
+ isUndefined, instanceOf, source } = require("../lang/type");
+
+/**
+ * The `AssertionError` is defined in assert.
+ * @extends Error
+ * @example
+ * new assert.AssertionError({
+ * message: message,
+ * actual: actual,
+ * expected: expected
+ * })
+ */
+function AssertionError(options) {
+ let assertionError = Object.create(AssertionError.prototype);
+
+ if (isString(options))
+ options = { message: options };
+ if ("actual" in options)
+ assertionError.actual = options.actual;
+ if ("expected" in options)
+ assertionError.expected = options.expected;
+ if ("operator" in options)
+ assertionError.operator = options.operator;
+
+ assertionError.message = options.message;
+ assertionError.stack = new Error().stack;
+ return assertionError;
+}
+AssertionError.prototype = Object.create(Error.prototype, {
+ constructor: { value: AssertionError },
+ name: { value: "AssertionError", enumerable: true },
+ toString: { value: function toString() {
+ let value;
+ if (this.message) {
+ value = this.name + " : " + this.message;
+ }
+ else {
+ value = [
+ this.name + " : ",
+ source(this.expected),
+ this.operator,
+ source(this.actual)
+ ].join(" ");
+ }
+ return value;
+ }}
+});
+exports.AssertionError = AssertionError;
+
+function Assert(logger) {
+ let assert = Object.create(Assert.prototype, { _log: { value: logger }});
+
+ assert.fail = assert.fail.bind(assert);
+ assert.pass = assert.pass.bind(assert);
+
+ return assert;
+}
+
+Assert.prototype = {
+ fail: function fail(e) {
+ if (!e || typeof(e) !== 'object') {
+ this._log.fail(e);
+ return;
+ }
+ let message = e.message;
+ try {
+ if ('operator' in e) {
+ message += [
+ " -",
+ source(e.actual),
+ e.operator,
+ source(e.expected)
+ ].join(" ");
+ }
+ }
+ catch(e) {}
+ this._log.fail(message);
+ },
+ pass: function pass(message) {
+ this._log.pass(message);
+ return true;
+ },
+ error: function error(e) {
+ this._log.exception(e);
+ },
+ ok: function ok(value, message) {
+ if (!!!value) {
+ this.fail({
+ actual: value,
+ expected: true,
+ message: message,
+ operator: "=="
+ });
+ return false;
+ }
+
+ this.pass(message);
+ return true;
+ },
+
+ /**
+ * The equality assertion tests shallow, coercive equality with `==`.
+ * @example
+ * assert.equal(1, 1, "one is one");
+ */
+ equal: function equal(actual, expected, message) {
+ if (actual == expected) {
+ this.pass(message);
+ return true;
+ }
+
+ this.fail({
+ actual: actual,
+ expected: expected,
+ message: message,
+ operator: "=="
+ });
+ return false;
+ },
+
+ /**
+ * The non-equality assertion tests for whether two objects are not equal
+ * with `!=`.
+ * @example
+ * assert.notEqual(1, 2, "one is not two");
+ */
+ notEqual: function notEqual(actual, expected, message) {
+ if (actual != expected) {
+ this.pass(message);
+ return true;
+ }
+
+ this.fail({
+ actual: actual,
+ expected: expected,
+ message: message,
+ operator: "!=",
+ });
+ return false;
+ },
+
+ /**
+ * The equivalence assertion tests a deep (with `===`) equality relation.
+ * @example
+ * assert.deepEqual({ a: "foo" }, { a: "foo" }, "equivalent objects")
+ */
+ deepEqual: function deepEqual(actual, expected, message) {
+ if (isDeepEqual(actual, expected)) {
+ this.pass(message);
+ return true;
+ }
+
+ this.fail({
+ actual: actual,
+ expected: expected,
+ message: message,
+ operator: "deepEqual"
+ });
+ return false;
+ },
+
+ /**
+ * The non-equivalence assertion tests for any deep (with `===`) inequality.
+ * @example
+ * assert.notDeepEqual({ a: "foo" }, Object.create({ a: "foo" }),
+ * "object's inherit from different prototypes");
+ */
+ notDeepEqual: function notDeepEqual(actual, expected, message) {
+ if (!isDeepEqual(actual, expected)) {
+ this.pass(message);
+ return true;
+ }
+
+ this.fail({
+ actual: actual,
+ expected: expected,
+ message: message,
+ operator: "notDeepEqual"
+ });
+ return false;
+ },
+
+ /**
+ * The strict equality assertion tests strict equality, as determined by
+ * `===`.
+ * @example
+ * assert.strictEqual(null, null, "`null` is `null`")
+ */
+ strictEqual: function strictEqual(actual, expected, message) {
+ if (actual === expected) {
+ this.pass(message);
+ return true;
+ }
+
+ this.fail({
+ actual: actual,
+ expected: expected,
+ message: message,
+ operator: "==="
+ });
+ return false;
+ },
+
+ /**
+ * The strict non-equality assertion tests for strict inequality, as
+ * determined by `!==`.
+ * @example
+ * assert.notStrictEqual(null, undefined, "`null` is not `undefined`");
+ */
+ notStrictEqual: function notStrictEqual(actual, expected, message) {
+ if (actual !== expected) {
+ this.pass(message);
+ return true;
+ }
+
+ this.fail({
+ actual: actual,
+ expected: expected,
+ message: message,
+ operator: "!=="
+ });
+ return false;
+ },
+
+ /**
+ * The assertion whether or not given `block` throws an exception. If optional
+ * `Error` argument is provided and it's type of function thrown error is
+ * asserted to be an instance of it, if type of `Error` is string then message
+ * of throw exception is asserted to contain it.
+ * @param {Function} block
+ * Function that is expected to throw.
+ * @param {Error|RegExp} [Error]
+ * Error constructor that is expected to be thrown or a string that
+ * must be contained by a message of the thrown exception, or a RegExp
+ * matching a message of the thrown exception.
+ * @param {String} message
+ * Description message
+ *
+ * @examples
+ *
+ * assert.throws(function block() {
+ * doSomething(4)
+ * }, "Object is expected", "Incorrect argument is passed");
+ *
+ * assert.throws(function block() {
+ * Object.create(5)
+ * }, TypeError, "TypeError is thrown");
+ */
+ throws: function throws(block, Error, message) {
+ let threw = false;
+ let exception = null;
+
+ // If third argument is not provided and second argument is a string it
+ // means that optional `Error` argument was not passed, so we shift
+ // arguments.
+ if (isString(Error) && isUndefined(message)) {
+ message = Error;
+ Error = undefined;
+ }
+
+ // Executing given `block`.
+ try {
+ block();
+ }
+ catch (e) {
+ threw = true;
+ exception = e;
+ }
+
+ // If exception was thrown and `Error` argument was not passed assert is
+ // passed.
+ if (threw && (isUndefined(Error) ||
+ // If passed `Error` is RegExp using it's test method to
+ // assert thrown exception message.
+ (isRegExp(Error) && (Error.test(exception.message) || Error.test(exception.toString()))) ||
+ // If passed `Error` is a constructor function testing if
+ // thrown exception is an instance of it.
+ (isFunction(Error) && instanceOf(exception, Error))))
+ {
+ this.pass(message);
+ return true;
+ }
+
+ // Otherwise we report assertion failure.
+ let failure = {
+ message: message,
+ operator: "matches"
+ };
+
+ if (exception) {
+ failure.actual = exception.message || exception.toString();
+ }
+
+ if (Error) {
+ failure.expected = Error.toString();
+ }
+
+ this.fail(failure);
+ return false;
+ }
+};
+exports.Assert = Assert;
+
+function isDeepEqual(actual, expected) {
+ // 7.1. All identical values are equivalent, as determined by ===.
+ if (actual === expected) {
+ return true;
+ }
+
+ // 7.2. If the expected value is a Date object, the actual value is
+ // equivalent if it is also a Date object that refers to the same time.
+ else if (isDate(actual) && isDate(expected)) {
+ return actual.getTime() === expected.getTime();
+ }
+
+ // XXX specification bug: this should be specified
+ else if (isPrimitive(actual) || isPrimitive(expected)) {
+ return expected === actual;
+ }
+
+ // 7.3. Other pairs that do not both pass typeof value == "object",
+ // equivalence is determined by ==.
+ else if (!isObject(actual) && !isObject(expected)) {
+ return actual == expected;
+ }
+
+ // 7.4. For all other Object pairs, including Array objects, equivalence is
+ // determined by having the same number of owned properties (as verified
+ // with Object.prototype.hasOwnProperty.call), the same set of keys
+ // (although not necessarily the same order), equivalent values for every
+ // corresponding key, and an identical "prototype" property. Note: this
+ // accounts for both named and indexed properties on Arrays.
+ else {
+ return actual.prototype === expected.prototype &&
+ isEquivalent(actual, expected);
+ }
+}
+
+function isEquivalent(a, b, stack) {
+ let aKeys = Object.keys(a);
+ let bKeys = Object.keys(b);
+
+ return aKeys.length === bKeys.length &&
+ isArrayEquivalent(aKeys.sort(), bKeys.sort()) &&
+ aKeys.every(function(key) {
+ return isDeepEqual(a[key], b[key], stack)
+ });
+}
+
+function isArrayEquivalent(a, b, stack) {
+ return isArray(a) && isArray(b) &&
+ a.every(function(value, index) {
+ return isDeepEqual(value, b[index]);
+ });
+}
diff --git a/toolkit/jetpack/sdk/test/harness.js b/toolkit/jetpack/sdk/test/harness.js
new file mode 100644
index 000000000..1b31a1c79
--- /dev/null
+++ b/toolkit/jetpack/sdk/test/harness.js
@@ -0,0 +1,645 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci, Cu } = require("chrome");
+const { Loader } = require('./loader');
+const { serializeStack, parseStack } = require("toolkit/loader");
+const { setTimeout } = require('../timers');
+const { PlainTextConsole } = require("../console/plain-text");
+const { when: unload } = require("../system/unload");
+const { format, fromException } = require("../console/traceback");
+const system = require("../system");
+const { gc: gcPromise } = require('./memory');
+const { defer } = require('../core/promise');
+const { extend } = require('../core/heritage');
+
+// Trick manifest builder to make it think we need these modules ?
+const unit = require("../deprecated/unit-test");
+const test = require("../../test");
+const url = require("../url");
+
+function emptyPromise() {
+ let { promise, resolve } = defer();
+ resolve();
+ return promise;
+}
+
+var cService = Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService);
+
+// The console used to log messages
+var testConsole;
+
+// Cuddlefish loader in which we load and execute tests.
+var loader;
+
+// Function to call when we're done running tests.
+var onDone;
+
+// Function to print text to a console, w/o CR at the end.
+var print;
+
+// How many more times to run all tests.
+var iterationsLeft;
+
+// Whether to report memory profiling information.
+var profileMemory;
+
+// Whether we should stop as soon as a test reports a failure.
+var stopOnError;
+
+// Function to call to retrieve a list of tests to execute
+var findAndRunTests;
+
+// Combined information from all test runs.
+var results;
+
+// A list of the compartments and windows loaded after startup
+var startLeaks;
+
+// JSON serialization of last memory usage stats; we keep it stringified
+// so we don't actually change the memory usage stats (in terms of objects)
+// of the JSRuntime we're profiling.
+var lastMemoryUsage;
+
+function analyzeRawProfilingData(data) {
+ var graph = data.graph;
+ var shapes = {};
+
+ // Convert keys in the graph from strings to ints.
+ // TODO: Can we get rid of this ridiculousness?
+ var newGraph = {};
+ for (id in graph) {
+ newGraph[parseInt(id)] = graph[id];
+ }
+ graph = newGraph;
+
+ var modules = 0;
+ var moduleIds = [];
+ var moduleObjs = {UNKNOWN: 0};
+ for (let name in data.namedObjects) {
+ moduleObjs[name] = 0;
+ moduleIds[data.namedObjects[name]] = name;
+ modules++;
+ }
+
+ var count = 0;
+ for (id in graph) {
+ var parent = graph[id].parent;
+ while (parent) {
+ if (parent in moduleIds) {
+ var name = moduleIds[parent];
+ moduleObjs[name]++;
+ break;
+ }
+ if (!(parent in graph)) {
+ moduleObjs.UNKNOWN++;
+ break;
+ }
+ parent = graph[parent].parent;
+ }
+ count++;
+ }
+
+ print("\nobject count is " + count + " in " + modules + " modules" +
+ " (" + data.totalObjectCount + " across entire JS runtime)\n");
+ if (lastMemoryUsage) {
+ var last = JSON.parse(lastMemoryUsage);
+ var diff = {
+ moduleObjs: dictDiff(last.moduleObjs, moduleObjs),
+ totalObjectClasses: dictDiff(last.totalObjectClasses,
+ data.totalObjectClasses)
+ };
+
+ for (let name in diff.moduleObjs)
+ print(" " + diff.moduleObjs[name] + " in " + name + "\n");
+ for (let name in diff.totalObjectClasses)
+ print(" " + diff.totalObjectClasses[name] + " instances of " +
+ name + "\n");
+ }
+ lastMemoryUsage = JSON.stringify(
+ {moduleObjs: moduleObjs,
+ totalObjectClasses: data.totalObjectClasses}
+ );
+}
+
+function dictDiff(last, curr) {
+ var diff = {};
+
+ for (let name in last) {
+ var result = (curr[name] || 0) - last[name];
+ if (result)
+ diff[name] = (result > 0 ? "+" : "") + result;
+ }
+ for (let name in curr) {
+ var result = curr[name] - (last[name] || 0);
+ if (result)
+ diff[name] = (result > 0 ? "+" : "") + result;
+ }
+ return diff;
+}
+
+function reportMemoryUsage() {
+ if (!profileMemory) {
+ return emptyPromise();
+ }
+
+ return gcPromise().then((() => {
+ var mgr = Cc["@mozilla.org/memory-reporter-manager;1"]
+ .getService(Ci.nsIMemoryReporterManager);
+ let count = 0;
+ function logReporter(process, path, kind, units, amount, description) {
+ print(((++count == 1) ? "\n" : "") + description + ": " + amount + "\n");
+ }
+ mgr.getReportsForThisProcess(logReporter, null, /* anonymize = */ false);
+ }));
+}
+
+var gWeakrefInfo;
+
+function checkMemory() {
+ return gcPromise().then(_ => {
+ let leaks = getPotentialLeaks();
+
+ let compartmentURLs = Object.keys(leaks.compartments).filter(function(url) {
+ return !(url in startLeaks.compartments);
+ });
+
+ let windowURLs = Object.keys(leaks.windows).filter(function(url) {
+ return !(url in startLeaks.windows);
+ });
+
+ for (let url of compartmentURLs)
+ console.warn("LEAKED", leaks.compartments[url]);
+
+ for (let url of windowURLs)
+ console.warn("LEAKED", leaks.windows[url]);
+ }).then(showResults);
+}
+
+function showResults() {
+ let { promise, resolve } = defer();
+
+ if (gWeakrefInfo) {
+ gWeakrefInfo.forEach(
+ function(info) {
+ var ref = info.weakref.get();
+ if (ref !== null) {
+ var data = ref.__url__ ? ref.__url__ : ref;
+ var warning = data == "[object Object]"
+ ? "[object " + data.constructor.name + "(" +
+ Object.keys(data).join(", ") + ")]"
+ : data;
+ console.warn("LEAK", warning, info.bin);
+ }
+ }
+ );
+ }
+
+ onDone(results);
+
+ resolve();
+ return promise;
+}
+
+function cleanup() {
+ let coverObject = {};
+ try {
+ loader.unload();
+
+ if (loader.globals.console.errorsLogged && !results.failed) {
+ results.failed++;
+ console.error("warnings and/or errors were logged.");
+ }
+
+ if (consoleListener.errorsLogged && !results.failed) {
+ console.warn(consoleListener.errorsLogged + " " +
+ "warnings or errors were logged to the " +
+ "platform's nsIConsoleService, which could " +
+ "be of no consequence; however, they could also " +
+ "be indicative of aberrant behavior.");
+ }
+
+ // read the code coverage object, if it exists, from CoverJS-moz
+ if (typeof loader.globals.global == "object") {
+ coverObject = loader.globals.global['__$coverObject'] || {};
+ }
+
+ consoleListener.errorsLogged = 0;
+ loader = null;
+
+ consoleListener.unregister();
+
+ Cu.forceGC();
+ }
+ catch (e) {
+ results.failed++;
+ console.error("unload.send() threw an exception.");
+ console.exception(e);
+ };
+
+ setTimeout(require("./options").checkMemory ? checkMemory : showResults, 1);
+
+ // dump the coverobject
+ if (Object.keys(coverObject).length){
+ const self = require('sdk/self');
+ const {pathFor} = require("sdk/system");
+ let file = require('sdk/io/file');
+ const {env} = require('sdk/system/environment');
+ console.log("CWD:", env.PWD);
+ let out = file.join(env.PWD,'coverstats-'+self.id+'.json');
+ console.log('coverstats:', out);
+ let outfh = file.open(out,'w');
+ outfh.write(JSON.stringify(coverObject,null,2));
+ outfh.flush();
+ outfh.close();
+ }
+}
+
+function getPotentialLeaks() {
+ Cu.forceGC();
+
+ // Things we can assume are part of the platform and so aren't leaks
+ let GOOD_BASE_URLS = [
+ "chrome://",
+ "resource:///",
+ "resource://app/",
+ "resource://gre/",
+ "resource://gre-resources/",
+ "resource://pdf.js/",
+ "resource://pdf.js.components/",
+ "resource://services-common/",
+ "resource://services-crypto/",
+ "resource://services-sync/"
+ ];
+
+ let ioService = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+ let uri = ioService.newURI("chrome://global/content/", "UTF-8", null);
+ let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].
+ getService(Ci.nsIChromeRegistry);
+ uri = chromeReg.convertChromeURL(uri);
+ let spec = uri.spec;
+ let pos = spec.indexOf("!/");
+ GOOD_BASE_URLS.push(spec.substring(0, pos + 2));
+
+ let zoneRegExp = new RegExp("^explicit/js-non-window/zones/zone[^/]+/compartment\\((.+)\\)");
+ let compartmentRegexp = new RegExp("^explicit/js-non-window/compartments/non-window-global/compartment\\((.+)\\)/");
+ let compartmentDetails = new RegExp("^([^,]+)(?:, (.+?))?(?: \\(from: (.*)\\))?$");
+ let windowRegexp = new RegExp("^explicit/window-objects/top\\((.*)\\)/active");
+ let windowDetails = new RegExp("^(.*), id=.*$");
+
+ function isPossibleLeak(item) {
+ if (!item.location)
+ return false;
+
+ for (let url of GOOD_BASE_URLS) {
+ if (item.location.substring(0, url.length) == url) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ let compartments = {};
+ let windows = {};
+ function logReporter(process, path, kind, units, amount, description) {
+ let matches;
+
+ if ((matches = compartmentRegexp.exec(path)) || (matches = zoneRegExp.exec(path))) {
+ if (matches[1] in compartments)
+ return;
+
+ let details = compartmentDetails.exec(matches[1]);
+ if (!details) {
+ console.error("Unable to parse compartment detail " + matches[1]);
+ return;
+ }
+
+ let item = {
+ path: matches[1],
+ principal: details[1],
+ location: details[2] ? details[2].replace(/\\/g, "/") : undefined,
+ source: details[3] ? details[3].split(" -> ").reverse() : undefined,
+ toString: function() {
+ return this.location;
+ }
+ };
+
+ if (!isPossibleLeak(item))
+ return;
+
+ compartments[matches[1]] = item;
+ return;
+ }
+
+ if ((matches = windowRegexp.exec(path))) {
+ if (matches[1] in windows)
+ return;
+
+ let details = windowDetails.exec(matches[1]);
+ if (!details) {
+ console.error("Unable to parse window detail " + matches[1]);
+ return;
+ }
+
+ let item = {
+ path: matches[1],
+ location: details[1].replace(/\\/g, "/"),
+ source: [details[1].replace(/\\/g, "/")],
+ toString: function() {
+ return this.location;
+ }
+ };
+
+ if (!isPossibleLeak(item))
+ return;
+
+ windows[matches[1]] = item;
+ }
+ }
+
+ Cc["@mozilla.org/memory-reporter-manager;1"]
+ .getService(Ci.nsIMemoryReporterManager)
+ .getReportsForThisProcess(logReporter, null, /* anonymize = */ false);
+
+ return { compartments: compartments, windows: windows };
+}
+
+function nextIteration(tests) {
+ if (tests) {
+ results.passed += tests.passed;
+ results.failed += tests.failed;
+
+ reportMemoryUsage().then(_ => {
+ let testRun = [];
+ for (let test of tests.testRunSummary) {
+ let testCopy = {};
+ for (let info in test) {
+ testCopy[info] = test[info];
+ }
+ testRun.push(testCopy);
+ }
+
+ results.testRuns.push(testRun);
+ iterationsLeft--;
+
+ checkForEnd();
+ })
+ }
+ else {
+ checkForEnd();
+ }
+}
+
+function checkForEnd() {
+ if (iterationsLeft && (!stopOnError || results.failed == 0)) {
+ // Pass the loader which has a hooked console that doesn't dispatch
+ // errors to the JS console and avoid firing false alarm in our
+ // console listener
+ findAndRunTests(loader, nextIteration);
+ }
+ else {
+ setTimeout(cleanup, 0);
+ }
+}
+
+var POINTLESS_ERRORS = [
+ 'Invalid chrome URI:',
+ 'OpenGL LayerManager Initialized Succesfully.',
+ '[JavaScript Error: "TelemetryStopwatch:',
+ 'reference to undefined property',
+ '[JavaScript Error: "The character encoding of the HTML document was ' +
+ 'not declared.',
+ '[Javascript Warning: "Error: Failed to preserve wrapper of wrapped ' +
+ 'native weak map key',
+ '[JavaScript Warning: "Duplicate resource declaration for',
+ 'file: "chrome://browser/content/',
+ 'file: "chrome://global/content/',
+ '[JavaScript Warning: "The character encoding of a framed document was ' +
+ 'not declared.',
+ 'file: "chrome://browser/skin/'
+];
+
+// These are messages that will cause a test to fail if logged through the
+// console service
+var IMPORTANT_ERRORS = [
+ 'Sending message that cannot be cloned. Are you trying to send an XPCOM object?',
+];
+
+var consoleListener = {
+ registered: false,
+
+ register: function() {
+ if (this.registered)
+ return;
+ cService.registerListener(this);
+ this.registered = true;
+ },
+
+ unregister: function() {
+ if (!this.registered)
+ return;
+ cService.unregisterListener(this);
+ this.registered = false;
+ },
+
+ errorsLogged: 0,
+
+ observe: function(object) {
+ if (!(object instanceof Ci.nsIScriptError))
+ return;
+ this.errorsLogged++;
+ var message = object.QueryInterface(Ci.nsIConsoleMessage).message;
+ if (IMPORTANT_ERRORS.find(msg => message.indexOf(msg) >= 0)) {
+ testConsole.error(message);
+ return;
+ }
+ var pointless = POINTLESS_ERRORS.filter(err => message.indexOf(err) >= 0);
+ if (pointless.length == 0 && message)
+ testConsole.log(message);
+ }
+};
+
+function TestRunnerConsole(base, options) {
+ let proto = extend(base, {
+ errorsLogged: 0,
+ warn: function warn() {
+ this.errorsLogged++;
+ base.warn.apply(base, arguments);
+ },
+ error: function error() {
+ this.errorsLogged++;
+ base.error.apply(base, arguments);
+ },
+ info: function info(first) {
+ if (options.verbose)
+ base.info.apply(base, arguments);
+ else
+ if (first == "pass:")
+ print(".");
+ },
+ });
+ return Object.create(proto);
+}
+
+function stringify(arg) {
+ try {
+ return String(arg);
+ }
+ catch(ex) {
+ return "<toString() error>";
+ }
+}
+
+function stringifyArgs(args) {
+ return Array.map(args, stringify).join(" ");
+}
+
+function TestRunnerTinderboxConsole(base, options) {
+ this.base = base;
+ this.print = options.print;
+ this.verbose = options.verbose;
+ this.errorsLogged = 0;
+
+ // Binding all the public methods to an instance so that they can be used
+ // as callback / listener functions straightaway.
+ this.log = this.log.bind(this);
+ this.info = this.info.bind(this);
+ this.warn = this.warn.bind(this);
+ this.error = this.error.bind(this);
+ this.debug = this.debug.bind(this);
+ this.exception = this.exception.bind(this);
+ this.trace = this.trace.bind(this);
+};
+
+TestRunnerTinderboxConsole.prototype = {
+ testMessage: function testMessage(pass, expected, test, message) {
+ let type = "TEST-";
+ if (expected) {
+ if (pass)
+ type += "PASS";
+ else
+ type += "KNOWN-FAIL";
+ }
+ else {
+ this.errorsLogged++;
+ if (pass)
+ type += "UNEXPECTED-PASS";
+ else
+ type += "UNEXPECTED-FAIL";
+ }
+
+ this.print(type + " | " + test + " | " + message + "\n");
+ if (!expected)
+ this.trace();
+ },
+
+ log: function log() {
+ this.print("TEST-INFO | " + stringifyArgs(arguments) + "\n");
+ },
+
+ info: function info(first) {
+ this.print("TEST-INFO | " + stringifyArgs(arguments) + "\n");
+ },
+
+ warn: function warn() {
+ this.errorsLogged++;
+ this.print("TEST-UNEXPECTED-FAIL | " + stringifyArgs(arguments) + "\n");
+ },
+
+ error: function error() {
+ this.errorsLogged++;
+ this.print("TEST-UNEXPECTED-FAIL | " + stringifyArgs(arguments) + "\n");
+ this.base.error.apply(this.base, arguments);
+ },
+
+ debug: function debug() {
+ this.print("TEST-INFO | " + stringifyArgs(arguments) + "\n");
+ },
+
+ exception: function exception(e) {
+ this.print("An exception occurred.\n" +
+ require("../console/traceback").format(e) + "\n" + e + "\n");
+ },
+
+ trace: function trace() {
+ var traceback = require("../console/traceback");
+ var stack = traceback.get();
+ stack.splice(-1, 1);
+ this.print("TEST-INFO | " + stringify(traceback.format(stack)) + "\n");
+ }
+};
+
+var runTests = exports.runTests = function runTests(options) {
+ iterationsLeft = options.iterations;
+ profileMemory = options.profileMemory;
+ stopOnError = options.stopOnError;
+ onDone = options.onDone;
+ print = options.print;
+ findAndRunTests = options.findAndRunTests;
+
+ results = {
+ passed: 0,
+ failed: 0,
+ testRuns: []
+ };
+
+ try {
+ consoleListener.register();
+ print("Running tests on " + system.name + " " + system.version +
+ "/Gecko " + system.platformVersion + " (Build " +
+ system.build + ") (" + system.id + ") under " +
+ system.platform + "/" + system.architecture + ".\n");
+
+ if (options.parseable)
+ testConsole = new TestRunnerTinderboxConsole(new PlainTextConsole(), options);
+ else
+ testConsole = new TestRunnerConsole(new PlainTextConsole(), options);
+
+ loader = Loader(module, {
+ console: testConsole,
+ global: {} // useful for storing things like coverage testing.
+ });
+
+ // Load these before getting initial leak stats as they will still be in
+ // memory when we check later
+ require("../deprecated/unit-test");
+ require("../deprecated/unit-test-finder");
+ if (profileMemory)
+ startLeaks = getPotentialLeaks();
+
+ nextIteration();
+ } catch (e) {
+ let frames = fromException(e).reverse().reduce(function(frames, frame) {
+ if (frame.fileName.split("/").pop() === "unit-test-finder.js")
+ frames.done = true
+ if (!frames.done) frames.push(frame)
+
+ return frames
+ }, [])
+
+ let prototype = typeof(e) === "object" ? e.constructor.prototype :
+ Error.prototype;
+ let stack = serializeStack(frames.reverse());
+
+ let error = Object.create(prototype, {
+ message: { value: e.message, writable: true, configurable: true },
+ fileName: { value: e.fileName, writable: true, configurable: true },
+ lineNumber: { value: e.lineNumber, writable: true, configurable: true },
+ stack: { value: stack, writable: true, configurable: true },
+ toString: { value: () => String(e), writable: true, configurable: true },
+ });
+
+ print("Error: " + error + " \n " + format(error));
+ onDone({passed: 0, failed: 1});
+ }
+};
+
+unload(_ => consoleListener.unregister());
diff --git a/toolkit/jetpack/sdk/test/httpd.js b/toolkit/jetpack/sdk/test/httpd.js
new file mode 100644
index 000000000..218493924
--- /dev/null
+++ b/toolkit/jetpack/sdk/test/httpd.js
@@ -0,0 +1,6 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+throw new Error(`This file was removed. A copy can be obtained from:
+ https://github.com/mozilla/addon-sdk/blob/master/test/lib/httpd.js`);
diff --git a/toolkit/jetpack/sdk/test/loader.js b/toolkit/jetpack/sdk/test/loader.js
new file mode 100644
index 000000000..33ba2ca5a
--- /dev/null
+++ b/toolkit/jetpack/sdk/test/loader.js
@@ -0,0 +1,123 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { resolveURI, Require,
+ unload, override, descriptor } = require('../../toolkit/loader');
+const { ensure } = require('../system/unload');
+const addonWindow = require('../addon/window');
+const { PlainTextConsole } = require('sdk/console/plain-text');
+
+var defaultGlobals = override(require('../system/globals'), {
+ console: console
+});
+
+function CustomLoader(module, globals, packaging, overrides={}) {
+ let options = packaging || require("@loader/options");
+ options = override(options, {
+ id: overrides.id || options.id,
+ globals: override(defaultGlobals, globals || {}),
+ modules: override(override(options.modules || {}, overrides.modules || {}), {
+ 'sdk/addon/window': addonWindow
+ })
+ });
+
+ let loaderModule = options.isNative ? '../../toolkit/loader' : '../loader/cuddlefish';
+ let { Loader } = require(loaderModule);
+ let loader = Loader(options);
+ let wrapper = Object.create(loader, descriptor({
+ require: Require(loader, module),
+ sandbox: function(id) {
+ let requirement = loader.resolve(id, module.id);
+ if (!requirement)
+ requirement = id;
+ let uri = resolveURI(requirement, loader.mapping);
+ return loader.sandboxes[uri];
+ },
+ unload: function(reason) {
+ unload(loader, reason);
+ }
+ }));
+ ensure(wrapper);
+ return wrapper;
+};
+exports.Loader = CustomLoader;
+
+function HookedPlainTextConsole(hook, print, innerID) {
+ this.log = hook.bind(null, "log", innerID);
+ this.info = hook.bind(null, "info", innerID);
+ this.warn = hook.bind(null, "warn", innerID);
+ this.error = hook.bind(null, "error", innerID);
+ this.debug = hook.bind(null, "debug", innerID);
+ this.exception = hook.bind(null, "exception", innerID);
+ this.time = hook.bind(null, "time", innerID);
+ this.timeEnd = hook.bind(null, "timeEnd", innerID);
+
+ this.__exposedProps__ = {
+ log: "rw", info: "rw", warn: "rw", error: "rw", debug: "rw",
+ exception: "rw", time: "rw", timeEnd: "rw"
+ };
+}
+
+// Creates a custom loader instance whose console module is hooked in order
+// to avoid printing messages to the console, and instead, expose them in the
+// returned `messages` array attribute
+exports.LoaderWithHookedConsole = function (module, callback) {
+ let messages = [];
+ function hook(type, innerID, msg) {
+ messages.push({ type: type, msg: msg, innerID: innerID });
+ if (callback)
+ callback(type, msg, innerID);
+ }
+
+ return {
+ loader: CustomLoader(module, {
+ console: new HookedPlainTextConsole(hook, null, null)
+ }, null, {
+ modules: {
+ 'sdk/console/plain-text': {
+ PlainTextConsole: HookedPlainTextConsole.bind(null, hook)
+ }
+ }
+ }),
+ messages: messages
+ };
+}
+
+// Same than LoaderWithHookedConsole with lower level, instead we get what is
+// actually printed to the command line console
+exports.LoaderWithHookedConsole2 = function (module, callback) {
+ let messages = [];
+ return {
+ loader: CustomLoader(module, {
+ console: new PlainTextConsole(function (msg) {
+ messages.push(msg);
+ if (callback)
+ callback(msg);
+ })
+ }),
+ messages: messages
+ };
+}
+
+// Creates a custom loader with a filtered console. The callback is passed every
+// console message type and message and if it returns false the message will
+// not be logged normally
+exports.LoaderWithFilteredConsole = function (module, callback) {
+ function hook(type, innerID, msg) {
+ if (callback && callback(type, msg, innerID) == false)
+ return;
+ console[type](msg);
+ }
+
+ return CustomLoader(module, {
+ console: new HookedPlainTextConsole(hook, null, null)
+ }, null, {
+ modules: {
+ 'sdk/console/plain-text': {
+ PlainTextConsole: HookedPlainTextConsole.bind(null, hook)
+ }
+ }
+ });
+}
diff --git a/toolkit/jetpack/sdk/test/memory.js b/toolkit/jetpack/sdk/test/memory.js
new file mode 100644
index 000000000..bd1198bfe
--- /dev/null
+++ b/toolkit/jetpack/sdk/test/memory.js
@@ -0,0 +1,11 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { Cu } = require("chrome");
+
+function gc() {
+ return new Promise(resolve => Cu.schedulePreciseGC(resolve));
+}
+exports.gc = gc;
diff --git a/toolkit/jetpack/sdk/test/options.js b/toolkit/jetpack/sdk/test/options.js
new file mode 100644
index 000000000..9bc611ca5
--- /dev/null
+++ b/toolkit/jetpack/sdk/test/options.js
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const options = require("@test/options");
+const { id } = require("../self");
+const { get } = require("../preferences/service");
+
+const readPref = (key) => get("extensions." + id + ".sdk." + key);
+
+exports.iterations = readPref("test.iterations") || options.iterations;
+exports.filter = readPref("test.filter") || options.filter;
+exports.profileMemory = readPref("profile.memory") || options.profileMemory;
+exports.stopOnError = readPref("test.stop") || options.stopOnError;
+exports.keepOpen = readPref("test.keepOpen") || false;
+exports.verbose = (readPref("output.logLevel") == "verbose") || options.verbose;
+exports.parseable = (readPref("output.format") == "tbpl") || options.parseable;
+exports.checkMemory = readPref("profile.leaks") || options.check_memory;
diff --git a/toolkit/jetpack/sdk/test/runner.js b/toolkit/jetpack/sdk/test/runner.js
new file mode 100644
index 000000000..ea37ac84f
--- /dev/null
+++ b/toolkit/jetpack/sdk/test/runner.js
@@ -0,0 +1,131 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+var { exit, stdout } = require("../system");
+var cfxArgs = require("../test/options");
+var events = require("../system/events");
+const { resolve } = require("../core/promise");
+
+function runTests(findAndRunTests) {
+ var harness = require("./harness");
+
+ function onDone(tests) {
+ stdout.write("\n");
+ var total = tests.passed + tests.failed;
+ stdout.write(tests.passed + " of " + total + " tests passed.\n");
+
+ events.emit("sdk:test:results", { data: JSON.stringify(tests) });
+
+ if (tests.failed == 0) {
+ if (tests.passed === 0)
+ stdout.write("No tests were run\n");
+ if (!cfxArgs.keepOpen)
+ exit(0);
+ } else {
+ if (cfxArgs.verbose || cfxArgs.parseable)
+ printFailedTests(tests, stdout.write);
+ if (!cfxArgs.keepOpen)
+ exit(1);
+ }
+ };
+
+ // We may have to run test on next cycle, otherwise XPCOM components
+ // are not correctly updated.
+ // For ex: nsIFocusManager.getFocusedElementForWindow may throw
+ // NS_ERROR_ILLEGAL_VALUE exception.
+ require("../timers").setTimeout(_ => harness.runTests({
+ findAndRunTests: findAndRunTests,
+ iterations: cfxArgs.iterations || 1,
+ filter: cfxArgs.filter,
+ profileMemory: cfxArgs.profileMemory,
+ stopOnError: cfxArgs.stopOnError,
+ verbose: cfxArgs.verbose,
+ parseable: cfxArgs.parseable,
+ print: stdout.write,
+ onDone: onDone
+ }));
+}
+
+function printFailedTests(tests, print) {
+ let iterationNumber = 0;
+ let singleIteration = (tests.testRuns || []).length == 1;
+ let padding = singleIteration ? "" : " ";
+
+ print("\nThe following tests failed:\n");
+
+ for (let testRun of tests.testRuns) {
+ iterationNumber++;
+
+ if (!singleIteration)
+ print(" Iteration " + iterationNumber + ":\n");
+
+ for (let test of testRun) {
+ if (test.failed > 0) {
+ print(padding + " " + test.name + ": " + test.errors +"\n");
+ }
+ }
+ print("\n");
+ }
+}
+
+function main() {
+ var testsStarted = false;
+
+ if (!testsStarted) {
+ testsStarted = true;
+ runTests(function findAndRunTests(loader, nextIteration) {
+ loader.require("../deprecated/unit-test").findAndRunTests({
+ testOutOfProcess: false,
+ testInProcess: true,
+ stopOnError: cfxArgs.stopOnError,
+ filter: cfxArgs.filter,
+ onDone: nextIteration
+ });
+ });
+ }
+};
+
+if (require.main === module)
+ main();
+
+exports.runTestsFromModule = function runTestsFromModule(module) {
+ let id = module.id;
+ // Make a copy of exports as it may already be frozen by module loader
+ let exports = {};
+ Object.keys(module.exports).forEach(key => {
+ exports[key] = module.exports[key];
+ });
+
+ runTests(function findAndRunTests(loader, nextIteration) {
+ // Consider that all these tests are CommonJS ones
+ loader.require('../../test').run(exports);
+
+ // Reproduce what is done in sdk/deprecated/unit-test-finder.findTests()
+ let tests = [];
+ for (let name of Object.keys(exports).sort()) {
+ tests.push({
+ setup: exports.setup,
+ teardown: exports.teardown,
+ testFunction: exports[name],
+ name: id + "." + name
+ });
+ }
+
+ // Reproduce what is done by unit-test.findAndRunTests()
+ var { TestRunner } = loader.require("../deprecated/unit-test");
+ var runner = new TestRunner();
+ runner.startMany({
+ tests: {
+ getNext: () => resolve(tests.shift())
+ },
+ stopOnError: cfxArgs.stopOnError,
+ onDone: nextIteration
+ });
+ });
+}
diff --git a/toolkit/jetpack/sdk/test/utils.js b/toolkit/jetpack/sdk/test/utils.js
new file mode 100644
index 000000000..b01df67d4
--- /dev/null
+++ b/toolkit/jetpack/sdk/test/utils.js
@@ -0,0 +1,199 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+const { defer } = require('../core/promise');
+const { setInterval, clearInterval } = require('../timers');
+const { getTabs, closeTab } = require("../tabs/utils");
+const { windows: getWindows } = require("../window/utils");
+const { close: closeWindow } = require("../window/helpers");
+const { isGenerator } = require("../lang/type");
+const { env } = require("../system/environment");
+const { Task } = require("resource://gre/modules/Task.jsm");
+
+const getTestNames = (exports) =>
+ Object.keys(exports).filter(name => /^test/.test(name));
+
+const isTestAsync = ({length}) => length > 1;
+const isHelperAsync = ({length}) => length > 2;
+
+/*
+ * Takes an `exports` object of a test file and a function `beforeFn`
+ * to be run before each test. `beforeFn` is called with a `name` string
+ * as the first argument of the test name, and may specify a second
+ * argument function `done` to indicate that this function should
+ * resolve asynchronously
+ */
+function before (exports, beforeFn) {
+ getTestNames(exports).map(name => {
+ let testFn = exports[name];
+
+ // GENERATOR TESTS
+ if (isGenerator(testFn) && isGenerator(beforeFn)) {
+ exports[name] = function*(assert) {
+ yield Task.spawn(beforeFn.bind(null, name, assert));
+ yield Task.spawn(testFn.bind(null, assert));
+ }
+ }
+ else if (isGenerator(testFn) && !isHelperAsync(beforeFn)) {
+ exports[name] = function*(assert) {
+ beforeFn(name, assert);
+ yield Task.spawn(testFn.bind(null, assert));
+ }
+ }
+ else if (isGenerator(testFn) && isHelperAsync(beforeFn)) {
+ exports[name] = function*(assert) {
+ yield new Promise(resolve => beforeFn(name, assert, resolve));
+ yield Task.spawn(testFn.bind(null, assert));
+ }
+ }
+ // SYNC TESTS
+ else if (!isTestAsync(testFn) && isGenerator(beforeFn)) {
+ exports[name] = function*(assert) {
+ yield Task.spawn(beforeFn.bind(null, name, assert));
+ testFn(assert);
+ };
+ }
+ else if (!isTestAsync(testFn) && !isHelperAsync(beforeFn)) {
+ exports[name] = function (assert) {
+ beforeFn(name, assert);
+ testFn(assert);
+ };
+ }
+ else if (!isTestAsync(testFn) && isHelperAsync(beforeFn)) {
+ exports[name] = function (assert, done) {
+ beforeFn(name, assert, () => {
+ testFn(assert);
+ done();
+ });
+ };
+ }
+ // ASYNC TESTS
+ else if (isTestAsync(testFn) && isGenerator(beforeFn)) {
+ exports[name] = function*(assert) {
+ yield Task.spawn(beforeFn.bind(null, name, assert));
+ yield new Promise(resolve => testFn(assert, resolve));
+ };
+ }
+ else if (isTestAsync(testFn) && !isHelperAsync(beforeFn)) {
+ exports[name] = function (assert, done) {
+ beforeFn(name, assert);
+ testFn(assert, done);
+ };
+ }
+ else if (isTestAsync(testFn) && isHelperAsync(beforeFn)) {
+ exports[name] = function (assert, done) {
+ beforeFn(name, assert, () => {
+ testFn(assert, done);
+ });
+ };
+ }
+ });
+}
+exports.before = before;
+
+/*
+ * Takes an `exports` object of a test file and a function `afterFn`
+ * to be run after each test. `afterFn` is called with a `name` string
+ * as the first argument of the test name, and may specify a second
+ * argument function `done` to indicate that this function should
+ * resolve asynchronously
+ */
+function after (exports, afterFn) {
+ getTestNames(exports).map(name => {
+ let testFn = exports[name];
+
+ // GENERATOR TESTS
+ if (isGenerator(testFn) && isGenerator(afterFn)) {
+ exports[name] = function*(assert) {
+ yield Task.spawn(testFn.bind(null, assert));
+ yield Task.spawn(afterFn.bind(null, name, assert));
+ }
+ }
+ else if (isGenerator(testFn) && !isHelperAsync(afterFn)) {
+ exports[name] = function*(assert) {
+ yield Task.spawn(testFn.bind(null, assert));
+ afterFn(name, assert);
+ }
+ }
+ else if (isGenerator(testFn) && isHelperAsync(afterFn)) {
+ exports[name] = function*(assert) {
+ yield Task.spawn(testFn.bind(null, assert));
+ yield new Promise(resolve => afterFn(name, assert, resolve));
+ }
+ }
+ // SYNC TESTS
+ else if (!isTestAsync(testFn) && isGenerator(afterFn)) {
+ exports[name] = function*(assert) {
+ testFn(assert);
+ yield Task.spawn(afterFn.bind(null, name, assert));
+ };
+ }
+ else if (!isTestAsync(testFn) && !isHelperAsync(afterFn)) {
+ exports[name] = function (assert) {
+ testFn(assert);
+ afterFn(name, assert);
+ };
+ }
+ else if (!isTestAsync(testFn) && isHelperAsync(afterFn)) {
+ exports[name] = function (assert, done) {
+ testFn(assert);
+ afterFn(name, assert, done);
+ };
+ }
+ // ASYNC TESTS
+ else if (isTestAsync(testFn) && isGenerator(afterFn)) {
+ exports[name] = function*(assert) {
+ yield new Promise(resolve => testFn(assert, resolve));
+ yield Task.spawn(afterFn.bind(null, name, assert));
+ };
+ }
+ else if (isTestAsync(testFn) && !isHelperAsync(afterFn)) {
+ exports[name] = function*(assert) {
+ yield new Promise(resolve => testFn(assert, resolve));
+ afterFn(name, assert);
+ };
+ }
+ else if (isTestAsync(testFn) && isHelperAsync(afterFn)) {
+ exports[name] = function*(assert) {
+ yield new Promise(resolve => testFn(assert, resolve));
+ yield new Promise(resolve => afterFn(name, assert, resolve));
+ };
+ }
+ });
+}
+exports.after = after;
+
+function waitUntil (predicate, delay) {
+ let { promise, resolve } = defer();
+ let interval = setInterval(() => {
+ if (!predicate()) return;
+ clearInterval(interval);
+ resolve();
+ }, delay || 10);
+ return promise;
+}
+exports.waitUntil = waitUntil;
+
+var cleanUI = function cleanUI() {
+ let { promise, resolve } = defer();
+
+ let windows = getWindows(null, { includePrivate: true });
+ if (windows.length > 1) {
+ return closeWindow(windows[1]).then(cleanUI);
+ }
+
+ getTabs(windows[0]).slice(1).forEach(closeTab);
+
+ resolve();
+
+ return promise;
+}
+exports.cleanUI = cleanUI;
+
+exports.isTravisCI = ("TRAVIS" in env && "CI" in env);
diff --git a/toolkit/jetpack/sdk/timers.js b/toolkit/jetpack/sdk/timers.js
new file mode 100644
index 000000000..e97db01f2
--- /dev/null
+++ b/toolkit/jetpack/sdk/timers.js
@@ -0,0 +1,105 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "stable"
+};
+
+const { CC, Cc, Ci } = require("chrome");
+const { when: unload } = require("./system/unload");
+
+const { TYPE_ONE_SHOT, TYPE_REPEATING_SLACK } = Ci.nsITimer;
+const Timer = CC("@mozilla.org/timer;1", "nsITimer");
+const timers = Object.create(null);
+const threadManager = Cc["@mozilla.org/thread-manager;1"].
+ getService(Ci.nsIThreadManager);
+const prefBranch = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefService).
+ QueryInterface(Ci.nsIPrefBranch);
+
+var MIN_DELAY = 4;
+// Try to get min timeout delay used by browser.
+try { MIN_DELAY = prefBranch.getIntPref("dom.min_timeout_value"); } finally {}
+
+
+// Last timer id.
+var lastID = 0;
+
+// Sets typer either by timeout or by interval
+// depending on a given type.
+function setTimer(type, callback, delay, ...args) {
+ let id = ++ lastID;
+ let timer = timers[id] = Timer();
+ timer.initWithCallback({
+ notify: function notify() {
+ try {
+ if (type === TYPE_ONE_SHOT)
+ delete timers[id];
+ callback.apply(null, args);
+ }
+ catch(error) {
+ console.exception(error);
+ }
+ }
+ }, Math.max(delay || MIN_DELAY), type);
+ return id;
+}
+
+function unsetTimer(id) {
+ let timer = timers[id];
+ delete timers[id];
+ if (timer) timer.cancel();
+}
+
+var immediates = new Map();
+
+var dispatcher = _ => {
+ // Allow scheduling of a new dispatch loop.
+ dispatcher.scheduled = false;
+ // Take a snapshot of timer `id`'s that have being present before
+ // starting a dispatch loop, in order to ignore timers registered
+ // in side effect to dispatch while also skipping immediates that
+ // were removed in side effect.
+ let ids = [...immediates.keys()];
+ for (let id of ids) {
+ let immediate = immediates.get(id);
+ if (immediate) {
+ immediates.delete(id);
+ try { immediate(); }
+ catch (error) { console.exception(error); }
+ }
+ }
+}
+
+function setImmediate(callback, ...params) {
+ let id = ++ lastID;
+ // register new immediate timer with curried params.
+ immediates.set(id, _ => callback.apply(callback, params));
+ // if dispatch loop is not scheduled schedule one. Own scheduler
+ if (!dispatcher.scheduled) {
+ dispatcher.scheduled = true;
+ threadManager.currentThread.dispatch(dispatcher,
+ Ci.nsIThread.DISPATCH_NORMAL);
+ }
+ return id;
+}
+
+function clearImmediate(id) {
+ immediates.delete(id);
+}
+
+// Bind timers so that toString-ing them looks same as on native timers.
+exports.setImmediate = setImmediate.bind(null);
+exports.clearImmediate = clearImmediate.bind(null);
+exports.setTimeout = setTimer.bind(null, TYPE_ONE_SHOT);
+exports.setInterval = setTimer.bind(null, TYPE_REPEATING_SLACK);
+exports.clearTimeout = unsetTimer.bind(null);
+exports.clearInterval = unsetTimer.bind(null);
+
+// all timers are cleared out on unload.
+unload(function() {
+ immediates.clear();
+ Object.keys(timers).forEach(unsetTimer)
+});
diff --git a/toolkit/jetpack/sdk/ui.js b/toolkit/jetpack/sdk/ui.js
new file mode 100644
index 000000000..7f9110b26
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui.js
@@ -0,0 +1,17 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '> 28'
+ }
+};
+
+exports.ActionButton = require('./ui/button/action').ActionButton;
+exports.ToggleButton = require('./ui/button/toggle').ToggleButton;
+exports.Sidebar = require('./ui/sidebar').Sidebar;
+exports.Frame = require('./ui/frame').Frame;
+exports.Toolbar = require('./ui/toolbar').Toolbar;
diff --git a/toolkit/jetpack/sdk/ui/button/action.js b/toolkit/jetpack/sdk/ui/button/action.js
new file mode 100644
index 000000000..dfb092d0c
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/button/action.js
@@ -0,0 +1,114 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '> 28'
+ }
+};
+
+const { Class } = require('../../core/heritage');
+const { merge } = require('../../util/object');
+const { Disposable } = require('../../core/disposable');
+const { on, off, emit, setListeners } = require('../../event/core');
+const { EventTarget } = require('../../event/target');
+const { getNodeView } = require('../../view/core');
+
+const view = require('./view');
+const { buttonContract, stateContract } = require('./contract');
+const { properties, render, state, register, unregister,
+ getDerivedStateFor } = require('../state');
+const { events: stateEvents } = require('../state/events');
+const { events: viewEvents } = require('./view/events');
+const events = require('../../event/utils');
+
+const { getActiveTab } = require('../../tabs/utils');
+
+const { id: addonID } = require('../../self');
+const { identify } = require('../id');
+
+const buttons = new Map();
+
+const toWidgetId = id =>
+ ('action-button--' + addonID.toLowerCase()+ '-' + id).
+ replace(/[^a-z0-9_-]/g, '');
+
+const ActionButton = Class({
+ extends: EventTarget,
+ implements: [
+ properties(stateContract),
+ state(stateContract),
+ Disposable
+ ],
+ setup: function setup(options) {
+ let state = merge({
+ disabled: false
+ }, buttonContract(options));
+
+ let id = toWidgetId(options.id);
+
+ register(this, state);
+
+ // Setup listeners.
+ setListeners(this, options);
+
+ buttons.set(id, this);
+
+ view.create(merge({}, state, { id: id }));
+ },
+
+ dispose: function dispose() {
+ let id = toWidgetId(this.id);
+ buttons.delete(id);
+
+ off(this);
+
+ view.dispose(id);
+
+ unregister(this);
+ },
+
+ get id() {
+ return this.state().id;
+ },
+
+ click: function click() { view.click(toWidgetId(this.id)) }
+});
+exports.ActionButton = ActionButton;
+
+identify.define(ActionButton, ({id}) => toWidgetId(id));
+
+getNodeView.define(ActionButton, button =>
+ view.nodeFor(toWidgetId(button.id))
+);
+
+var actionButtonStateEvents = events.filter(stateEvents,
+ e => e.target instanceof ActionButton);
+
+var actionButtonViewEvents = events.filter(viewEvents,
+ e => buttons.has(e.target));
+
+var clickEvents = events.filter(actionButtonViewEvents, e => e.type === 'click');
+var updateEvents = events.filter(actionButtonViewEvents, e => e.type === 'update');
+
+on(clickEvents, 'data', ({target: id, window}) => {
+ let button = buttons.get(id);
+ let state = getDerivedStateFor(button, getActiveTab(window));
+
+ emit(button, 'click', state);
+});
+
+on(updateEvents, 'data', ({target: id, window}) => {
+ render(buttons.get(id), window);
+});
+
+on(actionButtonStateEvents, 'data', ({target, window, state}) => {
+ let id = toWidgetId(target.id);
+ view.setIcon(id, window, state.icon);
+ view.setLabel(id, window, state.label);
+ view.setDisabled(id, window, state.disabled);
+ view.setBadge(id, window, state.badge, state.badgeColor);
+});
diff --git a/toolkit/jetpack/sdk/ui/button/contract.js b/toolkit/jetpack/sdk/ui/button/contract.js
new file mode 100644
index 000000000..ce6e33d95
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/button/contract.js
@@ -0,0 +1,73 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { contract } = require('../../util/contract');
+const { isLocalURL } = require('../../url');
+const { isNil, isObject, isString } = require('../../lang/type');
+const { required, either, string, boolean, object, number } = require('../../deprecated/api-utils');
+const { merge } = require('../../util/object');
+const { freeze } = Object;
+
+const isIconSet = (icons) =>
+ Object.keys(icons).
+ every(size => String(size >>> 0) === size && isLocalURL(icons[size]));
+
+var iconSet = {
+ is: either(object, string),
+ map: v => isObject(v) ? freeze(merge({}, v)) : v,
+ ok: v => (isString(v) && isLocalURL(v)) || (isObject(v) && isIconSet(v)),
+ msg: 'The option "icon" must be a local URL or an object with ' +
+ 'numeric keys / local URL values pair.'
+}
+
+var id = {
+ is: string,
+ ok: v => /^[a-z-_][a-z0-9-_]*$/i.test(v),
+ msg: 'The option "id" must be a valid alphanumeric id (hyphens and ' +
+ 'underscores are allowed).'
+};
+
+var label = {
+ is: string,
+ ok: v => isNil(v) || v.trim().length > 0,
+ msg: 'The option "label" must be a non empty string'
+}
+
+var badge = {
+ is: either(string, number),
+ msg: 'The option "badge" must be a string or a number'
+}
+
+var badgeColor = {
+ is: string,
+ msg: 'The option "badgeColor" must be a string'
+}
+
+var stateContract = contract({
+ label: label,
+ icon: iconSet,
+ disabled: boolean,
+ badge: badge,
+ badgeColor: badgeColor
+});
+
+exports.stateContract = stateContract;
+
+var buttonContract = contract(merge({}, stateContract.rules, {
+ id: required(id),
+ label: required(label),
+ icon: required(iconSet)
+}));
+
+exports.buttonContract = buttonContract;
+
+exports.toggleStateContract = contract(merge({
+ checked: boolean
+}, stateContract.rules));
+
+exports.toggleButtonContract = contract(merge({
+ checked: boolean
+}, buttonContract.rules));
+
diff --git a/toolkit/jetpack/sdk/ui/button/toggle.js b/toolkit/jetpack/sdk/ui/button/toggle.js
new file mode 100644
index 000000000..a226b3212
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/button/toggle.js
@@ -0,0 +1,127 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '> 28'
+ }
+};
+
+const { Class } = require('../../core/heritage');
+const { merge } = require('../../util/object');
+const { Disposable } = require('../../core/disposable');
+const { on, off, emit, setListeners } = require('../../event/core');
+const { EventTarget } = require('../../event/target');
+const { getNodeView } = require('../../view/core');
+
+const view = require('./view');
+const { toggleButtonContract, toggleStateContract } = require('./contract');
+const { properties, render, state, register, unregister,
+ setStateFor, getStateFor, getDerivedStateFor } = require('../state');
+const { events: stateEvents } = require('../state/events');
+const { events: viewEvents } = require('./view/events');
+const events = require('../../event/utils');
+
+const { getActiveTab } = require('../../tabs/utils');
+
+const { id: addonID } = require('../../self');
+const { identify } = require('../id');
+
+const buttons = new Map();
+
+const toWidgetId = id =>
+ ('toggle-button--' + addonID.toLowerCase()+ '-' + id).
+ replace(/[^a-z0-9_-]/g, '');
+
+const ToggleButton = Class({
+ extends: EventTarget,
+ implements: [
+ properties(toggleStateContract),
+ state(toggleStateContract),
+ Disposable
+ ],
+ setup: function setup(options) {
+ let state = merge({
+ disabled: false,
+ checked: false
+ }, toggleButtonContract(options));
+
+ let id = toWidgetId(options.id);
+
+ register(this, state);
+
+ // Setup listeners.
+ setListeners(this, options);
+
+ buttons.set(id, this);
+
+ view.create(merge({ type: 'checkbox' }, state, { id: id }));
+ },
+
+ dispose: function dispose() {
+ let id = toWidgetId(this.id);
+ buttons.delete(id);
+
+ off(this);
+
+ view.dispose(id);
+
+ unregister(this);
+ },
+
+ get id() {
+ return this.state().id;
+ },
+
+ click: function click() {
+ return view.click(toWidgetId(this.id));
+ }
+});
+exports.ToggleButton = ToggleButton;
+
+identify.define(ToggleButton, ({id}) => toWidgetId(id));
+
+getNodeView.define(ToggleButton, button =>
+ view.nodeFor(toWidgetId(button.id))
+);
+
+var toggleButtonStateEvents = events.filter(stateEvents,
+ e => e.target instanceof ToggleButton);
+
+var toggleButtonViewEvents = events.filter(viewEvents,
+ e => buttons.has(e.target));
+
+var clickEvents = events.filter(toggleButtonViewEvents, e => e.type === 'click');
+var updateEvents = events.filter(toggleButtonViewEvents, e => e.type === 'update');
+
+on(toggleButtonStateEvents, 'data', ({target, window, state}) => {
+ let id = toWidgetId(target.id);
+
+ view.setIcon(id, window, state.icon);
+ view.setLabel(id, window, state.label);
+ view.setDisabled(id, window, state.disabled);
+ view.setChecked(id, window, state.checked);
+ view.setBadge(id, window, state.badge, state.badgeColor);
+});
+
+on(clickEvents, 'data', ({target: id, window, checked }) => {
+ let button = buttons.get(id);
+ let windowState = getStateFor(button, window);
+
+ let newWindowState = merge({}, windowState, { checked: checked });
+
+ setStateFor(button, window, newWindowState);
+
+ let state = getDerivedStateFor(button, getActiveTab(window));
+
+ emit(button, 'click', state);
+
+ emit(button, 'change', state);
+});
+
+on(updateEvents, 'data', ({target: id, window}) => {
+ render(buttons.get(id), window);
+});
diff --git a/toolkit/jetpack/sdk/ui/button/view.js b/toolkit/jetpack/sdk/ui/button/view.js
new file mode 100644
index 000000000..63b7aea31
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/button/view.js
@@ -0,0 +1,243 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '> 28'
+ }
+};
+
+const { Cu } = require('chrome');
+const { on, off, emit } = require('../../event/core');
+
+const { data } = require('sdk/self');
+
+const { isObject, isNil } = require('../../lang/type');
+
+const { getMostRecentBrowserWindow } = require('../../window/utils');
+const { ignoreWindow } = require('../../private-browsing/utils');
+const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
+const { AREA_PANEL, AREA_NAVBAR } = CustomizableUI;
+
+const { events: viewEvents } = require('./view/events');
+
+const XUL_NS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
+
+const views = new Map();
+const customizedWindows = new WeakMap();
+
+const buttonListener = {
+ onCustomizeStart: window => {
+ for (let [id, view] of views) {
+ setIcon(id, window, view.icon);
+ setLabel(id, window, view.label);
+ }
+
+ customizedWindows.set(window, true);
+ },
+ onCustomizeEnd: window => {
+ customizedWindows.delete(window);
+
+ for (let [id, ] of views) {
+ let placement = CustomizableUI.getPlacementOfWidget(id);
+
+ if (placement)
+ emit(viewEvents, 'data', { type: 'update', target: id, window: window });
+ }
+ },
+ onWidgetAfterDOMChange: (node, nextNode, container) => {
+ let { id } = node;
+ let view = views.get(id);
+ let window = node.ownerDocument.defaultView;
+
+ if (view) {
+ emit(viewEvents, 'data', { type: 'update', target: id, window: window });
+ }
+ }
+};
+
+CustomizableUI.addListener(buttonListener);
+
+require('../../system/unload').when( _ =>
+ CustomizableUI.removeListener(buttonListener)
+);
+
+function getNode(id, window) {
+ return !views.has(id) || ignoreWindow(window)
+ ? null
+ : CustomizableUI.getWidget(id).forWindow(window).node
+};
+
+function isInToolbar(id) {
+ let placement = CustomizableUI.getPlacementOfWidget(id);
+
+ return placement && CustomizableUI.getAreaType(placement.area) === 'toolbar';
+}
+
+
+function getImage(icon, isInToolbar, pixelRatio) {
+ let targetSize = (isInToolbar ? 18 : 32) * pixelRatio;
+ let bestSize = 0;
+ let image = icon;
+
+ if (isObject(icon)) {
+ for (let size of Object.keys(icon)) {
+ size = +size;
+ let offset = targetSize - size;
+
+ if (offset === 0) {
+ bestSize = size;
+ break;
+ }
+
+ let delta = Math.abs(offset) - Math.abs(targetSize - bestSize);
+
+ if (delta < 0)
+ bestSize = size;
+ }
+
+ image = icon[bestSize];
+ }
+
+ if (image.indexOf('./') === 0)
+ return data.url(image.substr(2));
+
+ return image;
+}
+
+function nodeFor(id, window=getMostRecentBrowserWindow()) {
+ return customizedWindows.has(window) ? null : getNode(id, window);
+};
+exports.nodeFor = nodeFor;
+
+function create(options) {
+ let { id, label, icon, type, badge } = options;
+
+ if (views.has(id))
+ throw new Error('The ID "' + id + '" seems already used.');
+
+ CustomizableUI.createWidget({
+ id: id,
+ type: 'custom',
+ removable: true,
+ defaultArea: AREA_NAVBAR,
+ allowedAreas: [ AREA_PANEL, AREA_NAVBAR ],
+
+ onBuild: function(document) {
+ let window = document.defaultView;
+
+ let node = document.createElementNS(XUL_NS, 'toolbarbutton');
+
+ let image = getImage(icon, true, window.devicePixelRatio);
+
+ if (ignoreWindow(window))
+ node.style.display = 'none';
+
+ node.setAttribute('id', this.id);
+ node.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional badged-button');
+ node.setAttribute('type', type);
+ node.setAttribute('label', label);
+ node.setAttribute('tooltiptext', label);
+ node.setAttribute('image', image);
+ node.setAttribute('constrain-size', 'true');
+
+ views.set(id, {
+ area: this.currentArea,
+ icon: icon,
+ label: label
+ });
+
+ node.addEventListener('command', function(event) {
+ if (views.has(id)) {
+ emit(viewEvents, 'data', {
+ type: 'click',
+ target: id,
+ window: event.view,
+ checked: node.checked
+ });
+ }
+ });
+
+ return node;
+ }
+ });
+};
+exports.create = create;
+
+function dispose(id) {
+ if (!views.has(id)) return;
+
+ views.delete(id);
+ CustomizableUI.destroyWidget(id);
+}
+exports.dispose = dispose;
+
+function setIcon(id, window, icon) {
+ let node = getNode(id, window);
+
+ if (node) {
+ icon = customizedWindows.has(window) ? views.get(id).icon : icon;
+ let image = getImage(icon, isInToolbar(id), window.devicePixelRatio);
+
+ node.setAttribute('image', image);
+ }
+}
+exports.setIcon = setIcon;
+
+function setLabel(id, window, label) {
+ let node = nodeFor(id, window);
+
+ if (node) {
+ node.setAttribute('label', label);
+ node.setAttribute('tooltiptext', label);
+ }
+}
+exports.setLabel = setLabel;
+
+function setDisabled(id, window, disabled) {
+ let node = nodeFor(id, window);
+
+ if (node)
+ node.disabled = disabled;
+}
+exports.setDisabled = setDisabled;
+
+function setChecked(id, window, checked) {
+ let node = nodeFor(id, window);
+
+ if (node)
+ node.checked = checked;
+}
+exports.setChecked = setChecked;
+
+function setBadge(id, window, badge, color) {
+ let node = nodeFor(id, window);
+
+ if (node) {
+ // `Array.from` is needed to handle unicode symbol properly:
+ // '𝐀𝐁'.length is 4 where Array.from('𝐀𝐁').length is 2
+ let text = isNil(badge)
+ ? ''
+ : Array.from(String(badge)).slice(0, 4).join('');
+
+ node.setAttribute('badge', text);
+
+ let badgeNode = node.ownerDocument.getAnonymousElementByAttribute(node,
+ 'class', 'toolbarbutton-badge');
+
+ if (badgeNode)
+ badgeNode.style.backgroundColor = isNil(color) ? '' : color;
+ }
+}
+exports.setBadge = setBadge;
+
+function click(id) {
+ let node = nodeFor(id);
+
+ if (node)
+ node.click();
+}
+exports.click = click;
diff --git a/toolkit/jetpack/sdk/ui/button/view/events.js b/toolkit/jetpack/sdk/ui/button/view/events.js
new file mode 100644
index 000000000..98909656a
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/button/view/events.js
@@ -0,0 +1,18 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '*',
+ 'SeaMonkey': '*',
+ 'Thunderbird': '*'
+ }
+};
+
+var channel = {};
+
+exports.events = channel;
diff --git a/toolkit/jetpack/sdk/ui/component.js b/toolkit/jetpack/sdk/ui/component.js
new file mode 100644
index 000000000..d1f12c95e
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/component.js
@@ -0,0 +1,182 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+// Internal properties not exposed to the public.
+const cache = Symbol("component/cache");
+const writer = Symbol("component/writer");
+const isFirstWrite = Symbol("component/writer/first-write?");
+const currentState = Symbol("component/state/current");
+const pendingState = Symbol("component/state/pending");
+const isWriting = Symbol("component/writing?");
+
+const isntNull = x => x !== null;
+
+const Component = function(options, children) {
+ this[currentState] = null;
+ this[pendingState] = null;
+ this[writer] = null;
+ this[cache] = null;
+ this[isFirstWrite] = true;
+
+ this[Component.construct](options, children);
+}
+Component.Component = Component;
+// Constructs component.
+Component.construct = Symbol("component/construct");
+// Called with `options` and `children` and must return
+// initial state back.
+Component.initial = Symbol("component/initial");
+
+// Function patches current `state` with a given update.
+Component.patch = Symbol("component/patch");
+// Function that replaces current `state` with a passed state.
+Component.reset = Symbol("component/reset");
+
+// Function that must return render tree from passed state.
+Component.render = Symbol("component/render");
+
+// Path of the component with in the mount point.
+Component.path = Symbol("component/path");
+
+Component.isMounted = component => !!component[writer];
+Component.isWriting = component => !!component[isWriting];
+
+// Internal method that mounts component to a writer.
+// Mounts component to a writer.
+Component.mount = (component, write) => {
+ if (Component.isMounted(component)) {
+ throw Error("Can not mount already mounted component");
+ }
+
+ component[writer] = write;
+ Component.write(component);
+
+ if (component[Component.mounted]) {
+ component[Component.mounted]();
+ }
+}
+
+// Unmounts component from a writer.
+Component.unmount = (component) => {
+ if (Component.isMounted(component)) {
+ component[writer] = null;
+ if (component[Component.unmounted]) {
+ component[Component.unmounted]();
+ }
+ } else {
+ console.warn("Unmounting component that is not mounted is redundant");
+ }
+};
+ // Method invoked once after inital write occurs.
+Component.mounted = Symbol("component/mounted");
+// Internal method that unmounts component from the writer.
+Component.unmounted = Symbol("component/unmounted");
+// Function that must return true if component is changed
+Component.isUpdated = Symbol("component/updated?");
+Component.update = Symbol("component/update");
+Component.updated = Symbol("component/updated");
+
+const writeChild = base => (child, index) => Component.write(child, base, index)
+Component.write = (component, base, index) => {
+ if (component === null) {
+ return component;
+ }
+
+ if (!(component instanceof Component)) {
+ const path = base ? `${base}${component.key || index}/` : `/`;
+ return Object.assign({}, component, {
+ [Component.path]: path,
+ children: component.children && component.children.
+ map(writeChild(path)).
+ filter(isntNull)
+ });
+ }
+
+ component[isWriting] = true;
+
+ try {
+
+ const current = component[currentState];
+ const pending = component[pendingState] || current;
+ const isUpdated = component[Component.isUpdated];
+ const isInitial = component[isFirstWrite];
+
+ if (isUpdated(current, pending) || isInitial) {
+ if (!isInitial && component[Component.update]) {
+ component[Component.update](pending, current)
+ }
+
+ // Note: [Component.update] could have caused more updates so can't use
+ // `pending` as `component[pendingState]` may have changed.
+ component[currentState] = component[pendingState] || current;
+ component[pendingState] = null;
+
+ const tree = component[Component.render](component[currentState]);
+ component[cache] = Component.write(tree, base, index);
+ if (component[writer]) {
+ component[writer].call(null, component[cache]);
+ }
+
+ if (!isInitial && component[Component.updated]) {
+ component[Component.updated](current, pending);
+ }
+ }
+
+ component[isFirstWrite] = false;
+
+ return component[cache];
+ } finally {
+ component[isWriting] = false;
+ }
+};
+
+Component.prototype = Object.freeze({
+ constructor: Component,
+
+ [Component.mounted]: null,
+ [Component.unmounted]: null,
+ [Component.update]: null,
+ [Component.updated]: null,
+
+ get state() {
+ return this[pendingState] || this[currentState];
+ },
+
+
+ [Component.construct](settings, items) {
+ const initial = this[Component.initial];
+ const base = initial(settings, items);
+ const options = Object.assign(Object.create(null), base.options, settings);
+ const children = base.children || items || null;
+ const state = Object.assign(Object.create(null), base, {options, children});
+ this[currentState] = state;
+
+ if (this.setup) {
+ this.setup(state);
+ }
+ },
+ [Component.initial](options, children) {
+ return Object.create(null);
+ },
+ [Component.patch](update) {
+ this[Component.reset](Object.assign({}, this.state, update));
+ },
+ [Component.reset](state) {
+ this[pendingState] = state;
+ if (Component.isMounted(this) && !Component.isWriting(this)) {
+ Component.write(this);
+ }
+ },
+
+ [Component.isUpdated](before, after) {
+ return before != after
+ },
+
+ [Component.render](state) {
+ throw Error("Component must implement [Component.render] member");
+ }
+});
+
+module.exports = Component;
diff --git a/toolkit/jetpack/sdk/ui/frame.js b/toolkit/jetpack/sdk/ui/frame.js
new file mode 100644
index 000000000..566353cdf
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/frame.js
@@ -0,0 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "> 28"
+ }
+};
+
+require("./frame/view");
+const { Frame } = require("./frame/model");
+
+exports.Frame = Frame;
diff --git a/toolkit/jetpack/sdk/ui/frame/model.js b/toolkit/jetpack/sdk/ui/frame/model.js
new file mode 100644
index 000000000..627310874
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/frame/model.js
@@ -0,0 +1,154 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "> 28"
+ }
+};
+
+const { Class } = require("../../core/heritage");
+const { EventTarget } = require("../../event/target");
+const { emit, off, setListeners } = require("../../event/core");
+const { Reactor, foldp, send, merges } = require("../../event/utils");
+const { Disposable } = require("../../core/disposable");
+const { OutputPort } = require("../../output/system");
+const { InputPort } = require("../../input/system");
+const { identify } = require("../id");
+const { pairs, object, map, each } = require("../../util/sequence");
+const { patch, diff } = require("diffpatcher/index");
+const { isLocalURL } = require("../../url");
+const { compose } = require("../../lang/functional");
+const { contract } = require("../../util/contract");
+const { id: addonID, data: { url: resolve }} = require("../../self");
+const { Frames } = require("../../input/frame");
+
+
+const output = new OutputPort({ id: "frame-change" });
+const mailbox = new OutputPort({ id: "frame-mailbox" });
+const input = Frames;
+
+
+const makeID = url =>
+ ("frame-" + addonID + "-" + url).
+ split("/").join("-").
+ split(".").join("-").
+ replace(/[^A-Za-z0-9_\-]/g, "");
+
+const validate = contract({
+ name: {
+ is: ["string", "undefined"],
+ ok: x => /^[a-z][a-z0-9-_]+$/i.test(x),
+ msg: "The `option.name` must be a valid alphanumeric string (hyphens and " +
+ "underscores are allowed) starting with letter."
+ },
+ url: {
+ map: x => x.toString(),
+ is: ["string"],
+ ok: x => isLocalURL(x),
+ msg: "The `options.url` must be a valid local URI."
+ }
+});
+
+const Source = function({id, ownerID}) {
+ this.id = id;
+ this.ownerID = ownerID;
+};
+Source.postMessage = ({id, ownerID}, data, origin) => {
+ send(mailbox, object([id, {
+ inbox: {
+ target: {id: id, ownerID: ownerID},
+ timeStamp: Date.now(),
+ data: data,
+ origin: origin
+ }
+ }]));
+};
+Source.prototype.postMessage = function(data, origin) {
+ Source.postMessage(this, data, origin);
+};
+
+const Message = function({type, data, source, origin, timeStamp}) {
+ this.type = type;
+ this.data = data;
+ this.origin = origin;
+ this.timeStamp = timeStamp;
+ this.source = new Source(source);
+};
+
+
+const frames = new Map();
+const sources = new Map();
+
+const Frame = Class({
+ extends: EventTarget,
+ implements: [Disposable, Source],
+ initialize: function(params={}) {
+ const options = validate(params);
+ const id = makeID(options.name || options.url);
+
+ if (frames.has(id))
+ throw Error("Frame with this id already exists: " + id);
+
+ const initial = { id: id, url: resolve(options.url) };
+ this.id = id;
+
+ setListeners(this, params);
+
+ frames.set(this.id, this);
+
+ send(output, object([id, initial]));
+ },
+ get url() {
+ const state = reactor.value[this.id];
+ return state && state.url;
+ },
+ destroy: function() {
+ send(output, object([this.id, null]));
+ frames.delete(this.id);
+ off(this);
+ },
+ // `JSON.stringify` serializes objects based of the return
+ // value of this method. For convinienc we provide this method
+ // to serialize actual state data.
+ toJSON: function() {
+ return { id: this.id, url: this.url };
+ }
+});
+identify.define(Frame, frame => frame.id);
+
+exports.Frame = Frame;
+
+const reactor = new Reactor({
+ onStep: (present, past) => {
+ const delta = diff(past, present);
+
+ each(([id, update]) => {
+ const frame = frames.get(id);
+ if (update) {
+ if (!past[id])
+ emit(frame, "register");
+
+ if (update.outbox)
+ emit(frame, "message", new Message(present[id].outbox));
+
+ each(([ownerID, state]) => {
+ const readyState = state ? state.readyState : "detach";
+ const type = readyState === "loading" ? "attach" :
+ readyState === "interactive" ? "ready" :
+ readyState === "complete" ? "load" :
+ readyState;
+
+ // TODO: Cache `Source` instances somewhere to preserve
+ // identity.
+ emit(frame, type, {type: type,
+ source: new Source({id: id, ownerID: ownerID})});
+ }, pairs(update.owners));
+ }
+ }, pairs(delta));
+ }
+});
+reactor.run(input);
diff --git a/toolkit/jetpack/sdk/ui/frame/view.html b/toolkit/jetpack/sdk/ui/frame/view.html
new file mode 100644
index 000000000..2a405b583
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/frame/view.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script>
+ // HACK: This is not an ideal way to deliver chrome messages
+ // to an inner frame content but seems only way that would
+ // make `event.source` this (outer frame) window.
+ window.onmessage = function(event) {
+ var frame = document.querySelector("iframe");
+ var content = frame.contentWindow;
+ // If message is posted from chrome it has no `event.source`.
+ if (event.source === null)
+ content.postMessage(event.data, "*");
+ };
+ </script>
+ </head>
+ <body style="overflow: hidden"></body>
+</html>
diff --git a/toolkit/jetpack/sdk/ui/frame/view.js b/toolkit/jetpack/sdk/ui/frame/view.js
new file mode 100644
index 000000000..2eb4df2b7
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/frame/view.js
@@ -0,0 +1,150 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "> 28"
+ }
+};
+
+const { Cu, Ci } = require("chrome");
+const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
+const { subscribe, send, Reactor, foldp, lift, merges, keepIf } = require("../../event/utils");
+const { InputPort } = require("../../input/system");
+const { OutputPort } = require("../../output/system");
+const { LastClosed } = require("../../input/browser");
+const { pairs, keys, object, each } = require("../../util/sequence");
+const { curry, compose } = require("../../lang/functional");
+const { getFrameElement, getOuterId,
+ getByOuterId, getOwnerBrowserWindow } = require("../../window/utils");
+const { patch, diff } = require("diffpatcher/index");
+const { encode } = require("../../base64");
+const { Frames } = require("../../input/frame");
+
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+const HTML_NS = "http://www.w3.org/1999/xhtml";
+const OUTER_FRAME_URI = module.uri.replace(/\.js$/, ".html");
+
+const mailbox = new OutputPort({ id: "frame-mailbox" });
+
+const frameID = frame => frame.id.replace("outer-", "");
+const windowID = compose(getOuterId, getOwnerBrowserWindow);
+
+const getOuterFrame = (windowID, frameID) =>
+ getByOuterId(windowID).document.getElementById("outer-" + frameID);
+
+const listener = ({target, source, data, origin, timeStamp}) => {
+ // And sent received message to outbox so that frame API model
+ // will deal with it.
+ if (source && source !== target) {
+ const frame = getFrameElement(target);
+ const id = frameID(frame);
+ send(mailbox, object([id, {
+ outbox: {type: "message",
+ source: {id: id, ownerID: windowID(frame)},
+ data: data,
+ origin: origin,
+ timeStamp: timeStamp}}]));
+ }
+};
+
+// Utility function used to create frame with a given `state` and
+// inject it into given `window`.
+const registerFrame = ({id, url}) => {
+ CustomizableUI.createWidget({
+ id: id,
+ type: "custom",
+ removable: true,
+ onBuild: document => {
+ let view = document.createElementNS(XUL_NS, "toolbaritem");
+ view.setAttribute("id", id);
+ view.setAttribute("flex", 2);
+
+ let outerFrame = document.createElementNS(XUL_NS, "iframe");
+ outerFrame.setAttribute("src", OUTER_FRAME_URI);
+ outerFrame.setAttribute("id", "outer-" + id);
+ outerFrame.setAttribute("data-is-sdk-outer-frame", true);
+ outerFrame.setAttribute("type", "content");
+ outerFrame.setAttribute("transparent", true);
+ outerFrame.setAttribute("flex", 2);
+ outerFrame.setAttribute("style", "overflow: hidden;");
+ outerFrame.setAttribute("scrolling", "no");
+ outerFrame.setAttribute("disablehistory", true);
+ outerFrame.setAttribute("seamless", "seamless");
+ outerFrame.addEventListener("load", function onload() {
+ outerFrame.removeEventListener("load", onload, true);
+
+ let doc = outerFrame.contentDocument;
+
+ let innerFrame = doc.createElementNS(HTML_NS, "iframe");
+ innerFrame.setAttribute("id", id);
+ innerFrame.setAttribute("src", url);
+ innerFrame.setAttribute("seamless", "seamless");
+ innerFrame.setAttribute("sandbox", "allow-scripts");
+ innerFrame.setAttribute("scrolling", "no");
+ innerFrame.setAttribute("data-is-sdk-inner-frame", true);
+ innerFrame.setAttribute("style", [ "border:none",
+ "position:absolute", "width:100%", "top: 0",
+ "left: 0", "overflow: hidden"].join(";"));
+
+ doc.body.appendChild(innerFrame);
+ }, true);
+
+ view.appendChild(outerFrame);
+
+ return view;
+ }
+ });
+};
+
+const unregisterFrame = CustomizableUI.destroyWidget;
+
+const deliverMessage = curry((frameID, data, windowID) => {
+ const frame = getOuterFrame(windowID, frameID);
+ const content = frame && frame.contentWindow;
+
+ if (content)
+ content.postMessage(data, content.location.origin);
+});
+
+const updateFrame = (id, {inbox, owners}, present) => {
+ if (inbox) {
+ const { data, target:{ownerID}, source } = present[id].inbox;
+ if (ownerID)
+ deliverMessage(id, data, ownerID);
+ else
+ each(deliverMessage(id, data), keys(present[id].owners));
+ }
+
+ each(setupView(id), pairs(owners));
+};
+
+const setupView = curry((frameID, [windowID, state]) => {
+ if (state && state.readyState === "loading") {
+ const frame = getOuterFrame(windowID, frameID);
+ // Setup a message listener on contentWindow.
+ frame.contentWindow.addEventListener("message", listener);
+ }
+});
+
+
+const reactor = new Reactor({
+ onStep: (present, past) => {
+ const delta = diff(past, present);
+
+ // Apply frame changes
+ each(([id, update]) => {
+ if (update === null)
+ unregisterFrame(id);
+ else if (past[id])
+ updateFrame(id, update, present);
+ else
+ registerFrame(update);
+ }, pairs(delta));
+ },
+ onEnd: state => each(unregisterFrame, keys(state))
+});
+reactor.run(Frames);
diff --git a/toolkit/jetpack/sdk/ui/id.js b/toolkit/jetpack/sdk/ui/id.js
new file mode 100644
index 000000000..d17eb0a4e
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/id.js
@@ -0,0 +1,27 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental'
+};
+
+const method = require('../../method/core');
+const { uuid } = require('../util/uuid');
+
+// NOTE: use lang/functional memoize when it is updated to use WeakMap
+function memoize(f) {
+ const memo = new WeakMap();
+
+ return function memoizer(o) {
+ let key = o;
+ if (!memo.has(key))
+ memo.set(key, f.apply(this, arguments));
+ return memo.get(key);
+ };
+}
+
+var identify = method('identify');
+identify.define(Object, memoize(function() { return uuid(); }));
+exports.identify = identify;
diff --git a/toolkit/jetpack/sdk/ui/sidebar.js b/toolkit/jetpack/sdk/ui/sidebar.js
new file mode 100644
index 000000000..59e35ea11
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/sidebar.js
@@ -0,0 +1,311 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '*'
+ }
+};
+
+const { Class } = require('../core/heritage');
+const { merge } = require('../util/object');
+const { Disposable } = require('../core/disposable');
+const { off, emit, setListeners } = require('../event/core');
+const { EventTarget } = require('../event/target');
+const { URL } = require('../url');
+const { add, remove, has, clear, iterator } = require('../lang/weak-set');
+const { id: addonID, data } = require('../self');
+const { WindowTracker } = require('../deprecated/window-utils');
+const { isShowing } = require('./sidebar/utils');
+const { isBrowser, getMostRecentBrowserWindow, windows, isWindowPrivate } = require('../window/utils');
+const { ns } = require('../core/namespace');
+const { remove: removeFromArray } = require('../util/array');
+const { show, hide, toggle } = require('./sidebar/actions');
+const { Worker } = require('../deprecated/sync-worker');
+const { contract: sidebarContract } = require('./sidebar/contract');
+const { create, dispose, updateTitle, updateURL, isSidebarShowing, showSidebar, hideSidebar } = require('./sidebar/view');
+const { defer } = require('../core/promise');
+const { models, views, viewsFor, modelFor } = require('./sidebar/namespace');
+const { isLocalURL } = require('../url');
+const { ensure } = require('../system/unload');
+const { identify } = require('./id');
+const { uuid } = require('../util/uuid');
+const { viewFor } = require('../view/core');
+
+const resolveURL = (url) => url ? data.url(url) : url;
+
+const sidebarNS = ns();
+
+const WEB_PANEL_BROWSER_ID = 'web-panels-browser';
+
+var sidebars = {};
+
+const Sidebar = Class({
+ implements: [ Disposable ],
+ extends: EventTarget,
+ setup: function(options) {
+ // inital validation for the model information
+ let model = sidebarContract(options);
+
+ // save the model information
+ models.set(this, model);
+
+ // generate an id if one was not provided
+ model.id = model.id || addonID + '-' + uuid();
+
+ // further validation for the title and url
+ validateTitleAndURLCombo({}, this.title, this.url);
+
+ const self = this;
+ const internals = sidebarNS(self);
+ const windowNS = internals.windowNS = ns();
+
+ // see bug https://bugzilla.mozilla.org/show_bug.cgi?id=886148
+ ensure(this, 'destroy');
+
+ setListeners(this, options);
+
+ let bars = [];
+ internals.tracker = WindowTracker({
+ onTrack: function(window) {
+ if (!isBrowser(window))
+ return;
+
+ let sidebar = window.document.getElementById('sidebar');
+ let sidebarBox = window.document.getElementById('sidebar-box');
+
+ let bar = create(window, {
+ id: self.id,
+ title: self.title,
+ sidebarurl: self.url
+ });
+ bars.push(bar);
+ windowNS(window).bar = bar;
+
+ bar.addEventListener('command', function() {
+ if (isSidebarShowing(window, self)) {
+ hideSidebar(window, self).catch(() => {});
+ return;
+ }
+
+ showSidebar(window, self);
+ }, false);
+
+ function onSidebarLoad() {
+ // check if the sidebar is ready
+ let isReady = sidebar.docShell && sidebar.contentDocument;
+ if (!isReady)
+ return;
+
+ // check if it is a web panel
+ let panelBrowser = sidebar.contentDocument.getElementById(WEB_PANEL_BROWSER_ID);
+ if (!panelBrowser) {
+ bar.removeAttribute('checked');
+ return;
+ }
+
+ let sbTitle = window.document.getElementById('sidebar-title');
+ function onWebPanelSidebarCreated() {
+ if (panelBrowser.contentWindow.location != resolveURL(model.url) ||
+ sbTitle.value != model.title) {
+ return;
+ }
+
+ let worker = windowNS(window).worker = Worker({
+ window: panelBrowser.contentWindow,
+ injectInDocument: true
+ });
+
+ function onWebPanelSidebarUnload() {
+ windowNS(window).onWebPanelSidebarUnload = null;
+
+ // uncheck the associated menuitem
+ bar.setAttribute('checked', 'false');
+
+ emit(self, 'hide', {});
+ emit(self, 'detach', worker);
+ windowNS(window).worker = null;
+ }
+ windowNS(window).onWebPanelSidebarUnload = onWebPanelSidebarUnload;
+ panelBrowser.contentWindow.addEventListener('unload', onWebPanelSidebarUnload, true);
+
+ // check the associated menuitem
+ bar.setAttribute('checked', 'true');
+
+ function onWebPanelSidebarReady() {
+ panelBrowser.contentWindow.removeEventListener('DOMContentLoaded', onWebPanelSidebarReady, false);
+ windowNS(window).onWebPanelSidebarReady = null;
+
+ emit(self, 'ready', worker);
+ }
+ windowNS(window).onWebPanelSidebarReady = onWebPanelSidebarReady;
+ panelBrowser.contentWindow.addEventListener('DOMContentLoaded', onWebPanelSidebarReady, false);
+
+ function onWebPanelSidebarLoad() {
+ panelBrowser.contentWindow.removeEventListener('load', onWebPanelSidebarLoad, true);
+ windowNS(window).onWebPanelSidebarLoad = null;
+
+ // TODO: decide if returning worker is acceptable..
+ //emit(self, 'show', { worker: worker });
+ emit(self, 'show', {});
+ }
+ windowNS(window).onWebPanelSidebarLoad = onWebPanelSidebarLoad;
+ panelBrowser.contentWindow.addEventListener('load', onWebPanelSidebarLoad, true);
+
+ emit(self, 'attach', worker);
+ }
+ windowNS(window).onWebPanelSidebarCreated = onWebPanelSidebarCreated;
+ panelBrowser.addEventListener('DOMWindowCreated', onWebPanelSidebarCreated, true);
+ }
+ windowNS(window).onSidebarLoad = onSidebarLoad;
+ sidebar.addEventListener('load', onSidebarLoad, true); // removed properly
+ },
+ onUntrack: function(window) {
+ if (!isBrowser(window))
+ return;
+
+ // hide the sidebar if it is showing
+ hideSidebar(window, self).catch(() => {});
+
+ // kill the menu item
+ let { bar } = windowNS(window);
+ if (bar) {
+ removeFromArray(viewsFor(self), bar);
+ dispose(bar);
+ }
+
+ // kill listeners
+ let sidebar = window.document.getElementById('sidebar');
+
+ if (windowNS(window).onSidebarLoad) {
+ sidebar && sidebar.removeEventListener('load', windowNS(window).onSidebarLoad, true)
+ windowNS(window).onSidebarLoad = null;
+ }
+
+ let panelBrowser = sidebar && sidebar.contentDocument.getElementById(WEB_PANEL_BROWSER_ID);
+ if (windowNS(window).onWebPanelSidebarCreated) {
+ panelBrowser && panelBrowser.removeEventListener('DOMWindowCreated', windowNS(window).onWebPanelSidebarCreated, true);
+ windowNS(window).onWebPanelSidebarCreated = null;
+ }
+
+ if (windowNS(window).onWebPanelSidebarReady) {
+ panelBrowser && panelBrowser.contentWindow.removeEventListener('DOMContentLoaded', windowNS(window).onWebPanelSidebarReady, false);
+ windowNS(window).onWebPanelSidebarReady = null;
+ }
+
+ if (windowNS(window).onWebPanelSidebarLoad) {
+ panelBrowser && panelBrowser.contentWindow.removeEventListener('load', windowNS(window).onWebPanelSidebarLoad, true);
+ windowNS(window).onWebPanelSidebarLoad = null;
+ }
+
+ if (windowNS(window).onWebPanelSidebarUnload) {
+ panelBrowser && panelBrowser.contentWindow.removeEventListener('unload', windowNS(window).onWebPanelSidebarUnload, true);
+ windowNS(window).onWebPanelSidebarUnload();
+ }
+ }
+ });
+
+ views.set(this, bars);
+
+ add(sidebars, this);
+ },
+ get id() {
+ return (modelFor(this) || {}).id;
+ },
+ get title() {
+ return (modelFor(this) || {}).title;
+ },
+ set title(v) {
+ // destroyed?
+ if (!modelFor(this))
+ return;
+ // validation
+ if (typeof v != 'string')
+ throw Error('title must be a string');
+ validateTitleAndURLCombo(this, v, this.url);
+ // do update
+ updateTitle(this, v);
+ return modelFor(this).title = v;
+ },
+ get url() {
+ return (modelFor(this) || {}).url;
+ },
+ set url(v) {
+ // destroyed?
+ if (!modelFor(this))
+ return;
+
+ // validation
+ if (!isLocalURL(v))
+ throw Error('the url must be a valid local url');
+
+ validateTitleAndURLCombo(this, this.title, v);
+
+ // do update
+ updateURL(this, v);
+ modelFor(this).url = v;
+ },
+ show: function(window) {
+ return showSidebar(viewFor(window), this);
+ },
+ hide: function(window) {
+ return hideSidebar(viewFor(window), this);
+ },
+ dispose: function() {
+ const internals = sidebarNS(this);
+
+ off(this);
+
+ remove(sidebars, this);
+
+ // stop tracking windows
+ if (internals.tracker) {
+ internals.tracker.unload();
+ }
+
+ internals.tracker = null;
+ internals.windowNS = null;
+
+ views.delete(this);
+ models.delete(this);
+ }
+});
+exports.Sidebar = Sidebar;
+
+function validateTitleAndURLCombo(sidebar, title, url) {
+ url = resolveURL(url);
+
+ if (sidebar.title == title && sidebar.url == url) {
+ return false;
+ }
+
+ for (let window of windows(null, { includePrivate: true })) {
+ let sidebar = window.document.querySelector('menuitem[sidebarurl="' + url + '"][label="' + title + '"]');
+ if (sidebar) {
+ throw Error('The provided title and url combination is invalid (already used).');
+ }
+ }
+
+ return false;
+}
+
+isShowing.define(Sidebar, isSidebarShowing.bind(null, null));
+show.define(Sidebar, showSidebar.bind(null, null));
+hide.define(Sidebar, hideSidebar.bind(null, null));
+
+identify.define(Sidebar, function(sidebar) {
+ return sidebar.id;
+});
+
+function toggleSidebar(window, sidebar) {
+ // TODO: make sure this is not private
+ window = window || getMostRecentBrowserWindow();
+ if (isSidebarShowing(window, sidebar)) {
+ return hideSidebar(window, sidebar);
+ }
+ return showSidebar(window, sidebar);
+}
+toggle.define(Sidebar, toggleSidebar.bind(null, null));
diff --git a/toolkit/jetpack/sdk/ui/sidebar/actions.js b/toolkit/jetpack/sdk/ui/sidebar/actions.js
new file mode 100644
index 000000000..4a52984c9
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/sidebar/actions.js
@@ -0,0 +1,10 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const method = require('../../../method/core');
+
+exports.show = method('show');
+exports.hide = method('hide');
+exports.toggle = method('toggle');
diff --git a/toolkit/jetpack/sdk/ui/sidebar/contract.js b/toolkit/jetpack/sdk/ui/sidebar/contract.js
new file mode 100644
index 000000000..b59c37c0b
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/sidebar/contract.js
@@ -0,0 +1,27 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { contract } = require('../../util/contract');
+const { isValidURI, URL, isLocalURL } = require('../../url');
+const { isNil, isObject, isString } = require('../../lang/type');
+
+exports.contract = contract({
+ id: {
+ is: [ 'string', 'undefined' ],
+ ok: v => /^[a-z0-9-_]+$/i.test(v),
+ msg: 'The option "id" must be a valid alphanumeric id (hyphens and ' +
+ 'underscores are allowed).'
+ },
+ title: {
+ is: [ 'string' ],
+ ok: v => v.length
+ },
+ url: {
+ is: [ 'string' ],
+ ok: v => isLocalURL(v),
+ map: v => v.toString(),
+ msg: 'The option "url" must be a valid local URI.'
+ }
+});
diff --git a/toolkit/jetpack/sdk/ui/sidebar/namespace.js b/toolkit/jetpack/sdk/ui/sidebar/namespace.js
new file mode 100644
index 000000000..d79725d1a
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/sidebar/namespace.js
@@ -0,0 +1,15 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const models = exports.models = new WeakMap();
+const views = exports.views = new WeakMap();
+exports.buttons = new WeakMap();
+
+exports.viewsFor = function viewsFor(sidebar) {
+ return views.get(sidebar);
+};
+exports.modelFor = function modelFor(sidebar) {
+ return models.get(sidebar);
+};
diff --git a/toolkit/jetpack/sdk/ui/sidebar/utils.js b/toolkit/jetpack/sdk/ui/sidebar/utils.js
new file mode 100644
index 000000000..d6145c32e
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/sidebar/utils.js
@@ -0,0 +1,8 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const method = require('../../../method/core');
+
+exports.isShowing = method('isShowing');
diff --git a/toolkit/jetpack/sdk/ui/sidebar/view.js b/toolkit/jetpack/sdk/ui/sidebar/view.js
new file mode 100644
index 000000000..c91e69d3d
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/sidebar/view.js
@@ -0,0 +1,214 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable',
+ 'engines': {
+ 'Firefox': '*'
+ }
+};
+
+const { models, buttons, views, viewsFor, modelFor } = require('./namespace');
+const { isBrowser, getMostRecentBrowserWindow, windows, isWindowPrivate } = require('../../window/utils');
+const { setStateFor } = require('../state');
+const { defer } = require('../../core/promise');
+const { isPrivateBrowsingSupported, data } = require('../../self');
+
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+const WEB_PANEL_BROWSER_ID = 'web-panels-browser';
+
+const resolveURL = (url) => url ? data.url(url) : url;
+
+function create(window, details) {
+ let id = makeID(details.id);
+ let { document } = window;
+
+ if (document.getElementById(id))
+ throw new Error('The ID "' + details.id + '" seems already used.');
+
+ let menuitem = document.createElementNS(XUL_NS, 'menuitem');
+ menuitem.setAttribute('id', id);
+ menuitem.setAttribute('label', details.title);
+ menuitem.setAttribute('sidebarurl', resolveURL(details.sidebarurl));
+ menuitem.setAttribute('checked', 'false');
+ menuitem.setAttribute('type', 'checkbox');
+ menuitem.setAttribute('group', 'sidebar');
+ menuitem.setAttribute('autoCheck', 'false');
+
+ document.getElementById('viewSidebarMenu').appendChild(menuitem);
+
+ return menuitem;
+}
+exports.create = create;
+
+function dispose(menuitem) {
+ menuitem.parentNode.removeChild(menuitem);
+}
+exports.dispose = dispose;
+
+function updateTitle(sidebar, title) {
+ let button = buttons.get(sidebar);
+
+ for (let window of windows(null, { includePrivate: true })) {
+ let { document } = window;
+
+ // update the button
+ if (button) {
+ setStateFor(button, window, { label: title });
+ }
+
+ // update the menuitem
+ let mi = document.getElementById(makeID(sidebar.id));
+ if (mi) {
+ mi.setAttribute('label', title)
+ }
+
+ // update sidebar, if showing
+ if (isSidebarShowing(window, sidebar)) {
+ document.getElementById('sidebar-title').setAttribute('value', title);
+ }
+ }
+}
+exports.updateTitle = updateTitle;
+
+function updateURL(sidebar, url) {
+ let eleID = makeID(sidebar.id);
+
+ url = resolveURL(url);
+
+ for (let window of windows(null, { includePrivate: true })) {
+ // update the menuitem
+ let mi = window.document.getElementById(eleID);
+ if (mi) {
+ mi.setAttribute('sidebarurl', url)
+ }
+
+ // update sidebar, if showing
+ if (isSidebarShowing(window, sidebar)) {
+ showSidebar(window, sidebar, url);
+ }
+ }
+}
+exports.updateURL = updateURL;
+
+function isSidebarShowing(window, sidebar) {
+ let win = window || getMostRecentBrowserWindow();
+
+ // make sure there is a window
+ if (!win) {
+ return false;
+ }
+
+ // make sure there is a sidebar for the window
+ let sb = win.document.getElementById('sidebar');
+ let sidebarTitle = win.document.getElementById('sidebar-title');
+ if (!(sb && sidebarTitle)) {
+ return false;
+ }
+
+ // checks if the sidebar box is hidden
+ let sbb = win.document.getElementById('sidebar-box');
+ if (!sbb || sbb.hidden) {
+ return false;
+ }
+
+ if (sidebarTitle.value == modelFor(sidebar).title) {
+ let url = resolveURL(modelFor(sidebar).url);
+
+ // checks if the sidebar is loading
+ if (win.gWebPanelURI == url) {
+ return true;
+ }
+
+ // checks if the sidebar loaded already
+ let ele = sb.contentDocument && sb.contentDocument.getElementById(WEB_PANEL_BROWSER_ID);
+ if (!ele) {
+ return false;
+ }
+
+ if (ele.getAttribute('cachedurl') == url) {
+ return true;
+ }
+
+ if (ele && ele.contentWindow && ele.contentWindow.location == url) {
+ return true;
+ }
+ }
+
+ // default
+ return false;
+}
+exports.isSidebarShowing = isSidebarShowing;
+
+function showSidebar(window, sidebar, newURL) {
+ window = window || getMostRecentBrowserWindow();
+
+ let { promise, resolve, reject } = defer();
+ let model = modelFor(sidebar);
+
+ if (!newURL && isSidebarShowing(window, sidebar)) {
+ resolve({});
+ }
+ else if (!isPrivateBrowsingSupported && isWindowPrivate(window)) {
+ reject(Error('You cannot show a sidebar on private windows'));
+ }
+ else {
+ sidebar.once('show', resolve);
+
+ let menuitem = window.document.getElementById(makeID(model.id));
+ menuitem.setAttribute('checked', true);
+
+ window.openWebPanel(model.title, resolveURL(newURL || model.url));
+ }
+
+ return promise;
+}
+exports.showSidebar = showSidebar;
+
+
+function hideSidebar(window, sidebar) {
+ window = window || getMostRecentBrowserWindow();
+
+ let { promise, resolve, reject } = defer();
+
+ if (!isSidebarShowing(window, sidebar)) {
+ reject(Error('The sidebar is already hidden'));
+ }
+ else {
+ sidebar.once('hide', resolve);
+
+ // Below was taken from http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#4775
+ // the code for window.todggleSideBar()..
+ let { document } = window;
+ let sidebarEle = document.getElementById('sidebar');
+ let sidebarTitle = document.getElementById('sidebar-title');
+ let sidebarBox = document.getElementById('sidebar-box');
+ let sidebarSplitter = document.getElementById('sidebar-splitter');
+ let commandID = sidebarBox.getAttribute('sidebarcommand');
+ let sidebarBroadcaster = document.getElementById(commandID);
+
+ sidebarBox.hidden = true;
+ sidebarSplitter.hidden = true;
+
+ sidebarEle.setAttribute('src', 'about:blank');
+ //sidebarEle.docShell.createAboutBlankContentViewer(null);
+
+ sidebarBroadcaster.removeAttribute('checked');
+ sidebarBox.setAttribute('sidebarcommand', '');
+ sidebarTitle.value = '';
+ sidebarBox.hidden = true;
+ sidebarSplitter.hidden = true;
+
+ // TODO: perhaps this isn't necessary if the window is not most recent?
+ window.gBrowser.selectedBrowser.focus();
+ }
+
+ return promise;
+}
+exports.hideSidebar = hideSidebar;
+
+function makeID(id) {
+ return 'jetpack-sidebar-' + id;
+}
diff --git a/toolkit/jetpack/sdk/ui/state.js b/toolkit/jetpack/sdk/ui/state.js
new file mode 100644
index 000000000..152ce696d
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/state.js
@@ -0,0 +1,239 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+// The Button module currently supports only Firefox.
+// See: https://bugzilla.mozilla.org/show_bug.cgi?id=jetpack-panel-apps
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '*',
+ 'SeaMonkey': '*',
+ 'Thunderbird': '*'
+ }
+};
+
+const { Ci } = require('chrome');
+
+const events = require('../event/utils');
+const { events: browserEvents } = require('../browser/events');
+const { events: tabEvents } = require('../tab/events');
+const { events: stateEvents } = require('./state/events');
+
+const { windows, isInteractive, getFocusedBrowser } = require('../window/utils');
+const { getActiveTab, getOwnerWindow } = require('../tabs/utils');
+
+const { ignoreWindow } = require('../private-browsing/utils');
+
+const { freeze } = Object;
+const { merge } = require('../util/object');
+const { on, off, emit } = require('../event/core');
+
+const { add, remove, has, clear, iterator } = require('../lang/weak-set');
+const { isNil } = require('../lang/type');
+
+const { viewFor } = require('../view/core');
+
+const components = new WeakMap();
+
+const ERR_UNREGISTERED = 'The state cannot be set or get. ' +
+ 'The object may be not be registered, or may already have been unloaded.';
+
+const ERR_INVALID_TARGET = 'The state cannot be set or get for this target.' +
+ 'Only window, tab and registered component are valid targets.';
+
+const isWindow = thing => thing instanceof Ci.nsIDOMWindow;
+const isTab = thing => thing.tagName && thing.tagName.toLowerCase() === 'tab';
+const isActiveTab = thing => isTab(thing) && thing === getActiveTab(getOwnerWindow(thing));
+const isEnumerable = window => !ignoreWindow(window);
+const browsers = _ =>
+ windows('navigator:browser', { includePrivate: true }).filter(isInteractive);
+const getMostRecentTab = _ => getActiveTab(getFocusedBrowser());
+
+function getStateFor(component, target) {
+ if (!isRegistered(component))
+ throw new Error(ERR_UNREGISTERED);
+
+ if (!components.has(component))
+ return null;
+
+ let states = components.get(component);
+
+ if (target) {
+ if (isTab(target) || isWindow(target) || target === component)
+ return states.get(target) || null;
+ else
+ throw new Error(ERR_INVALID_TARGET);
+ }
+
+ return null;
+}
+exports.getStateFor = getStateFor;
+
+function getDerivedStateFor(component, target) {
+ if (!isRegistered(component))
+ throw new Error(ERR_UNREGISTERED);
+
+ if (!components.has(component))
+ return null;
+
+ let states = components.get(component);
+
+ let componentState = states.get(component);
+ let windowState = null;
+ let tabState = null;
+
+ if (target) {
+ // has a target
+ if (isTab(target)) {
+ windowState = states.get(getOwnerWindow(target), null);
+
+ if (states.has(target)) {
+ // we have a tab state
+ tabState = states.get(target);
+ }
+ }
+ else if (isWindow(target) && states.has(target)) {
+ // we have a window state
+ windowState = states.get(target);
+ }
+ }
+
+ return freeze(merge({}, componentState, windowState, tabState));
+}
+exports.getDerivedStateFor = getDerivedStateFor;
+
+function setStateFor(component, target, state) {
+ if (!isRegistered(component))
+ throw new Error(ERR_UNREGISTERED);
+
+ let isComponentState = target === component;
+ let targetWindows = isWindow(target) ? [target] :
+ isActiveTab(target) ? [getOwnerWindow(target)] :
+ isComponentState ? browsers() :
+ isTab(target) ? [] :
+ null;
+
+ if (!targetWindows)
+ throw new Error(ERR_INVALID_TARGET);
+
+ // initialize the state's map
+ if (!components.has(component))
+ components.set(component, new WeakMap());
+
+ let states = components.get(component);
+
+ if (state === null && !isComponentState) // component state can't be deleted
+ states.delete(target);
+ else {
+ let base = isComponentState ? states.get(target) : null;
+ states.set(target, freeze(merge({}, base, state)));
+ }
+
+ render(component, targetWindows);
+}
+exports.setStateFor = setStateFor;
+
+function render(component, targetWindows) {
+ targetWindows = targetWindows ? [].concat(targetWindows) : browsers();
+
+ for (let window of targetWindows.filter(isEnumerable)) {
+ let tabState = getDerivedStateFor(component, getActiveTab(window));
+
+ emit(stateEvents, 'data', {
+ type: 'render',
+ target: component,
+ window: window,
+ state: tabState
+ });
+
+ }
+}
+exports.render = render;
+
+function properties(contract) {
+ let { rules } = contract;
+ let descriptor = Object.keys(rules).reduce(function(descriptor, name) {
+ descriptor[name] = {
+ get: function() { return getDerivedStateFor(this)[name] },
+ set: function(value) {
+ let changed = {};
+ changed[name] = value;
+
+ setStateFor(this, this, contract(changed));
+ }
+ }
+ return descriptor;
+ }, {});
+
+ return Object.create(Object.prototype, descriptor);
+}
+exports.properties = properties;
+
+function state(contract) {
+ return {
+ state: function state(target, state) {
+ let nativeTarget = target === 'window' ? getFocusedBrowser()
+ : target === 'tab' ? getMostRecentTab()
+ : target === this ? null
+ : viewFor(target);
+
+ if (!nativeTarget && target !== this && !isNil(target))
+ throw new Error(ERR_INVALID_TARGET);
+
+ target = nativeTarget || target;
+
+ // jquery style
+ return arguments.length < 2
+ ? getDerivedStateFor(this, target)
+ : setStateFor(this, target, contract(state))
+ }
+ }
+}
+exports.state = state;
+
+const register = (component, state) => {
+ add(components, component);
+ setStateFor(component, component, state);
+}
+exports.register = register;
+
+const unregister = component => {
+ remove(components, component);
+}
+exports.unregister = unregister;
+
+const isRegistered = component => has(components, component);
+exports.isRegistered = isRegistered;
+
+var tabSelect = events.filter(tabEvents, e => e.type === 'TabSelect');
+var tabClose = events.filter(tabEvents, e => e.type === 'TabClose');
+var windowOpen = events.filter(browserEvents, e => e.type === 'load');
+var windowClose = events.filter(browserEvents, e => e.type === 'close');
+
+var close = events.merge([tabClose, windowClose]);
+var activate = events.merge([windowOpen, tabSelect]);
+
+on(activate, 'data', ({target}) => {
+ let [window, tab] = isWindow(target)
+ ? [target, getActiveTab(target)]
+ : [getOwnerWindow(target), target];
+
+ if (ignoreWindow(window)) return;
+
+ for (let component of iterator(components)) {
+ emit(stateEvents, 'data', {
+ type: 'render',
+ target: component,
+ window: window,
+ state: getDerivedStateFor(component, tab)
+ });
+ }
+});
+
+on(close, 'data', function({target}) {
+ for (let component of iterator(components)) {
+ components.get(component).delete(target);
+ }
+});
diff --git a/toolkit/jetpack/sdk/ui/state/events.js b/toolkit/jetpack/sdk/ui/state/events.js
new file mode 100644
index 000000000..98909656a
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/state/events.js
@@ -0,0 +1,18 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'experimental',
+ 'engines': {
+ 'Firefox': '*',
+ 'SeaMonkey': '*',
+ 'Thunderbird': '*'
+ }
+};
+
+var channel = {};
+
+exports.events = channel;
diff --git a/toolkit/jetpack/sdk/ui/toolbar.js b/toolkit/jetpack/sdk/ui/toolbar.js
new file mode 100644
index 000000000..c1becab2d
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/toolbar.js
@@ -0,0 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "> 28"
+ }
+};
+
+const { Toolbar } = require("./toolbar/model");
+require("./toolbar/view");
+
+exports.Toolbar = Toolbar;
diff --git a/toolkit/jetpack/sdk/ui/toolbar/model.js b/toolkit/jetpack/sdk/ui/toolbar/model.js
new file mode 100644
index 000000000..5c5428606
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/toolbar/model.js
@@ -0,0 +1,151 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "> 28"
+ }
+};
+
+const { Class } = require("../../core/heritage");
+const { EventTarget } = require("../../event/target");
+const { off, setListeners, emit } = require("../../event/core");
+const { Reactor, foldp, merges, send } = require("../../event/utils");
+const { Disposable } = require("../../core/disposable");
+const { InputPort } = require("../../input/system");
+const { OutputPort } = require("../../output/system");
+const { identify } = require("../id");
+const { pairs, object, map, each } = require("../../util/sequence");
+const { patch, diff } = require("diffpatcher/index");
+const { contract } = require("../../util/contract");
+const { id: addonID } = require("../../self");
+
+// Input state is accumulated from the input received form the toolbar
+// view code & local output. Merging local output reflects local state
+// changes without complete roundloop.
+const input = foldp(patch, {}, new InputPort({ id: "toolbar-changed" }));
+const output = new OutputPort({ id: "toolbar-change" });
+
+// Takes toolbar title and normalizes is to an
+// identifier, also prefixes with add-on id.
+const titleToId = title =>
+ ("toolbar-" + addonID + "-" + title).
+ toLowerCase().
+ replace(/\s/g, "-").
+ replace(/[^A-Za-z0-9_\-]/g, "");
+
+const validate = contract({
+ title: {
+ is: ["string"],
+ ok: x => x.length > 0,
+ msg: "The `option.title` string must be provided"
+ },
+ items: {
+ is:["undefined", "object", "array"],
+ msg: "The `options.items` must be iterable sequence of items"
+ },
+ hidden: {
+ is: ["boolean", "undefined"],
+ msg: "The `options.hidden` must be boolean"
+ }
+});
+
+// Toolbars is a mapping between `toolbar.id` & `toolbar` instances,
+// which is used to find intstance for dispatching events.
+var toolbars = new Map();
+
+const Toolbar = Class({
+ extends: EventTarget,
+ implements: [Disposable],
+ initialize: function(params={}) {
+ const options = validate(params);
+ const id = titleToId(options.title);
+
+ if (toolbars.has(id))
+ throw Error("Toolbar with this id already exists: " + id);
+
+ // Set of the items in the toolbar isn't mutable, as a matter of fact
+ // it just defines desired set of items, actual set is under users
+ // control. Conver test to an array and freeze to make sure users won't
+ // try mess with it.
+ const items = Object.freeze(options.items ? [...options.items] : []);
+
+ const initial = {
+ id: id,
+ title: options.title,
+ // By default toolbars are visible when add-on is installed, unless
+ // add-on authors decides it should be hidden. From that point on
+ // user is in control.
+ collapsed: !!options.hidden,
+ // In terms of state only identifiers of items matter.
+ items: items.map(identify)
+ };
+
+ this.id = id;
+ this.items = items;
+
+ toolbars.set(id, this);
+ setListeners(this, params);
+
+ // Send initial state to the host so it can reflect it
+ // into a user interface.
+ send(output, object([id, initial]));
+ },
+
+ get title() {
+ const state = reactor.value[this.id];
+ return state && state.title;
+ },
+ get hidden() {
+ const state = reactor.value[this.id];
+ return state && state.collapsed;
+ },
+
+ destroy: function() {
+ send(output, object([this.id, null]));
+ },
+ // `JSON.stringify` serializes objects based of the return
+ // value of this method. For convinienc we provide this method
+ // to serialize actual state data. Note: items will also be
+ // serialized so they should probably implement `toJSON`.
+ toJSON: function() {
+ return {
+ id: this.id,
+ title: this.title,
+ hidden: this.hidden,
+ items: this.items
+ };
+ }
+});
+exports.Toolbar = Toolbar;
+identify.define(Toolbar, toolbar => toolbar.id);
+
+const dispose = toolbar => {
+ toolbars.delete(toolbar.id);
+ emit(toolbar, "detach");
+ off(toolbar);
+};
+
+const reactor = new Reactor({
+ onStep: (present, past) => {
+ const delta = diff(past, present);
+
+ each(([id, update]) => {
+ const toolbar = toolbars.get(id);
+
+ // Remove
+ if (!update)
+ dispose(toolbar);
+ // Add
+ else if (!past[id])
+ emit(toolbar, "attach");
+ // Update
+ else
+ emit(toolbar, update.collapsed ? "hide" : "show", toolbar);
+ }, pairs(delta));
+ }
+});
+reactor.run(input);
diff --git a/toolkit/jetpack/sdk/ui/toolbar/view.js b/toolkit/jetpack/sdk/ui/toolbar/view.js
new file mode 100644
index 000000000..4ef0c3d46
--- /dev/null
+++ b/toolkit/jetpack/sdk/ui/toolbar/view.js
@@ -0,0 +1,248 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental",
+ "engines": {
+ "Firefox": "> 28"
+ }
+};
+
+const { Cu } = require("chrome");
+const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
+const { subscribe, send, Reactor, foldp, lift, merges } = require("../../event/utils");
+const { InputPort } = require("../../input/system");
+const { OutputPort } = require("../../output/system");
+const { Interactive } = require("../../input/browser");
+const { CustomizationInput } = require("../../input/customizable-ui");
+const { pairs, map, isEmpty, object,
+ each, keys, values } = require("../../util/sequence");
+const { curry, flip } = require("../../lang/functional");
+const { patch, diff } = require("diffpatcher/index");
+const prefs = require("../../preferences/service");
+const { getByOuterId } = require("../../window/utils");
+const { ignoreWindow } = require('../../private-browsing/utils');
+
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+const PREF_ROOT = "extensions.sdk-toolbar-collapsed.";
+
+
+// There are two output ports one for publishing changes that occured
+// and the other for change requests. Later is synchronous and is only
+// consumed here. Note: it needs to be synchronous to avoid race conditions
+// when `collapsed` attribute changes are caused by user interaction and
+// toolbar is destroyed between the ticks.
+const output = new OutputPort({ id: "toolbar-changed" });
+const syncoutput = new OutputPort({ id: "toolbar-change", sync: true });
+
+// Merge disptached changes and recevied changes from models to keep state up to
+// date.
+const Toolbars = foldp(patch, {}, merges([new InputPort({ id: "toolbar-changed" }),
+ new InputPort({ id: "toolbar-change" })]));
+const State = lift((toolbars, windows, customizable) =>
+ ({windows: windows, toolbars: toolbars, customizable: customizable}),
+ Toolbars, Interactive, new CustomizationInput());
+
+// Shared event handler that makes `event.target.parent` collapsed.
+// Used as toolbar's close buttons click handler.
+const collapseToolbar = event => {
+ const toolbar = event.target.parentNode;
+ toolbar.collapsed = true;
+};
+
+const parseAttribute = x =>
+ x === "true" ? true :
+ x === "false" ? false :
+ x === "" ? null :
+ x;
+
+// Shared mutation observer that is used to observe `toolbar` node's
+// attribute mutations. Mutations are aggregated in the `delta` hash
+// and send to `ToolbarStateChanged` channel to let model know state
+// has changed.
+const attributesChanged = mutations => {
+ const delta = mutations.reduce((changes, {attributeName, target}) => {
+ const id = target.id;
+ const field = attributeName === "toolbarname" ? "title" : attributeName;
+ let change = changes[id] || (changes[id] = {});
+ change[field] = parseAttribute(target.getAttribute(attributeName));
+ return changes;
+ }, {});
+
+ // Calculate what are the updates from the current state and if there are
+ // any send them.
+ const updates = diff(reactor.value, patch(reactor.value, delta));
+
+ if (!isEmpty(pairs(updates))) {
+ // TODO: Consider sending sync to make sure that there won't be a new
+ // update doing a delete in the meantime.
+ send(syncoutput, updates);
+ }
+};
+
+
+// Utility function creates `toolbar` with a "close" button and returns
+// it back. In addition it set's up a listener and observer to communicate
+// state changes.
+const addView = curry((options, {document, window}) => {
+ if (ignoreWindow(window))
+ return;
+
+ let view = document.createElementNS(XUL_NS, "toolbar");
+ view.setAttribute("id", options.id);
+ view.setAttribute("collapsed", options.collapsed);
+ view.setAttribute("toolbarname", options.title);
+ view.setAttribute("pack", "end");
+ view.setAttribute("customizable", "false");
+ view.setAttribute("style", "padding: 2px 0; max-height: 40px;");
+ view.setAttribute("mode", "icons");
+ view.setAttribute("iconsize", "small");
+ view.setAttribute("context", "toolbar-context-menu");
+ view.setAttribute("class", "chromeclass-toolbar");
+
+ let label = document.createElementNS(XUL_NS, "label");
+ label.setAttribute("value", options.title);
+ label.setAttribute("collapsed", "true");
+ view.appendChild(label);
+
+ let closeButton = document.createElementNS(XUL_NS, "toolbarbutton");
+ closeButton.setAttribute("id", "close-" + options.id);
+ closeButton.setAttribute("class", "close-icon");
+ closeButton.setAttribute("customizable", false);
+ closeButton.addEventListener("command", collapseToolbar);
+
+ view.appendChild(closeButton);
+
+ // In order to have a close button not costumizable, aligned on the right,
+ // leaving the customizable capabilities of Australis, we need to create
+ // a toolbar inside a toolbar.
+ // This is should be a temporary hack, we should have a proper XBL for toolbar
+ // instead. See:
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=982005
+ let toolbar = document.createElementNS(XUL_NS, "toolbar");
+ toolbar.setAttribute("id", "inner-" + options.id);
+ toolbar.setAttribute("defaultset", options.items.join(","));
+ toolbar.setAttribute("customizable", "true");
+ toolbar.setAttribute("style", "-moz-appearance: none; overflow: hidden");
+ toolbar.setAttribute("mode", "icons");
+ toolbar.setAttribute("iconsize", "small");
+ toolbar.setAttribute("context", "toolbar-context-menu");
+ toolbar.setAttribute("flex", "1");
+
+ view.insertBefore(toolbar, closeButton);
+
+ const observer = new document.defaultView.MutationObserver(attributesChanged);
+ observer.observe(view, { attributes: true,
+ attributeFilter: ["collapsed", "toolbarname"] });
+
+ const toolbox = document.getElementById("navigator-toolbox");
+ toolbox.appendChild(view);
+});
+const viewAdd = curry(flip(addView));
+
+const removeView = curry((id, {document}) => {
+ const view = document.getElementById(id);
+ if (view) view.remove();
+});
+
+const updateView = curry((id, {title, collapsed, isCustomizing}, {document}) => {
+ const view = document.getElementById(id);
+
+ if (!view)
+ return;
+
+ if (title)
+ view.setAttribute("toolbarname", title);
+
+ if (collapsed !== void(0))
+ view.setAttribute("collapsed", Boolean(collapsed));
+
+ if (isCustomizing !== void(0)) {
+ view.querySelector("label").collapsed = !isCustomizing;
+ view.querySelector("toolbar").style.visibility = isCustomizing
+ ? "hidden" : "visible";
+ }
+});
+
+const viewUpdate = curry(flip(updateView));
+
+// Utility function used to register toolbar into CustomizableUI.
+const registerToolbar = state => {
+ // If it's first additon register toolbar as customizableUI component.
+ CustomizableUI.registerArea("inner-" + state.id, {
+ type: CustomizableUI.TYPE_TOOLBAR,
+ legacy: true,
+ defaultPlacements: [...state.items]
+ });
+};
+// Utility function used to unregister toolbar from the CustomizableUI.
+const unregisterToolbar = CustomizableUI.unregisterArea;
+
+const reactor = new Reactor({
+ onStep: (present, past) => {
+ const delta = diff(past, present);
+
+ each(([id, update]) => {
+ // If update is `null` toolbar is removed, in such case
+ // we unregister toolbar and remove it from each window
+ // it was added to.
+ if (update === null) {
+ unregisterToolbar("inner-" + id);
+ each(removeView(id), values(past.windows));
+
+ send(output, object([id, null]));
+ }
+ else if (past.toolbars[id]) {
+ // If `collapsed` state for toolbar was updated, persist
+ // it for a future sessions.
+ if (update.collapsed !== void(0))
+ prefs.set(PREF_ROOT + id, update.collapsed);
+
+ // Reflect update in each window it was added to.
+ each(updateView(id, update), values(past.windows));
+
+ send(output, object([id, update]));
+ }
+ // Hack: Mutation observers are invoked async, which means that if
+ // client does `hide(toolbar)` & then `toolbar.destroy()` by the
+ // time we'll get update for `collapsed` toolbar will be removed.
+ // For now we check if `update.id` is present which will be undefined
+ // in such cases.
+ else if (update.id) {
+ // If it is a new toolbar we create initial state by overriding
+ // `collapsed` filed with value persisted in previous sessions.
+ const state = patch(update, {
+ collapsed: prefs.get(PREF_ROOT + id, update.collapsed),
+ });
+
+ // Register toolbar and add it each window known in the past
+ // (note that new windows if any will be handled in loop below).
+ registerToolbar(state);
+ each(addView(state), values(past.windows));
+
+ send(output, object([state.id, state]));
+ }
+ }, pairs(delta.toolbars));
+
+ // Add views to every window that was added.
+ each(window => {
+ if (window)
+ each(viewAdd(window), values(past.toolbars));
+ }, values(delta.windows));
+
+ each(([id, isCustomizing]) => {
+ each(viewUpdate(getByOuterId(id), {isCustomizing: !!isCustomizing}),
+ keys(present.toolbars));
+
+ }, pairs(delta.customizable))
+ },
+ onEnd: state => {
+ each(id => {
+ unregisterToolbar("inner-" + id);
+ each(removeView(id), values(state.windows));
+ }, keys(state.toolbars));
+ }
+});
+reactor.run(State);
diff --git a/toolkit/jetpack/sdk/uri/resource.js b/toolkit/jetpack/sdk/uri/resource.js
new file mode 100644
index 000000000..8a1dcbf2c
--- /dev/null
+++ b/toolkit/jetpack/sdk/uri/resource.js
@@ -0,0 +1,37 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const {Cc, Ci} = require("chrome");
+const ioService = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+const resourceHandler = ioService.getProtocolHandler("resource").
+ QueryInterface(Ci.nsIResProtocolHandler);
+
+const URI = (uri, base=null) =>
+ ioService.newURI(uri, null, base && URI(base))
+
+const mount = (domain, uri) =>
+ resourceHandler.setSubstitution(domain, ioService.newURI(uri, null, null));
+exports.mount = mount;
+
+const unmount = (domain, uri) =>
+ resourceHandler.setSubstitution(domain, null);
+exports.unmount = unmount;
+
+const domain = 1;
+const path = 2;
+const resolve = (uri) => {
+ const match = /resource\:\/\/([^\/]+)\/{0,1}([\s\S]*)/.exec(uri);
+ const domain = match && match[1];
+ const path = match && match[2];
+ return !match ? null :
+ !resourceHandler.hasSubstitution(domain) ? null :
+ resourceHandler.resolveURI(URI(`/${path}`, `resource://${domain}/`));
+}
+exports.resolve = resolve;
diff --git a/toolkit/jetpack/sdk/url.js b/toolkit/jetpack/sdk/url.js
new file mode 100644
index 000000000..ae16ac4a8
--- /dev/null
+++ b/toolkit/jetpack/sdk/url.js
@@ -0,0 +1,349 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci, Cr, Cu } = require("chrome");
+
+const { Class } = require("./core/heritage");
+const base64 = require("./base64");
+var tlds = Cc["@mozilla.org/network/effective-tld-service;1"]
+ .getService(Ci.nsIEffectiveTLDService);
+
+var ios = Cc['@mozilla.org/network/io-service;1']
+ .getService(Ci.nsIIOService);
+
+var resProt = ios.getProtocolHandler("resource")
+ .QueryInterface(Ci.nsIResProtocolHandler);
+
+var URLParser = Cc["@mozilla.org/network/url-parser;1?auth=no"]
+ .getService(Ci.nsIURLParser);
+
+const { Services } = Cu.import("resource://gre/modules/Services.jsm");
+
+function newURI(uriStr, base) {
+ try {
+ let baseURI = base ? ios.newURI(base, null, null) : null;
+ return ios.newURI(uriStr, null, baseURI);
+ }
+ catch (e) {
+ if (e.result == Cr.NS_ERROR_MALFORMED_URI) {
+ throw new Error("malformed URI: " + uriStr);
+ }
+ if (e.result == Cr.NS_ERROR_FAILURE ||
+ e.result == Cr.NS_ERROR_ILLEGAL_VALUE) {
+ throw new Error("invalid URI: " + uriStr);
+ }
+ }
+}
+
+function resolveResourceURI(uri) {
+ var resolved;
+ try {
+ resolved = resProt.resolveURI(uri);
+ }
+ catch (e) {
+ if (e.result == Cr.NS_ERROR_NOT_AVAILABLE) {
+ throw new Error("resource does not exist: " + uri.spec);
+ }
+ }
+ return resolved;
+}
+
+var fromFilename = exports.fromFilename = function fromFilename(path) {
+ var file = Cc['@mozilla.org/file/local;1']
+ .createInstance(Ci.nsILocalFile);
+ file.initWithPath(path);
+ return ios.newFileURI(file).spec;
+};
+
+var toFilename = exports.toFilename = function toFilename(url) {
+ var uri = newURI(url);
+ if (uri.scheme == "resource")
+ uri = newURI(resolveResourceURI(uri));
+ if (uri.scheme == "chrome") {
+ var channel = ios.newChannelFromURI2(uri,
+ null, // aLoadingNode
+ Services.scriptSecurityManager.getSystemPrincipal(),
+ null, // aTriggeringPrincipal
+ Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+ Ci.nsIContentPolicy.TYPE_OTHER);
+ try {
+ channel = channel.QueryInterface(Ci.nsIFileChannel);
+ return channel.file.path;
+ }
+ catch (e) {
+ if (e.result == Cr.NS_NOINTERFACE) {
+ throw new Error("chrome url isn't on filesystem: " + url);
+ }
+ }
+ }
+ if (uri.scheme == "file") {
+ var file = uri.QueryInterface(Ci.nsIFileURL).file;
+ return file.path;
+ }
+ throw new Error("cannot map to filename: " + url);
+};
+
+function URL(url, base) {
+ if (!(this instanceof URL)) {
+ return new URL(url, base);
+ }
+
+ var uri = newURI(url, base);
+
+ var userPass = null;
+ try {
+ userPass = uri.userPass ? uri.userPass : null;
+ }
+ catch (e) {
+ if (e.result != Cr.NS_ERROR_FAILURE) {
+ throw e;
+ }
+ }
+
+ var host = null;
+ try {
+ host = uri.host;
+ }
+ catch (e) {
+ if (e.result != Cr.NS_ERROR_FAILURE) {
+ throw e;
+ }
+ }
+
+ var port = null;
+ try {
+ port = uri.port == -1 ? null : uri.port;
+ }
+ catch (e) {
+ if (e.result != Cr.NS_ERROR_FAILURE) {
+ throw e;
+ }
+ }
+
+ let fileName = "/";
+ try {
+ fileName = uri.QueryInterface(Ci.nsIURL).fileName;
+ } catch (e) {
+ if (e.result != Cr.NS_NOINTERFACE) {
+ throw e;
+ }
+ }
+
+ let uriData = [uri.path, uri.path.length, {}, {}, {}, {}, {}, {}];
+ URLParser.parsePath.apply(URLParser, uriData);
+ let [{ value: filepathPos }, { value: filepathLen },
+ { value: queryPos }, { value: queryLen },
+ { value: refPos }, { value: refLen }] = uriData.slice(2);
+
+ let hash = uri.ref ? "#" + uri.ref : "";
+ let pathname = uri.path.substr(filepathPos, filepathLen);
+ let search = uri.path.substr(queryPos, queryLen);
+ search = search ? "?" + search : "";
+
+ this.__defineGetter__("fileName", () => fileName);
+ this.__defineGetter__("scheme", () => uri.scheme);
+ this.__defineGetter__("userPass", () => userPass);
+ this.__defineGetter__("host", () => host);
+ this.__defineGetter__("hostname", () => host);
+ this.__defineGetter__("port", () => port);
+ this.__defineGetter__("path", () => uri.path);
+ this.__defineGetter__("pathname", () => pathname);
+ this.__defineGetter__("hash", () => hash);
+ this.__defineGetter__("href", () => uri.spec);
+ this.__defineGetter__("origin", () => uri.prePath);
+ this.__defineGetter__("protocol", () => uri.scheme + ":");
+ this.__defineGetter__("search", () => search);
+
+ Object.defineProperties(this, {
+ toString: {
+ value() {
+ return new String(uri.spec).toString();
+ },
+ enumerable: false
+ },
+ valueOf: {
+ value() {
+ return new String(uri.spec).valueOf();
+ },
+ enumerable: false
+ },
+ toSource: {
+ value() {
+ return new String(uri.spec).toSource();
+ },
+ enumerable: false
+ },
+ // makes more sense to flatten to string, easier to travel across JSON
+ toJSON: {
+ value() {
+ return new String(uri.spec).toString();
+ },
+ enumerable: false
+ }
+ });
+
+ return this;
+};
+
+URL.prototype = Object.create(String.prototype);
+exports.URL = URL;
+
+/**
+ * Parse and serialize a Data URL.
+ *
+ * See: http://tools.ietf.org/html/rfc2397
+ *
+ * Note: Could be extended in the future to decode / encode automatically binary
+ * data.
+ */
+const DataURL = Class({
+
+ get base64 () {
+ return "base64" in this.parameters;
+ },
+
+ set base64 (value) {
+ if (value)
+ this.parameters["base64"] = "";
+ else
+ delete this.parameters["base64"];
+ },
+ /**
+ * Initialize the Data URL object. If a uri is given, it will be parsed.
+ *
+ * @param {String} [uri] The uri to parse
+ *
+ * @throws {URIError} if the Data URL is malformed
+ */
+ initialize: function(uri) {
+ // Due to bug 751834 it is not possible document and define these
+ // properties in the prototype.
+
+ /**
+ * An hashmap that contains the parameters of the Data URL. By default is
+ * empty, that accordingly to RFC is equivalent to {"charset" : "US-ASCII"}
+ */
+ this.parameters = {};
+
+ /**
+ * The MIME type of the data. By default is empty, that accordingly to RFC
+ * is equivalent to "text/plain"
+ */
+ this.mimeType = "";
+
+ /**
+ * The string that represent the data in the Data URL
+ */
+ this.data = "";
+
+ if (typeof uri === "undefined")
+ return;
+
+ uri = String(uri);
+
+ let matches = uri.match(/^data:([^,]*),(.*)$/i);
+
+ if (!matches)
+ throw new URIError("Malformed Data URL: " + uri);
+
+ let mediaType = matches[1].trim();
+
+ this.data = decodeURIComponent(matches[2].trim());
+
+ if (!mediaType)
+ return;
+
+ let parametersList = mediaType.split(";");
+
+ this.mimeType = parametersList.shift().trim();
+
+ for (let parameter, i = 0; parameter = parametersList[i++];) {
+ let pairs = parameter.split("=");
+ let name = pairs[0].trim();
+ let value = pairs.length > 1 ? decodeURIComponent(pairs[1].trim()) : "";
+
+ this.parameters[name] = value;
+ }
+
+ if (this.base64)
+ this.data = base64.decode(this.data);
+
+ },
+
+ /**
+ * Returns the object as a valid Data URL string
+ *
+ * @returns {String} The Data URL
+ */
+ toString : function() {
+ let parametersList = [];
+
+ for (let name in this.parameters) {
+ let encodedParameter = encodeURIComponent(name);
+ let value = this.parameters[name];
+
+ if (value)
+ encodedParameter += "=" + encodeURIComponent(value);
+
+ parametersList.push(encodedParameter);
+ }
+
+ // If there is at least a parameter, add an empty string in order
+ // to start with a `;` on join call.
+ if (parametersList.length > 0)
+ parametersList.unshift("");
+
+ let data = this.base64 ? base64.encode(this.data) : this.data;
+
+ return "data:" +
+ this.mimeType +
+ parametersList.join(";") + "," +
+ encodeURIComponent(data);
+ }
+});
+
+exports.DataURL = DataURL;
+
+var getTLD = exports.getTLD = function getTLD (url) {
+ let uri = newURI(url.toString());
+ let tld = null;
+ try {
+ tld = tlds.getPublicSuffix(uri);
+ }
+ catch (e) {
+ if (e.result != Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS &&
+ e.result != Cr.NS_ERROR_HOST_IS_IP_ADDRESS) {
+ throw e;
+ }
+ }
+ return tld;
+};
+
+var isValidURI = exports.isValidURI = function (uri) {
+ try {
+ newURI(uri);
+ }
+ catch(e) {
+ return false;
+ }
+ return true;
+}
+
+function isLocalURL(url) {
+ if (String.indexOf(url, './') === 0)
+ return true;
+
+ try {
+ return ['resource', 'data', 'chrome'].indexOf(URL(url).scheme) > -1;
+ }
+ catch(e) {}
+
+ return false;
+}
+exports.isLocalURL = isLocalURL;
diff --git a/toolkit/jetpack/sdk/url/utils.js b/toolkit/jetpack/sdk/url/utils.js
new file mode 100644
index 000000000..aa5759204
--- /dev/null
+++ b/toolkit/jetpack/sdk/url/utils.js
@@ -0,0 +1,29 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Cc, Ci, Cr } = require("chrome");
+const IOService = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+const { isValidURI } = require("../url");
+const { method } = require("../../method/core");
+
+function newURI (uri) {
+ if (!isValidURI(uri))
+ throw new Error("malformed URI: " + uri);
+ return IOService.newURI(uri, null, null);
+}
+exports.newURI = newURI;
+
+var getURL = method('sdk/url:getURL');
+getURL.define(String, url => url);
+getURL.define(function (object) {
+ return null;
+});
+exports.getURL = getURL;
diff --git a/toolkit/jetpack/sdk/util/array.js b/toolkit/jetpack/sdk/util/array.js
new file mode 100644
index 000000000..1d61a973e
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/array.js
@@ -0,0 +1,123 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+/**
+ * Returns `true` if given `array` contain given `element` or `false`
+ * otherwise.
+ * @param {Array} array
+ * Target array.
+ * @param {Object|String|Number|Boolean} element
+ * Element being looked up.
+ * @returns {Boolean}
+ */
+var has = exports.has = function has(array, element) {
+ // shorter and faster equivalent of `array.indexOf(element) >= 0`
+ return !!~array.indexOf(element);
+};
+var hasAny = exports.hasAny = function hasAny(array, elements) {
+ if (arguments.length < 2)
+ return false;
+ if (!Array.isArray(elements))
+ elements = [ elements ];
+ return array.some(function (element) {
+ return has(elements, element);
+ });
+};
+
+/**
+ * Adds given `element` to the given `array` if it does not contain it yet.
+ * `true` is returned if element was added otherwise `false` is returned.
+ * @param {Array} array
+ * Target array.
+ * @param {Object|String|Number|Boolean} element
+ * Element to be added.
+ * @returns {Boolean}
+ */
+var add = exports.add = function add(array, element) {
+ var result;
+ if ((result = !has(array, element)))
+ array.push(element);
+
+ return result;
+};
+
+/**
+ * Removes first occurrence of the given `element` from the given `array`. If
+ * `array` does not contain given `element` `false` is returned otherwise
+ * `true` is returned.
+ * @param {Array} array
+ * Target array.
+ * @param {Object|String|Number|Boolean} element
+ * Element to be removed.
+ * @returns {Boolean}
+ */
+exports.remove = function remove(array, element) {
+ var result;
+ if ((result = has(array, element)))
+ array.splice(array.indexOf(element), 1);
+
+ return result;
+};
+
+/**
+ * Produces a duplicate-free version of the given `array`.
+ * @param {Array} array
+ * Source array.
+ * @returns {Array}
+ */
+function unique(array) {
+ return array.reduce(function(result, item) {
+ add(result, item);
+ return result;
+ }, []);
+};
+exports.unique = unique;
+
+/**
+ * Produce an array that contains the union: each distinct element from all
+ * of the passed-in arrays.
+ */
+function union() {
+ return unique(Array.concat.apply(null, arguments));
+};
+exports.union = union;
+
+exports.flatten = function flatten(array){
+ var flat = [];
+ for (var i = 0, l = array.length; i < l; i++) {
+ flat = flat.concat(Array.isArray(array[i]) ? flatten(array[i]) : array[i]);
+ }
+ return flat;
+};
+
+function fromIterator(iterator) {
+ let array = [];
+ if (iterator.__iterator__) {
+ for (let item of iterator)
+ array.push(item);
+ }
+ else {
+ for (let item of iterator)
+ array.push(item);
+ }
+ return array;
+}
+exports.fromIterator = fromIterator;
+
+function find(array, predicate, fallback) {
+ var index = 0;
+ var count = array.length;
+ while (index < count) {
+ var value = array[index];
+ if (predicate(value)) return value;
+ else index = index + 1;
+ }
+ return fallback;
+}
+exports.find = find;
diff --git a/toolkit/jetpack/sdk/util/collection.js b/toolkit/jetpack/sdk/util/collection.js
new file mode 100644
index 000000000..194a29470
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/collection.js
@@ -0,0 +1,115 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+exports.Collection = Collection;
+
+/**
+ * Adds a collection property to the given object. Setting the property to a
+ * scalar value empties the collection and adds the value. Setting it to an
+ * array empties the collection and adds all the items in the array.
+ *
+ * @param obj
+ * The property will be defined on this object.
+ * @param propName
+ * The name of the property.
+ * @param array
+ * If given, this will be used as the collection's backing array.
+ */
+exports.addCollectionProperty = function addCollProperty(obj, propName, array) {
+ array = array || [];
+ let publicIface = new Collection(array);
+
+ Object.defineProperty(obj, propName, {
+ configurable: true,
+ enumerable: true,
+
+ set: function set(itemOrItems) {
+ array.splice(0, array.length);
+ publicIface.add(itemOrItems);
+ },
+
+ get: function get() {
+ return publicIface;
+ }
+ });
+};
+
+/**
+ * A collection is ordered, like an array, but its items are unique, like a set.
+ *
+ * @param array
+ * The collection is backed by an array. If this is given, it will be
+ * used as the backing array. This way the caller can fully control the
+ * collection. Otherwise a new empty array will be used, and no one but
+ * the collection will have access to it.
+ */
+function Collection(array) {
+ array = array || [];
+
+ /**
+ * Provides iteration over the collection. Items are yielded in the order
+ * they were added.
+ */
+ this.__iterator__ = function Collection___iterator__() {
+ let items = array.slice();
+ for (let i = 0; i < items.length; i++)
+ yield items[i];
+ };
+
+ /**
+ * The number of items in the collection.
+ */
+ this.__defineGetter__("length", function Collection_get_length() {
+ return array.length;
+ });
+
+ /**
+ * Adds a single item or an array of items to the collection. Any items
+ * already contained in the collection are ignored.
+ *
+ * @param itemOrItems
+ * An item or array of items.
+ * @return The collection.
+ */
+ this.add = function Collection_add(itemOrItems) {
+ let items = toArray(itemOrItems);
+ for (let i = 0; i < items.length; i++) {
+ let item = items[i];
+ if (array.indexOf(item) < 0)
+ array.push(item);
+ }
+ return this;
+ };
+
+ /**
+ * Removes a single item or an array of items from the collection. Any items
+ * not contained in the collection are ignored.
+ *
+ * @param itemOrItems
+ * An item or array of items.
+ * @return The collection.
+ */
+ this.remove = function Collection_remove(itemOrItems) {
+ let items = toArray(itemOrItems);
+ for (let i = 0; i < items.length; i++) {
+ let idx = array.indexOf(items[i]);
+ if (idx >= 0)
+ array.splice(idx, 1);
+ }
+ return this;
+ };
+};
+
+function toArray(itemOrItems) {
+ let isArr = itemOrItems &&
+ itemOrItems.constructor &&
+ itemOrItems.constructor.name === "Array";
+ return isArr ? itemOrItems : [itemOrItems];
+}
diff --git a/toolkit/jetpack/sdk/util/contract.js b/toolkit/jetpack/sdk/util/contract.js
new file mode 100644
index 000000000..c689ea601
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/contract.js
@@ -0,0 +1,55 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { validateOptions: valid } = require("../deprecated/api-utils");
+const method = require("method/core");
+
+// Function takes property validation rules and returns function that given
+// an `options` object will return validated / normalized options back. If
+// option(s) are invalid validator will throw exception described by rules.
+// Returned will also have contain `rules` property with a given validation
+// rules and `properties` function that can be used to generate validated
+// property getter and setters can be mixed into prototype. For more details
+// see `properties` function below.
+function contract(rules) {
+ const validator = (instance, options) => {
+ return valid(options || instance || {}, rules);
+ };
+ validator.rules = rules
+ validator.properties = function(modelFor) {
+ return properties(modelFor, rules);
+ }
+ return validator;
+}
+exports.contract = contract
+
+// Function takes `modelFor` instance state model accessor functions and
+// a property validation rules and generates object with getters and setters
+// that can be mixed into prototype. Property accessors update model for the
+// given instance. If you wish to react to property updates you can always
+// override setters to put specific logic.
+function properties(modelFor, rules) {
+ let descriptor = Object.keys(rules).reduce(function(descriptor, name) {
+ descriptor[name] = {
+ get: function() { return modelFor(this)[name] },
+ set: function(value) {
+ let change = {};
+ change[name] = value;
+ modelFor(this)[name] = valid(change, rules)[name];
+ }
+ }
+ return descriptor
+ }, {});
+ return Object.create(Object.prototype, descriptor);
+}
+exports.properties = properties;
+
+const validate = method("contract/validate");
+exports.validate = validate;
diff --git a/toolkit/jetpack/sdk/util/deprecate.js b/toolkit/jetpack/sdk/util/deprecate.js
new file mode 100644
index 000000000..40f236de5
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/deprecate.js
@@ -0,0 +1,40 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { get, format } = require("../console/traceback");
+const { get: getPref } = require("../preferences/service");
+const PREFERENCE = "devtools.errorconsole.deprecation_warnings";
+
+function deprecateUsage(msg) {
+ // Print caller stacktrace in order to help figuring out which code
+ // does use deprecated thing
+ let stack = get().slice(2);
+
+ if (getPref(PREFERENCE))
+ console.error("DEPRECATED: " + msg + "\n" + format(stack));
+}
+exports.deprecateUsage = deprecateUsage;
+
+function deprecateFunction(fun, msg) {
+ return function deprecated() {
+ deprecateUsage(msg);
+ return fun.apply(this, arguments);
+ };
+}
+exports.deprecateFunction = deprecateFunction;
+
+function deprecateEvent(fun, msg, evtTypes) {
+ return function deprecateEvent(evtType) {
+ if (evtTypes.indexOf(evtType) >= 0)
+ deprecateUsage(msg);
+ return fun.apply(this, arguments);
+ };
+}
+exports.deprecateEvent = deprecateEvent;
diff --git a/toolkit/jetpack/sdk/util/dispatcher.js b/toolkit/jetpack/sdk/util/dispatcher.js
new file mode 100644
index 000000000..67d29dfed
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/dispatcher.js
@@ -0,0 +1,54 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const method = require("method/core");
+
+// Utility function that is just an enhancement over `method` to
+// allow predicate based dispatch in addition to polymorphic
+// dispatch. Unfortunately polymorphic dispatch does not quite
+// cuts it in the world of XPCOM where no types / classes exist
+// and all the XUL nodes share same type / prototype.
+// Probably this is more generic and belongs some place else, but
+// we can move it later once this will be relevant.
+var dispatcher = hint => {
+ const base = method(hint);
+ // Make a map for storing predicate, implementation mappings.
+ let implementations = new Map();
+
+ // Dispatcher function goes through `predicate, implementation`
+ // pairs to find predicate that matches first argument and
+ // returns application of arguments on the associated
+ // `implementation`. If no matching predicate is found delegates
+ // to a `base` polymorphic function.
+ let dispatch = (value, ...rest) => {
+ for (let [predicate, implementation] of implementations) {
+ if (predicate(value))
+ return implementation(value, ...rest);
+ }
+
+ return base(value, ...rest);
+ };
+
+ // Expose base API.
+ dispatch.define = base.define;
+ dispatch.implement = base.implement;
+ dispatch.toString = base.toString;
+
+ // Add a `when` function to allow extending function via
+ // predicates.
+ dispatch.when = (predicate, implementation) => {
+ if (implementations.has(predicate))
+ throw TypeError("Already implemented for the given predicate");
+ implementations.set(predicate, implementation);
+ };
+
+ return dispatch;
+};
+
+exports.dispatcher = dispatcher;
diff --git a/toolkit/jetpack/sdk/util/list.js b/toolkit/jetpack/sdk/util/list.js
new file mode 100644
index 000000000..6d7d2dea9
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/list.js
@@ -0,0 +1,90 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+const { Class } = require('../core/heritage');
+const listNS = require('../core/namespace').ns();
+
+const listOptions = {
+ /**
+ * List constructor can take any number of element to populate itself.
+ * @params {Object|String|Number} element
+ * @example
+ * List(1,2,3).length == 3 // true
+ */
+ initialize: function List() {
+ listNS(this).keyValueMap = [];
+
+ for (let i = 0, ii = arguments.length; i < ii; i++)
+ addListItem(this, arguments[i]);
+ },
+ /**
+ * Number of elements in this list.
+ * @type {Number}
+ */
+ get length() {
+ return listNS(this).keyValueMap.length;
+ },
+ /**
+ * Returns a string representing this list.
+ * @returns {String}
+ */
+ toString: function toString() {
+ return 'List(' + listNS(this).keyValueMap + ')';
+ },
+ /**
+ * Custom iterator providing `List`s enumeration behavior.
+ * We cant reuse `_iterator` that is defined by `Iterable` since it provides
+ * iteration in an arbitrary order.
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Statements/for...in
+ * @param {Boolean} onKeys
+ */
+ __iterator__: function __iterator__(onKeys, onKeyValue) {
+ let array = listNS(this).keyValueMap.slice(0),
+ i = -1;
+ for (let element of array)
+ yield onKeyValue ? [++i, element] : onKeys ? ++i : element;
+ },
+};
+listOptions[Symbol.iterator] = function iterator() {
+ return listNS(this).keyValueMap.slice(0)[Symbol.iterator]();
+};
+const List = Class(listOptions);
+exports.List = List;
+
+function addListItem(that, value) {
+ let list = listNS(that).keyValueMap,
+ index = list.indexOf(value);
+
+ if (-1 === index) {
+ try {
+ that[that.length] = value;
+ }
+ catch (e) {}
+ list.push(value);
+ }
+}
+exports.addListItem = addListItem;
+
+function removeListItem(that, element) {
+ let list = listNS(that).keyValueMap,
+ index = list.indexOf(element);
+
+ if (0 <= index) {
+ list.splice(index, 1);
+ try {
+ for (let length = list.length; index < length; index++)
+ that[index] = list[index];
+ that[list.length] = undefined;
+ }
+ catch(e){}
+ }
+}
+exports.removeListItem = removeListItem;
+
+exports.listNS = listNS;
diff --git a/toolkit/jetpack/sdk/util/match-pattern.js b/toolkit/jetpack/sdk/util/match-pattern.js
new file mode 100644
index 000000000..a0eb88b49
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/match-pattern.js
@@ -0,0 +1,113 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { URL } = require('../url');
+const cache = {};
+
+function MatchPattern(pattern) {
+ if (cache[pattern]) return cache[pattern];
+
+ if (typeof pattern.test == "function") {
+ // For compatibility with -moz-document rules, we require the RegExp's
+ // global, ignoreCase, and multiline flags to be set to false.
+ if (pattern.global) {
+ throw new Error("A RegExp match pattern cannot be set to `global` " +
+ "(i.e. //g).");
+ }
+ if (pattern.multiline) {
+ throw new Error("A RegExp match pattern cannot be set to `multiline` " +
+ "(i.e. //m).");
+ }
+
+ this.regexp = pattern;
+ }
+ else {
+ let firstWildcardPosition = pattern.indexOf("*");
+ let lastWildcardPosition = pattern.lastIndexOf("*");
+ if (firstWildcardPosition != lastWildcardPosition)
+ throw new Error("There can be at most one '*' character in a wildcard.");
+
+ if (firstWildcardPosition == 0) {
+ if (pattern.length == 1)
+ this.anyWebPage = true;
+ else if (pattern[1] != ".")
+ throw new Error("Expected a *.<domain name> string, got: " + pattern);
+ else
+ this.domain = pattern.substr(2);
+ }
+ else {
+ if (pattern.indexOf(":") == -1) {
+ throw new Error("When not using *.example.org wildcard, the string " +
+ "supplied is expected to be either an exact URL to " +
+ "match or a URL prefix. The provided string ('" +
+ pattern + "') is unlikely to match any pages.");
+ }
+
+ if (firstWildcardPosition == -1)
+ this.exactURL = pattern;
+ else if (firstWildcardPosition == pattern.length - 1)
+ this.urlPrefix = pattern.substr(0, pattern.length - 1);
+ else {
+ throw new Error("The provided wildcard ('" + pattern + "') has a '*' " +
+ "in an unexpected position. It is expected to be the " +
+ "first or the last character in the wildcard.");
+ }
+ }
+ }
+
+ cache[pattern] = this;
+}
+
+MatchPattern.prototype = {
+ test: function MatchPattern_test(urlStr) {
+ try {
+ var url = URL(urlStr);
+ }
+ catch (err) {
+ return false;
+ }
+
+ // Test the URL against a RegExp pattern. For compatibility with
+ // -moz-document rules, we require the RegExp to match the entire URL,
+ // so we not only test for a match, we also make sure the matched string
+ // is the entire URL string.
+ //
+ // Assuming most URLs don't match most match patterns, we call `test` for
+ // speed when determining whether or not the URL matches, then call `exec`
+ // for the small subset that match to make sure the entire URL matches.
+ if (this.regexp && this.regexp.test(urlStr) &&
+ this.regexp.exec(urlStr)[0] == urlStr)
+ return true;
+
+ if (this.anyWebPage && /^(https?|ftp)$/.test(url.scheme))
+ return true;
+
+ if (this.exactURL && this.exactURL == urlStr)
+ return true;
+
+ // Tests the urlStr against domain and check if
+ // wildcard submitted (*.domain.com), it only allows
+ // subdomains (sub.domain.com) or from the root (http://domain.com)
+ // and reject non-matching domains (otherdomain.com)
+ // bug 856913
+ if (this.domain && url.host &&
+ (url.host === this.domain ||
+ url.host.slice(-this.domain.length - 1) === "." + this.domain))
+ return true;
+
+ if (this.urlPrefix && 0 == urlStr.indexOf(this.urlPrefix))
+ return true;
+
+ return false;
+ },
+
+ toString: () => '[object MatchPattern]'
+};
+
+exports.MatchPattern = MatchPattern;
diff --git a/toolkit/jetpack/sdk/util/object.js b/toolkit/jetpack/sdk/util/object.js
new file mode 100644
index 000000000..9d202bb51
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/object.js
@@ -0,0 +1,104 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { flatten } = require('./array');
+
+/**
+ * Merges all the properties of all arguments into first argument. If two or
+ * more argument objects have own properties with the same name, the property
+ * is overridden, with precedence from right to left, implying, that properties
+ * of the object on the left are overridden by a same named property of the
+ * object on the right.
+ *
+ * Any argument given with "falsy" value - commonly `null` and `undefined` in
+ * case of objects - are skipped.
+ *
+ * @examples
+ * var a = { bar: 0, a: 'a' }
+ * var b = merge(a, { foo: 'foo', bar: 1 }, { foo: 'bar', name: 'b' });
+ * b === a // true
+ * b.a // 'a'
+ * b.foo // 'bar'
+ * b.bar // 1
+ * b.name // 'b'
+ */
+function merge(source) {
+ let descriptor = {};
+
+ // `Boolean` converts the first parameter to a boolean value. Any object is
+ // converted to `true` where `null` and `undefined` becames `false`. Therefore
+ // the `filter` method will keep only objects that are defined and not null.
+ Array.slice(arguments, 1).filter(Boolean).forEach(function onEach(properties) {
+ getOwnPropertyIdentifiers(properties).forEach(function(name) {
+ descriptor[name] = Object.getOwnPropertyDescriptor(properties, name);
+ });
+ });
+ return Object.defineProperties(source, descriptor);
+}
+exports.merge = merge;
+
+/**
+ * Returns an object that inherits from the first argument and contains all the
+ * properties from all following arguments.
+ * `extend(source1, source2, source3)` is equivalent of
+ * `merge(Object.create(source1), source2, source3)`.
+ */
+function extend(source) {
+ let rest = Array.slice(arguments, 1);
+ rest.unshift(Object.create(source));
+ return merge.apply(null, rest);
+}
+exports.extend = extend;
+
+function has(obj, key) {
+ return obj.hasOwnProperty(key);
+}
+exports.has = has;
+
+function each(obj, fn) {
+ for (let key in obj) has(obj, key) && fn(obj[key], key, obj);
+}
+exports.each = each;
+
+/**
+ * Like `merge`, except no property descriptors are manipulated, for use
+ * with platform objects. Identical to underscore's `extend`. Useful for
+ * merging XPCOM objects
+ */
+function safeMerge(source) {
+ Array.slice(arguments, 1).forEach(function onEach (obj) {
+ for (let prop in obj) source[prop] = obj[prop];
+ });
+ return source;
+}
+exports.safeMerge = safeMerge;
+
+/*
+ * Returns a copy of the object without omitted properties
+ */
+function omit(source, ...values) {
+ let copy = {};
+ let keys = flatten(values);
+ for (let prop in source)
+ if (!~keys.indexOf(prop))
+ copy[prop] = source[prop];
+ return copy;
+}
+exports.omit = omit;
+
+// get object's own property Symbols and/or Names, including nonEnumerables by default
+function getOwnPropertyIdentifiers(object, options = { names: true, symbols: true, nonEnumerables: true }) {
+ const symbols = !options.symbols ? [] :
+ Object.getOwnPropertySymbols(object);
+ const names = !options.names ? [] :
+ options.nonEnumerables ? Object.getOwnPropertyNames(object) :
+ Object.keys(object);
+ return [...names, ...symbols];
+}
+exports.getOwnPropertyIdentifiers = getOwnPropertyIdentifiers;
diff --git a/toolkit/jetpack/sdk/util/rules.js b/toolkit/jetpack/sdk/util/rules.js
new file mode 100644
index 000000000..98e3109b0
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/rules.js
@@ -0,0 +1,53 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Class } = require('../core/heritage');
+const { MatchPattern } = require('./match-pattern');
+const { emit } = require('../event/core');
+const { EventTarget } = require('../event/target');
+const { List, addListItem, removeListItem } = require('./list');
+
+// Should deprecate usage of EventEmitter/compose
+const Rules = Class({
+ implements: [
+ EventTarget,
+ List
+ ],
+ add: function(...rules) {
+ return [].concat(rules).forEach(function onAdd(rule) {
+ addListItem(this, rule);
+ emit(this, 'add', rule);
+ }, this);
+ },
+ remove: function(...rules) {
+ return [].concat(rules).forEach(function onRemove(rule) {
+ removeListItem(this, rule);
+ emit(this, 'remove', rule);
+ }, this);
+ },
+ get: function(rule) {
+ let found = false;
+ for (let i in this) if (this[i] === rule) found = true;
+ return found;
+ },
+ // Returns true if uri matches atleast one stored rule
+ matchesAny: function(uri) {
+ return !!filterMatches(this, uri).length;
+ },
+ toString: () => '[object Rules]'
+});
+exports.Rules = Rules;
+
+function filterMatches(instance, uri) {
+ let matches = [];
+ for (let i in instance) {
+ if (new MatchPattern(instance[i]).test(uri)) matches.push(instance[i]);
+ }
+ return matches;
+}
diff --git a/toolkit/jetpack/sdk/util/sequence.js b/toolkit/jetpack/sdk/util/sequence.js
new file mode 100644
index 000000000..28e3de255
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/sequence.js
@@ -0,0 +1,593 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+// Disclamer:
+// In this module we'll have some common argument / variable names
+// to hint their type or behavior.
+//
+// - `f` stands for "function" that is intended to be side effect
+// free.
+// - `p` stands for "predicate" that is function which returns logical
+// true or false and is intended to be side effect free.
+// - `x` / `y` single item of the sequence.
+// - `xs` / `ys` sequence of `x` / `y` items where `x` / `y` signifies
+// type of the items in sequence, so sequence is not of the same item.
+// - `_` used for argument(s) or variable(s) who's values are ignored.
+
+const { complement, flip, identity } = require("../lang/functional");
+const { isArray, isArguments, isMap, isSet, isGenerator,
+ isString, isBoolean, isNumber } = require("../lang/type");
+
+const Sequence = function Sequence(iterator) {
+ if (!isGenerator(iterator)) {
+ throw TypeError("Expected generator argument");
+ }
+
+ this[Symbol.iterator] = iterator;
+};
+exports.Sequence = Sequence;
+
+const polymorphic = dispatch => x =>
+ x === null ? dispatch.null(null) :
+ x === void(0) ? dispatch.void(void(0)) :
+ isArray(x) ? (dispatch.array || dispatch.indexed)(x) :
+ isString(x) ? (dispatch.string || dispatch.indexed)(x) :
+ isArguments(x) ? (dispatch.arguments || dispatch.indexed)(x) :
+ isMap(x) ? dispatch.map(x) :
+ isSet(x) ? dispatch.set(x) :
+ isNumber(x) ? dispatch.number(x) :
+ isBoolean(x) ? dispatch.boolean(x) :
+ dispatch.default(x);
+
+const nogen = function*() {};
+const empty = () => new Sequence(nogen);
+exports.empty = empty;
+
+const seq = polymorphic({
+ null: empty,
+ void: empty,
+ array: identity,
+ string: identity,
+ arguments: identity,
+ map: identity,
+ set: identity,
+ default: x => x instanceof Sequence ? x : new Sequence(x)
+});
+exports.seq = seq;
+
+// Function to cast seq to string.
+const string = (...etc) => "".concat(...etc);
+exports.string = string;
+
+// Function for casting seq to plain object.
+const object = (...pairs) => {
+ let result = {};
+ for (let [key, value] of pairs)
+ result[key] = value;
+
+ return result;
+};
+exports.object = object;
+
+// Takes `getEnumerator` function that returns `nsISimpleEnumerator`
+// and creates lazy sequence of it's items. Note that function does
+// not take `nsISimpleEnumerator` itslef because that would allow
+// single iteration, which would not be consistent with rest of the
+// lazy sequences.
+const fromEnumerator = getEnumerator => seq(function* () {
+ const enumerator = getEnumerator();
+ while (enumerator.hasMoreElements())
+ yield enumerator.getNext();
+});
+exports.fromEnumerator = fromEnumerator;
+
+// Takes `object` and returns lazy sequence of own `[key, value]`
+// pairs (does not include inherited and non enumerable keys).
+const pairs = polymorphic({
+ null: empty,
+ void: empty,
+ map: identity,
+ indexed: indexed => seq(function* () {
+ const count = indexed.length;
+ let index = 0;
+ while (index < count) {
+ yield [index, indexed[index]];
+ index = index + 1;
+ }
+ }),
+ default: object => seq(function* () {
+ for (let key of Object.keys(object))
+ yield [key, object[key]];
+ })
+});
+exports.pairs = pairs;
+
+const names = polymorphic({
+ null: empty,
+ void: empty,
+ default: object => seq(function*() {
+ for (let name of Object.getOwnPropertyNames(object)) {
+ yield name;
+ }
+ })
+});
+exports.names = names;
+
+const symbols = polymorphic({
+ null: empty,
+ void: empty,
+ default: object => seq(function* () {
+ for (let symbol of Object.getOwnPropertySymbols(object)) {
+ yield symbol;
+ }
+ })
+});
+exports.symbols = symbols;
+
+const keys = polymorphic({
+ null: empty,
+ void: empty,
+ indexed: indexed => seq(function* () {
+ const count = indexed.length;
+ let index = 0;
+ while (index < count) {
+ yield index;
+ index = index + 1;
+ }
+ }),
+ map: map => seq(function* () {
+ for (let [key, _] of map)
+ yield key;
+ }),
+ default: object => seq(function* () {
+ for (let key of Object.keys(object))
+ yield key;
+ })
+});
+exports.keys = keys;
+
+
+const values = polymorphic({
+ null: empty,
+ void: empty,
+ set: identity,
+ indexed: indexed => seq(function* () {
+ const count = indexed.length;
+ let index = 0;
+ while (index < count) {
+ yield indexed[index];
+ index = index + 1;
+ }
+ }),
+ map: map => seq(function* () {
+ for (let [_, value] of map) yield value;
+ }),
+ default: object => seq(function* () {
+ for (let key of Object.keys(object)) yield object[key];
+ })
+});
+exports.values = values;
+
+
+
+// Returns a lazy sequence of `x`, `f(x)`, `f(f(x))` etc.
+// `f` must be free of side-effects. Note that returned
+// sequence is infinite so it must be consumed partially.
+//
+// Implements clojure iterate:
+// http://clojuredocs.org/clojure_core/clojure.core/iterate
+const iterate = (f, x) => seq(function* () {
+ let state = x;
+ while (true) {
+ yield state;
+ state = f(state);
+ }
+});
+exports.iterate = iterate;
+
+// Returns a lazy sequence of the items in sequence for which `p(item)`
+// returns `true`. `p` must be free of side-effects.
+//
+// Implements clojure filter:
+// http://clojuredocs.org/clojure_core/clojure.core/filter
+const filter = (p, sequence) => seq(function* () {
+ if (sequence !== null && sequence !== void(0)) {
+ for (let item of sequence) {
+ if (p(item))
+ yield item;
+ }
+ }
+});
+exports.filter = filter;
+
+// Returns a lazy sequence consisting of the result of applying `f` to the
+// set of first items of each sequence, followed by applying f to the set
+// of second items in each sequence, until any one of the sequences is
+// exhausted. Any remaining items in other sequences are ignored. Function
+// `f` should accept number-of-sequences arguments.
+//
+// Implements clojure map:
+// http://clojuredocs.org/clojure_core/clojure.core/map
+const map = (f, ...sequences) => seq(function* () {
+ const count = sequences.length;
+ // Optimize a single sequence case
+ if (count === 1) {
+ let [sequence] = sequences;
+ if (sequence !== null && sequence !== void(0)) {
+ for (let item of sequence)
+ yield f(item);
+ }
+ }
+ else {
+ // define args array that will be recycled on each
+ // step to aggregate arguments to be passed to `f`.
+ let args = [];
+ // define inputs to contain started generators.
+ let inputs = [];
+
+ let index = 0;
+ while (index < count) {
+ inputs[index] = sequences[index][Symbol.iterator]();
+ index = index + 1;
+ }
+
+ // Run loop yielding of applying `f` to the set of
+ // items at each step until one of the `inputs` is
+ // exhausted.
+ let done = false;
+ while (!done) {
+ let index = 0;
+ let value = void(0);
+ while (index < count && !done) {
+ ({ done, value } = inputs[index].next());
+
+ // If input is not exhausted yet store value in args.
+ if (!done) {
+ args[index] = value;
+ index = index + 1;
+ }
+ }
+
+ // If none of the inputs is exhasted yet, `args` contain items
+ // from each input so we yield application of `f` over them.
+ if (!done)
+ yield f(...args);
+ }
+ }
+});
+exports.map = map;
+
+// Returns a lazy sequence of the intermediate values of the reduction (as
+// per reduce) of sequence by `f`, starting with `initial` value if provided.
+//
+// Implements clojure reductions:
+// http://clojuredocs.org/clojure_core/clojure.core/reductions
+const reductions = (...params) => {
+ const count = params.length;
+ let hasInitial = false;
+ let f, initial, source;
+ if (count === 2) {
+ [f, source] = params;
+ }
+ else if (count === 3) {
+ [f, initial, source] = params;
+ hasInitial = true;
+ }
+ else {
+ throw Error("Invoked with wrong number of arguments: " + count);
+ }
+
+ const sequence = seq(source);
+
+ return seq(function* () {
+ let started = hasInitial;
+ let result = void(0);
+
+ // If initial is present yield it.
+ if (hasInitial)
+ yield (result = initial);
+
+ // For each item of the sequence accumulate new result.
+ for (let item of sequence) {
+ // If nothing has being yield yet set result to first
+ // item and yield it.
+ if (!started) {
+ started = true;
+ yield (result = item);
+ }
+ // Otherwise accumulate new result and yield it.
+ else {
+ yield (result = f(result, item));
+ }
+ }
+
+ // If nothing has being yield yet it's empty sequence and no
+ // `initial` was provided in which case we need to yield `f()`.
+ if (!started)
+ yield f();
+ });
+};
+exports.reductions = reductions;
+
+// `f` should be a function of 2 arguments. If `initial` is not supplied,
+// returns the result of applying `f` to the first 2 items in sequence, then
+// applying `f` to that result and the 3rd item, etc. If sequence contains no
+// items, `f` must accept no arguments as well, and reduce returns the
+// result of calling f with no arguments. If sequence has only 1 item, it
+// is returned and `f` is not called. If `initial` is supplied, returns the
+// result of applying `f` to `initial` and the first item in sequence, then
+// applying `f` to that result and the 2nd item, etc. If sequence contains no
+// items, returns `initial` and `f` is not called.
+//
+// Implements clojure reduce:
+// http://clojuredocs.org/clojure_core/clojure.core/reduce
+const reduce = (...args) => {
+ const xs = reductions(...args);
+ let x;
+ for (x of xs) void(0);
+ return x;
+};
+exports.reduce = reduce;
+
+const each = (f, sequence) => {
+ for (let x of seq(sequence)) void(f(x));
+};
+exports.each = each;
+
+
+const inc = x => x + 1;
+// Returns the number of items in the sequence. `count(null)` && `count()`
+// returns `0`. Also works on strings, arrays, Maps & Sets.
+
+// Implements clojure count:
+// http://clojuredocs.org/clojure_core/clojure.core/count
+const count = polymorphic({
+ null: _ => 0,
+ void: _ => 0,
+ indexed: indexed => indexed.length,
+ map: map => map.size,
+ set: set => set.size,
+ default: xs => reduce(inc, 0, xs)
+});
+exports.count = count;
+
+// Returns `true` if sequence has no items.
+
+// Implements clojure empty?:
+// http://clojuredocs.org/clojure_core/clojure.core/empty_q
+const isEmpty = sequence => {
+ // Treat `null` and `undefined` as empty sequences.
+ if (sequence === null || sequence === void(0))
+ return true;
+
+ // If contains any item non empty so return `false`.
+ for (let _ of sequence)
+ return false;
+
+ // If has not returned yet, there was nothing to iterate
+ // so it's empty.
+ return true;
+};
+exports.isEmpty = isEmpty;
+
+const and = (a, b) => a && b;
+
+// Returns true if `p(x)` is logical `true` for every `x` in sequence, else
+// `false`.
+//
+// Implements clojure every?:
+// http://clojuredocs.org/clojure_core/clojure.core/every_q
+const isEvery = (p, sequence) => {
+ if (sequence !== null && sequence !== void(0)) {
+ for (let item of sequence) {
+ if (!p(item))
+ return false;
+ }
+ }
+ return true;
+};
+exports.isEvery = isEvery;
+
+// Returns the first logical true value of (p x) for any x in sequence,
+// else `null`.
+//
+// Implements clojure some:
+// http://clojuredocs.org/clojure_core/clojure.core/some
+const some = (p, sequence) => {
+ if (sequence !== null && sequence !== void(0)) {
+ for (let item of sequence) {
+ if (p(item))
+ return true;
+ }
+ }
+ return null;
+};
+exports.some = some;
+
+// Returns a lazy sequence of the first `n` items in sequence, or all items if
+// there are fewer than `n`.
+//
+// Implements clojure take:
+// http://clojuredocs.org/clojure_core/clojure.core/take
+const take = (n, sequence) => n <= 0 ? empty() : seq(function* () {
+ let count = n;
+ for (let item of sequence) {
+ yield item;
+ count = count - 1;
+ if (count === 0) break;
+ }
+});
+exports.take = take;
+
+// Returns a lazy sequence of successive items from sequence while
+// `p(item)` returns `true`. `p` must be free of side-effects.
+//
+// Implements clojure take-while:
+// http://clojuredocs.org/clojure_core/clojure.core/take-while
+const takeWhile = (p, sequence) => seq(function* () {
+ for (let item of sequence) {
+ if (!p(item))
+ break;
+
+ yield item;
+ }
+});
+exports.takeWhile = takeWhile;
+
+// Returns a lazy sequence of all but the first `n` items in
+// sequence.
+//
+// Implements clojure drop:
+// http://clojuredocs.org/clojure_core/clojure.core/drop
+const drop = (n, sequence) => seq(function* () {
+ if (sequence !== null && sequence !== void(0)) {
+ let count = n;
+ for (let item of sequence) {
+ if (count > 0)
+ count = count - 1;
+ else
+ yield item;
+ }
+ }
+});
+exports.drop = drop;
+
+// Returns a lazy sequence of the items in sequence starting from the
+// first item for which `p(item)` returns falsy value.
+//
+// Implements clojure drop-while:
+// http://clojuredocs.org/clojure_core/clojure.core/drop-while
+const dropWhile = (p, sequence) => seq(function* () {
+ let keep = false;
+ for (let item of sequence) {
+ keep = keep || !p(item);
+ if (keep) yield item;
+ }
+});
+exports.dropWhile = dropWhile;
+
+// Returns a lazy sequence representing the concatenation of the
+// suplied sequences.
+//
+// Implements clojure conact:
+// http://clojuredocs.org/clojure_core/clojure.core/concat
+const concat = (...sequences) => seq(function* () {
+ for (let sequence of sequences)
+ for (let item of sequence)
+ yield item;
+});
+exports.concat = concat;
+
+// Returns the first item in the sequence.
+//
+// Implements clojure first:
+// http://clojuredocs.org/clojure_core/clojure.core/first
+const first = sequence => {
+ if (sequence !== null && sequence !== void(0)) {
+ for (let item of sequence)
+ return item;
+ }
+ return null;
+};
+exports.first = first;
+
+// Returns a possibly empty sequence of the items after the first.
+//
+// Implements clojure rest:
+// http://clojuredocs.org/clojure_core/clojure.core/rest
+const rest = sequence => drop(1, sequence);
+exports.rest = rest;
+
+// Returns the value at the index. Returns `notFound` or `undefined`
+// if index is out of bounds.
+const nth = (xs, n, notFound) => {
+ if (n >= 0) {
+ if (isArray(xs) || isArguments(xs) || isString(xs)) {
+ return n < xs.length ? xs[n] : notFound;
+ }
+ else if (xs !== null && xs !== void(0)) {
+ let count = n;
+ for (let x of xs) {
+ if (count <= 0)
+ return x;
+
+ count = count - 1;
+ }
+ }
+ }
+ return notFound;
+};
+exports.nth = nth;
+
+// Return the last item in sequence, in linear time.
+// If `sequence` is an array or string or arguments
+// returns in constant time.
+// Implements clojure last:
+// http://clojuredocs.org/clojure_core/clojure.core/last
+const last = polymorphic({
+ null: _ => null,
+ void: _ => null,
+ indexed: indexed => indexed[indexed.length - 1],
+ map: xs => reduce((_, x) => x, xs),
+ set: xs => reduce((_, x) => x, xs),
+ default: xs => reduce((_, x) => x, xs)
+});
+exports.last = last;
+
+// Return a lazy sequence of all but the last `n` (default 1) items
+// from the give `xs`.
+//
+// Implements clojure drop-last:
+// http://clojuredocs.org/clojure_core/clojure.core/drop-last
+const dropLast = flip((xs, n=1) => seq(function* () {
+ let ys = [];
+ for (let x of xs) {
+ ys.push(x);
+ if (ys.length > n)
+ yield ys.shift();
+ }
+}));
+exports.dropLast = dropLast;
+
+// Returns a lazy sequence of the elements of `xs` with duplicates
+// removed
+//
+// Implements clojure distinct
+// http://clojuredocs.org/clojure_core/clojure.core/distinct
+const distinct = sequence => seq(function* () {
+ let items = new Set();
+ for (let item of sequence) {
+ if (!items.has(item)) {
+ items.add(item);
+ yield item;
+ }
+ }
+});
+exports.distinct = distinct;
+
+// Returns a lazy sequence of the items in `xs` for which
+// `p(x)` returns false. `p` must be free of side-effects.
+//
+// Implements clojure remove
+// http://clojuredocs.org/clojure_core/clojure.core/remove
+const remove = (p, xs) => filter(complement(p), xs);
+exports.remove = remove;
+
+// Returns the result of applying concat to the result of
+// `map(f, xs)`. Thus function `f` should return a sequence.
+//
+// Implements clojure mapcat
+// http://clojuredocs.org/clojure_core/clojure.core/mapcat
+const mapcat = (f, sequence) => seq(function* () {
+ const sequences = map(f, sequence);
+ for (let sequence of sequences)
+ for (let item of sequence)
+ yield item;
+});
+exports.mapcat = mapcat;
diff --git a/toolkit/jetpack/sdk/util/uuid.js b/toolkit/jetpack/sdk/util/uuid.js
new file mode 100644
index 000000000..6d0f2de53
--- /dev/null
+++ b/toolkit/jetpack/sdk/util/uuid.js
@@ -0,0 +1,19 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Cc, Ci, components: { ID: parseUUID } } = require('chrome');
+const { generateUUID } = Cc['@mozilla.org/uuid-generator;1'].
+ getService(Ci.nsIUUIDGenerator);
+
+// Returns `uuid`. If `id` is passed then it's parsed to `uuid` and returned
+// if not then new one is generated.
+exports.uuid = function uuid(id) {
+ return id ? parseUUID(id) : generateUUID();
+};
diff --git a/toolkit/jetpack/sdk/view/core.js b/toolkit/jetpack/sdk/view/core.js
new file mode 100644
index 000000000..5e82e9b5d
--- /dev/null
+++ b/toolkit/jetpack/sdk/view/core.js
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+var { Ci } = require("chrome");
+var method = require("../../method/core");
+
+// Returns DOM node associated with a view for
+// the given `value`. If `value` has no view associated
+// it returns `null`. You can implement this method for
+// this type to define what the result should be for it.
+var getNodeView = method("getNodeView");
+getNodeView.define(x =>
+ x instanceof Ci.nsIDOMNode ? x :
+ x instanceof Ci.nsIDOMWindow ? x :
+ null);
+exports.getNodeView = getNodeView;
+exports.viewFor = getNodeView;
+
+var getActiveView = method("getActiveView");
+exports.getActiveView = getActiveView;
diff --git a/toolkit/jetpack/sdk/webextension.js b/toolkit/jetpack/sdk/webextension.js
new file mode 100644
index 000000000..d1c4385e2
--- /dev/null
+++ b/toolkit/jetpack/sdk/webextension.js
@@ -0,0 +1,43 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
+};
+
+let webExtension;
+let waitForWebExtensionAPI;
+
+module.exports = {
+ initFromBootstrapAddonParam(data) {
+ if (webExtension) {
+ throw new Error("'sdk/webextension' module has been already initialized");
+ }
+
+ webExtension = data.webExtension;
+ },
+
+ startup() {
+ if (!webExtension) {
+ return Promise.reject(new Error(
+ "'sdk/webextension' module is currently disabled. " +
+ "('hasEmbeddedWebExtension' option is missing or set to false)"
+ ));
+ }
+
+ // NOTE: calling `startup` more than once raises an "Embedded Extension already started"
+ // error, but given that SDK addons are going to have access to the startup method through
+ // an SDK module that can be required in any part of the addon, it will be nicer if any
+ // additional startup calls return the startup promise instead of raising an exception,
+ // so that the SDK addon can access the API object in the other addon modules without the
+ // need to manually pass this promise around.
+ if (!waitForWebExtensionAPI) {
+ waitForWebExtensionAPI = webExtension.startup();
+ }
+
+ return waitForWebExtensionAPI;
+ }
+};
diff --git a/toolkit/jetpack/sdk/window/browser.js b/toolkit/jetpack/sdk/window/browser.js
new file mode 100644
index 000000000..380b5a486
--- /dev/null
+++ b/toolkit/jetpack/sdk/window/browser.js
@@ -0,0 +1,54 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { Class } = require('../core/heritage');
+const { windowNS } = require('./namespace');
+const { on, off, once } = require('../event/core');
+const { method } = require('../lang/functional');
+const { getWindowTitle } = require('./utils');
+const unload = require('../system/unload');
+const { EventTarget } = require('../event/target');
+const { isPrivate } = require('../private-browsing/utils');
+const { isWindowPrivate, isFocused } = require('../window/utils');
+const { viewFor } = require('../view/core');
+
+const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead';
+
+const BrowserWindow = Class({
+ initialize: function initialize(options) {
+ EventTarget.prototype.initialize.call(this, options);
+ windowNS(this).window = options.window;
+ },
+ activate: function activate() {
+ // TODO
+ return null;
+ },
+ close: function() {
+ throw new Error(ERR_FENNEC_MSG);
+ return null;
+ },
+ get title() {
+ return getWindowTitle(windowNS(this).window);
+ },
+ // NOTE: Fennec only has one window, which is assumed below
+ // TODO: remove assumption below
+ // NOTE: tabs requires windows
+ get tabs() {
+ return require('../tabs');
+ },
+ get activeTab() {
+ return require('../tabs').activeTab;
+ },
+ on: method(on),
+ removeListener: method(off),
+ once: method(once)
+});
+exports.BrowserWindow = BrowserWindow;
+
+const getWindowView = window => windowNS(window).window;
+
+viewFor.define(BrowserWindow, getWindowView);
+isPrivate.define(BrowserWindow, (window) => isWindowPrivate(viewFor(window).window));
+isFocused.define(BrowserWindow, (window) => isFocused(viewFor(window).window));
diff --git a/toolkit/jetpack/sdk/window/events.js b/toolkit/jetpack/sdk/window/events.js
new file mode 100644
index 000000000..b1d3a1f3e
--- /dev/null
+++ b/toolkit/jetpack/sdk/window/events.js
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { Ci, Cu } = require("chrome");
+const { observe } = require("../event/chrome");
+const { open } = require("../event/dom");
+const { windows } = require("../window/utils");
+const { filter, merge, map, expand } = require("../event/utils");
+
+function documentMatches(weakWindow, event) {
+ let window = weakWindow.get();
+ return window && event.target === window.document;
+}
+
+function makeStrictDocumentFilter(window) {
+ // Note: Do not define a closure within this function. Otherwise
+ // you may leak the window argument.
+ let weak = Cu.getWeakReference(window);
+ return documentMatches.bind(null, weak);
+}
+
+function toEventWithDefaultViewTarget({type, target}) {
+ return { type: type, target: target.defaultView }
+}
+
+// Function registers single shot event listeners for relevant window events
+// that forward events to exported event stream.
+function eventsFor(window) {
+ // NOTE: Do no use pass a closure from this function into a stream
+ // transform function. You will capture the window in the
+ // closure and leak the window until the event stream is
+ // completely closed.
+ let interactive = open(window, "DOMContentLoaded", { capture: true });
+ let complete = open(window, "load", { capture: true });
+ let states = merge([interactive, complete]);
+ let changes = filter(states, makeStrictDocumentFilter(window));
+ return map(changes, toEventWithDefaultViewTarget);
+}
+
+// Create our event channels. We do this in a separate function to
+// minimize the chance of leaking intermediate objects on the global.
+function makeEvents() {
+ // In addition to observing windows that are open we also observe windows
+ // that are already already opened in case they're in process of loading.
+ var opened = windows(null, { includePrivate: true });
+ var currentEvents = merge(opened.map(eventsFor));
+
+ // Register system event listeners for top level window open / close.
+ function rename({type, target, data}) {
+ return { type: rename[type], target: target, data: data }
+ }
+ rename.domwindowopened = "open";
+ rename.domwindowclosed = "close";
+
+ var openEvents = map(observe("domwindowopened"), rename);
+ var closeEvents = map(observe("domwindowclosed"), rename);
+ var futureEvents = expand(openEvents, ({target}) => eventsFor(target));
+
+ return merge([currentEvents, futureEvents, openEvents, closeEvents]);
+}
+
+exports.events = makeEvents();
diff --git a/toolkit/jetpack/sdk/window/helpers.js b/toolkit/jetpack/sdk/window/helpers.js
new file mode 100644
index 000000000..56cfcaba7
--- /dev/null
+++ b/toolkit/jetpack/sdk/window/helpers.js
@@ -0,0 +1,81 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { defer, all } = require('../core/promise');
+const events = require('../system/events');
+const { open: openWindow, onFocus, getToplevelWindow,
+ isInteractive, isStartupFinished, getOuterId } = require('./utils');
+const { Ci } = require("chrome");
+
+function open(uri, options) {
+ return promise(openWindow.apply(null, arguments), 'load').then(focus);
+}
+exports.open = open;
+
+function close(window) {
+ let deferred = defer();
+ let toplevelWindow = getToplevelWindow(window);
+ let outerId = getOuterId(toplevelWindow);
+ events.on("outer-window-destroyed", function onclose({subject}) {
+ let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
+ if (id == outerId) {
+ events.off("outer-window-destroyed", onclose);
+ deferred.resolve();
+ }
+ }, true);
+ window.close();
+ return deferred.promise;
+}
+exports.close = close;
+
+function focus(window) {
+ let p = onFocus(window);
+ window.focus();
+ return p;
+}
+exports.focus = focus;
+
+function ready(window) {
+ let { promise: result, resolve } = defer();
+
+ if (isInteractive(window))
+ resolve(window);
+ else
+ resolve(promise(window, 'DOMContentLoaded'));
+
+ return result;
+}
+exports.ready = ready;
+
+function startup(window) {
+ let { promise: result, resolve } = defer();
+
+ if (isStartupFinished(window)) {
+ resolve(window);
+ } else {
+ events.on("browser-delayed-startup-finished", function listener({subject}) {
+ if (subject === window) {
+ events.off("browser-delayed-startup-finished", listener);
+ resolve(window);
+ }
+ });
+ }
+
+ return result;
+}
+exports.startup = startup;
+
+function promise(target, evt, capture) {
+ let deferred = defer();
+ capture = !!capture;
+
+ target.addEventListener(evt, function eventHandler() {
+ target.removeEventListener(evt, eventHandler, capture);
+ deferred.resolve(target);
+ }, capture);
+
+ return deferred.promise;
+}
+exports.promise = promise;
diff --git a/toolkit/jetpack/sdk/window/namespace.js b/toolkit/jetpack/sdk/window/namespace.js
new file mode 100644
index 000000000..b486f888d
--- /dev/null
+++ b/toolkit/jetpack/sdk/window/namespace.js
@@ -0,0 +1,6 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+exports.windowNS = require('../core/namespace').ns();
diff --git a/toolkit/jetpack/sdk/window/utils.js b/toolkit/jetpack/sdk/window/utils.js
new file mode 100644
index 000000000..db91a0fed
--- /dev/null
+++ b/toolkit/jetpack/sdk/window/utils.js
@@ -0,0 +1,460 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'unstable'
+};
+
+const { Cc, Ci } = require('chrome');
+const array = require('../util/array');
+const { defer } = require('sdk/core/promise');
+const { dispatcher } = require("../util/dispatcher");
+
+const windowWatcher = Cc['@mozilla.org/embedcomp/window-watcher;1'].
+ getService(Ci.nsIWindowWatcher);
+const appShellService = Cc['@mozilla.org/appshell/appShellService;1'].
+ getService(Ci.nsIAppShellService);
+const WM = Cc['@mozilla.org/appshell/window-mediator;1'].
+ getService(Ci.nsIWindowMediator);
+const io = Cc['@mozilla.org/network/io-service;1'].
+ getService(Ci.nsIIOService);
+const FM = Cc["@mozilla.org/focus-manager;1"].
+ getService(Ci.nsIFocusManager);
+
+const XUL_NS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
+
+const prefs = require("../preferences/service");
+const BROWSER = 'navigator:browser',
+ URI_BROWSER = prefs.get('browser.chromeURL', null),
+ NAME = '_blank',
+ FEATURES = 'chrome,all,dialog=no,non-private';
+
+function isWindowPrivate(win) {
+ if (!win)
+ return false;
+
+ // if the pbService is undefined, the PrivateBrowsingUtils.jsm is available,
+ // and the app is Firefox, then assume per-window private browsing is
+ // enabled.
+ try {
+ return win.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext)
+ .usePrivateBrowsing;
+ }
+ catch(e) {}
+
+ // Sometimes the input is not a nsIDOMWindow.. but it is still a winodw.
+ try {
+ return !!win.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing;
+ }
+ catch (e) {}
+
+ return false;
+}
+exports.isWindowPrivate = isWindowPrivate;
+
+function getMostRecentBrowserWindow() {
+ return getMostRecentWindow(BROWSER);
+}
+exports.getMostRecentBrowserWindow = getMostRecentBrowserWindow;
+
+function getHiddenWindow() {
+ return appShellService.hiddenDOMWindow;
+}
+exports.getHiddenWindow = getHiddenWindow;
+
+function getMostRecentWindow(type) {
+ return WM.getMostRecentWindow(type);
+}
+exports.getMostRecentWindow = getMostRecentWindow;
+
+/**
+ * Returns the ID of the window's current inner window.
+ */
+function getInnerId(window) {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
+};
+exports.getInnerId = getInnerId;
+
+/**
+ * Returns the ID of the window's outer window.
+ */
+function getOuterId(window) {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
+};
+exports.getOuterId = getOuterId;
+
+/**
+ * Returns window by the outer window id.
+ */
+const getByOuterId = WM.getOuterWindowWithId;
+exports.getByOuterId = getByOuterId;
+
+const getByInnerId = WM.getCurrentInnerWindowWithId;
+exports.getByInnerId = getByInnerId;
+
+/**
+ * Returns `nsIXULWindow` for the given `nsIDOMWindow`.
+ */
+function getXULWindow(window) {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIWebNavigation).
+ QueryInterface(Ci.nsIDocShellTreeItem).
+ treeOwner.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIXULWindow);
+};
+exports.getXULWindow = getXULWindow;
+
+function getDOMWindow(xulWindow) {
+ return xulWindow.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDOMWindow);
+}
+exports.getDOMWindow = getDOMWindow;
+
+/**
+ * Returns `nsIBaseWindow` for the given `nsIDOMWindow`.
+ */
+function getBaseWindow(window) {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIWebNavigation).
+ QueryInterface(Ci.nsIDocShell).
+ QueryInterface(Ci.nsIDocShellTreeItem).
+ treeOwner.
+ QueryInterface(Ci.nsIBaseWindow);
+}
+exports.getBaseWindow = getBaseWindow;
+
+/**
+ * Returns the `nsIDOMWindow` toplevel window for any child/inner window
+ */
+function getToplevelWindow(window) {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsIDocShellTreeItem)
+ .rootTreeItem
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindow);
+}
+exports.getToplevelWindow = getToplevelWindow;
+
+function getWindowDocShell(window) {
+ return window.gBrowser.docShell;
+}
+exports.getWindowDocShell = getWindowDocShell;
+
+function getWindowLoadingContext(window) {
+ return getWindowDocShell(window).
+ QueryInterface(Ci.nsILoadContext);
+}
+exports.getWindowLoadingContext = getWindowLoadingContext;
+
+const isTopLevel = window => window && getToplevelWindow(window) === window;
+exports.isTopLevel = isTopLevel;
+
+/**
+ * Takes hash of options and serializes it to a features string that
+ * can be used passed to `window.open`. For more details on features string see:
+ * https://developer.mozilla.org/en/DOM/window.open#Position_and_size_features
+ */
+function serializeFeatures(options) {
+ return Object.keys(options).reduce(function(result, name) {
+ let value = options[name];
+
+ // the chrome and private features are special
+ if ((name == 'private' || name == 'chrome' || name == 'all'))
+ return result + ((value === true) ? ',' + name : '');
+
+ return result + ',' + name + '=' +
+ (value === true ? 'yes' : value === false ? 'no' : value);
+ }, '').substr(1);
+}
+
+/**
+ * Opens a top level window and returns it's `nsIDOMWindow` representation.
+ * @params {String} uri
+ * URI of the document to be loaded into window.
+ * @params {nsIDOMWindow} options.parent
+ * Used as parent for the created window.
+ * @params {String} options.name
+ * Optional name that is assigned to the window.
+ * @params {Object} options.features
+ * Map of key, values like: `{ width: 10, height: 15, chrome: true, private: true }`.
+ */
+function open(uri, options) {
+ uri = uri || URI_BROWSER;
+ options = options || {};
+
+ if (!uri)
+ throw new Error('browser.chromeURL is undefined, please provide an explicit uri');
+
+ if (['chrome', 'resource', 'data'].indexOf(io.newURI(uri, null, null).scheme) < 0)
+ throw new Error('only chrome, resource and data uris are allowed');
+
+ let newWindow = windowWatcher.
+ openWindow(options.parent || null,
+ uri,
+ options.name || null,
+ options.features ? serializeFeatures(options.features) : null,
+ options.args || null);
+
+ return newWindow;
+}
+exports.open = open;
+
+function onFocus(window) {
+ let { resolve, promise } = defer();
+
+ if (isFocused(window)) {
+ resolve(window);
+ }
+ else {
+ window.addEventListener("focus", function focusListener() {
+ window.removeEventListener("focus", focusListener, true);
+ resolve(window);
+ }, true);
+ }
+
+ return promise;
+}
+exports.onFocus = onFocus;
+
+var isFocused = dispatcher("window-isFocused");
+isFocused.when(x => x instanceof Ci.nsIDOMWindow, (window) => {
+ const FM = Cc["@mozilla.org/focus-manager;1"].
+ getService(Ci.nsIFocusManager);
+
+ let childTargetWindow = {};
+ FM.getFocusedElementForWindow(window, true, childTargetWindow);
+ childTargetWindow = childTargetWindow.value;
+
+ let focusedChildWindow = {};
+ if (FM.activeWindow) {
+ FM.getFocusedElementForWindow(FM.activeWindow, true, focusedChildWindow);
+ focusedChildWindow = focusedChildWindow.value;
+ }
+
+ return (focusedChildWindow === childTargetWindow);
+});
+exports.isFocused = isFocused;
+
+/**
+ * Opens a top level window and returns it's `nsIDOMWindow` representation.
+ * Same as `open` but with more features
+ * @param {Object} options
+ *
+ */
+function openDialog(options) {
+ options = options || {};
+
+ let features = options.features || FEATURES;
+ let featureAry = features.toLowerCase().split(',');
+
+ if (!!options.private) {
+ // add private flag if private window is desired
+ if (!array.has(featureAry, 'private')) {
+ featureAry.push('private');
+ }
+
+ // remove the non-private flag ig a private window is desired
+ let nonPrivateIndex = featureAry.indexOf('non-private');
+ if (nonPrivateIndex >= 0) {
+ featureAry.splice(nonPrivateIndex, 1);
+ }
+
+ features = featureAry.join(',');
+ }
+
+ let browser = getMostRecentBrowserWindow();
+
+ // if there is no browser then do nothing
+ if (!browser)
+ return undefined;
+
+ let newWindow = browser.openDialog.apply(
+ browser,
+ array.flatten([
+ options.url || URI_BROWSER,
+ options.name || NAME,
+ features,
+ options.args || null
+ ])
+ );
+
+ return newWindow;
+}
+exports.openDialog = openDialog;
+
+/**
+ * Returns an array of all currently opened windows.
+ * Note that these windows may still be loading.
+ */
+function windows(type, options) {
+ options = options || {};
+ let list = [];
+ let winEnum = WM.getEnumerator(type);
+ while (winEnum.hasMoreElements()) {
+ let window = winEnum.getNext().QueryInterface(Ci.nsIDOMWindow);
+ // Only add non-private windows when pb permission isn't set,
+ // unless an option forces the addition of them.
+ if (!window.closed && (options.includePrivate || !isWindowPrivate(window))) {
+ list.push(window);
+ }
+ }
+ return list;
+}
+exports.windows = windows;
+
+/**
+ * Check if the given window is interactive.
+ * i.e. if its "DOMContentLoaded" event has already been fired.
+ * @params {nsIDOMWindow} window
+ */
+const isInteractive = window =>
+ window.document.readyState === "interactive" ||
+ isDocumentLoaded(window) ||
+ // XUL documents stays '"uninitialized"' until it's `readyState` becomes
+ // `"complete"`.
+ isXULDocumentWindow(window) && window.document.readyState === "interactive";
+exports.isInteractive = isInteractive;
+
+/**
+ * Check if the given browser window has finished the startup.
+ * @params {nsIDOMWindow} window
+ */
+const isStartupFinished = (window) =>
+ isBrowser(window) &&
+ window.gBrowserInit &&
+ window.gBrowserInit.delayedStartupFinished;
+
+exports.isStartupFinished = isStartupFinished;
+
+const isXULDocumentWindow = ({document}) =>
+ document.documentElement &&
+ document.documentElement.namespaceURI === XUL_NS;
+
+/**
+ * Check if the given window is completely loaded.
+ * i.e. if its "load" event has already been fired and all possible DOM content
+ * is done loading (the whole DOM document, images content, ...)
+ * @params {nsIDOMWindow} window
+ */
+function isDocumentLoaded(window) {
+ return window.document.readyState == "complete";
+}
+exports.isDocumentLoaded = isDocumentLoaded;
+
+function isBrowser(window) {
+ try {
+ return window.document.documentElement.getAttribute("windowtype") === BROWSER;
+ }
+ catch (e) {}
+ return false;
+};
+exports.isBrowser = isBrowser;
+
+function getWindowTitle(window) {
+ return window && window.document ? window.document.title : null;
+}
+exports.getWindowTitle = getWindowTitle;
+
+function isXULBrowser(window) {
+ return !!(isBrowser(window) && window.XULBrowserWindow);
+}
+exports.isXULBrowser = isXULBrowser;
+
+/**
+ * Returns the most recent focused window
+ */
+function getFocusedWindow() {
+ let window = WM.getMostRecentWindow(BROWSER);
+
+ return window ? window.document.commandDispatcher.focusedWindow : null;
+}
+exports.getFocusedWindow = getFocusedWindow;
+
+/**
+ * Returns the focused browser window if any, or the most recent one.
+ * Opening new window, updates most recent window, but focus window
+ * changes later; so most recent window and focused window are not always
+ * the same.
+ */
+function getFocusedBrowser() {
+ let window = FM.activeWindow;
+ return isBrowser(window) ? window : getMostRecentBrowserWindow()
+}
+exports.getFocusedBrowser = getFocusedBrowser;
+
+/**
+ * Returns the focused element in the most recent focused window
+ */
+function getFocusedElement() {
+ let window = WM.getMostRecentWindow(BROWSER);
+
+ return window ? window.document.commandDispatcher.focusedElement : null;
+}
+exports.getFocusedElement = getFocusedElement;
+
+function getFrames(window) {
+ return Array.slice(window.frames).reduce(function(frames, frame) {
+ return frames.concat(frame, getFrames(frame));
+ }, []);
+}
+exports.getFrames = getFrames;
+
+function getScreenPixelsPerCSSPixel(window) {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDOMWindowUtils).screenPixelsPerCSSPixel;
+}
+exports.getScreenPixelsPerCSSPixel = getScreenPixelsPerCSSPixel;
+
+function getOwnerBrowserWindow(node) {
+ /**
+ Takes DOM node and returns browser window that contains it.
+ **/
+ let window = getToplevelWindow(node.ownerDocument.defaultView);
+ // If anchored window is browser then it's target browser window.
+ return isBrowser(window) ? window : null;
+}
+exports.getOwnerBrowserWindow = getOwnerBrowserWindow;
+
+function getParentWindow(window) {
+ try {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsIDocShellTreeItem).parent
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindow);
+ }
+ catch (e) {}
+ return null;
+}
+exports.getParentWindow = getParentWindow;
+
+
+function getParentFrame(window) {
+ try {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsIDocShellTreeItem).parent
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindow);
+ }
+ catch (e) {}
+ return null;
+}
+exports.getParentWindow = getParentWindow;
+
+// The element in which the window is embedded, or `null`
+// if the window is top-level. Similar to `window.frameElement`
+// but can cross chrome-content boundries.
+const getFrameElement = target =>
+ (target instanceof Ci.nsIDOMDocument ? target.defaultView : target).
+ QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIDOMWindowUtils).
+ containerElement;
+exports.getFrameElement = getFrameElement;
diff --git a/toolkit/jetpack/sdk/windows.js b/toolkit/jetpack/sdk/windows.js
new file mode 100644
index 000000000..06dbe70b2
--- /dev/null
+++ b/toolkit/jetpack/sdk/windows.js
@@ -0,0 +1,32 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+module.metadata = {
+ 'stability': 'stable'
+};
+
+const { isBrowser } = require('./window/utils');
+const { modelFor } = require('./model/core');
+const { viewFor } = require('./view/core');
+
+
+if (require('./system/xul-app').is('Fennec')) {
+ module.exports = require('./windows/fennec');
+}
+else {
+ module.exports = require('./windows/firefox');
+}
+
+
+const browsers = module.exports.browserWindows;
+
+//
+modelFor.when(isBrowser, view => {
+ for (let model of browsers) {
+ if (viewFor(model) === view)
+ return model;
+ }
+ return null;
+});
diff --git a/toolkit/jetpack/sdk/windows/fennec.js b/toolkit/jetpack/sdk/windows/fennec.js
new file mode 100644
index 000000000..3c3b6c313
--- /dev/null
+++ b/toolkit/jetpack/sdk/windows/fennec.js
@@ -0,0 +1,83 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { Class } = require('../core/heritage');
+const { BrowserWindow } = require('../window/browser');
+const { WindowTracker } = require('../deprecated/window-utils');
+const { isBrowser, getMostRecentBrowserWindow } = require('../window/utils');
+const { windowNS } = require('../window/namespace');
+const { on, off, once, emit } = require('../event/core');
+const { method } = require('../lang/functional');
+const { EventTarget } = require('../event/target');
+const { List, addListItem } = require('../util/list');
+
+const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead';
+
+// NOTE: On Fennec there is only one window.
+
+var BrowserWindows = Class({
+ implements: [ List ],
+ extends: EventTarget,
+ initialize: function() {
+ List.prototype.initialize.apply(this);
+ },
+ get activeWindow() {
+ let window = getMostRecentBrowserWindow();
+ return window ? getBrowserWindow({window: window}) : null;
+ },
+ open: function open(options) {
+ throw new Error(ERR_FENNEC_MSG);
+ return null;
+ }
+});
+const browserWindows = exports.browserWindows = BrowserWindows();
+
+
+/**
+ * Gets a `BrowserWindow` for the given `chromeWindow` if previously
+ * registered, `null` otherwise.
+ */
+function getRegisteredWindow(chromeWindow) {
+ for (let window of browserWindows) {
+ if (chromeWindow === windowNS(window).window)
+ return window;
+ }
+
+ return null;
+}
+
+/**
+ * Gets a `BrowserWindow` for the provided window options obj
+ * @params {Object} options
+ * Options that are passed to the the `BrowserWindow`
+ * @returns {BrowserWindow}
+ */
+function getBrowserWindow(options) {
+ let window = null;
+
+ // if we have a BrowserWindow already then use it
+ if ('window' in options)
+ window = getRegisteredWindow(options.window);
+ if (window)
+ return window;
+
+ // we don't have a BrowserWindow yet, so create one
+ window = BrowserWindow(options);
+ addListItem(browserWindows, window);
+ return window;
+}
+
+WindowTracker({
+ onTrack: function onTrack(chromeWindow) {
+ if (!isBrowser(chromeWindow)) return;
+ let window = getBrowserWindow({ window: chromeWindow });
+ emit(browserWindows, 'open', window);
+ },
+ onUntrack: function onUntrack(chromeWindow) {
+ if (!isBrowser(chromeWindow)) return;
+ let window = getBrowserWindow({ window: chromeWindow });
+ emit(browserWindows, 'close', window);
+ }
+});
diff --git a/toolkit/jetpack/sdk/windows/firefox.js b/toolkit/jetpack/sdk/windows/firefox.js
new file mode 100644
index 000000000..1eb1d8488
--- /dev/null
+++ b/toolkit/jetpack/sdk/windows/firefox.js
@@ -0,0 +1,224 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Class } = require('../core/heritage');
+const { observer } = require('./observer');
+const { isBrowser, getMostRecentBrowserWindow, windows, open, getInnerId,
+ getWindowTitle, getToplevelWindow, isFocused, isWindowPrivate } = require('../window/utils');
+const { List, addListItem, removeListItem } = require('../util/list');
+const { viewFor } = require('../view/core');
+const { modelFor } = require('../model/core');
+const { emit, emitOnObject, setListeners } = require('../event/core');
+const { once } = require('../dom/events');
+const { EventTarget } = require('../event/target');
+const { getSelectedTab } = require('../tabs/utils');
+const { Cc, Ci } = require('chrome');
+const { Options } = require('../tabs/common');
+const system = require('../system/events');
+const { ignoreWindow, isPrivate, isWindowPBSupported } = require('../private-browsing/utils');
+const { data, isPrivateBrowsingSupported } = require('../self');
+const { setImmediate } = require('../timers');
+
+const supportPrivateWindows = isPrivateBrowsingSupported && isWindowPBSupported;
+
+const modelsFor = new WeakMap();
+const viewsFor = new WeakMap();
+
+const Window = Class({
+ implements: [EventTarget],
+ initialize: function(domWindow) {
+ modelsFor.set(domWindow, this);
+ viewsFor.set(this, domWindow);
+ },
+
+ get title() {
+ return getWindowTitle(viewsFor.get(this));
+ },
+
+ activate: function() {
+ viewsFor.get(this).focus();
+ },
+
+ close: function(callback) {
+ let domWindow = viewsFor.get(this);
+
+ if (callback) {
+ // We want to catch the close event immediately after the close events are
+ // emitted everywhere but without letting the event loop spin. Registering
+ // for the same events as windowEventListener but afterwards does this
+ let listener = (event, closedWin) => {
+ if (event != "close" || closedWin != domWindow)
+ return;
+
+ observer.off("*", listener);
+ callback();
+ }
+
+ observer.on("*", listener);
+ }
+
+ domWindow.close();
+ }
+});
+
+const windowTabs = new WeakMap();
+
+const BrowserWindow = Class({
+ extends: Window,
+
+ get tabs() {
+ let tabs = windowTabs.get(this);
+ if (tabs)
+ return tabs;
+
+ return new WindowTabs(this);
+ }
+});
+
+const WindowTabs = Class({
+ implements: [EventTarget],
+ extends: List,
+ initialize: function(window) {
+ List.prototype.initialize.call(this);
+ windowTabs.set(window, this);
+ viewsFor.set(this, viewsFor.get(window));
+
+ // Make sure the tabs module has loaded and found all existing tabs
+ const tabs = require('../tabs');
+
+ for (let tab of tabs) {
+ if (tab.window == window)
+ addListItem(this, tab);
+ }
+ },
+
+ get activeTab() {
+ return modelFor(getSelectedTab(viewsFor.get(this)));
+ },
+
+ open: function(options) {
+ options = Options(options);
+
+ let domWindow = viewsFor.get(this);
+ let { Tab } = require('../tabs/tab-firefox');
+
+ // The capturing listener will see the TabOpen event before
+ // sdk/tabs/observer giving us time to set up the tab and listeners before
+ // the real open event is fired
+ let listener = event => {
+ new Tab(event.target, options);
+ };
+
+ once(domWindow, "TabOpen", listener, true);
+ domWindow.gBrowser.addTab(options.url);
+ }
+});
+
+const BrowserWindows = Class({
+ implements: [EventTarget],
+ extends: List,
+ initialize: function() {
+ List.prototype.initialize.call(this);
+ },
+
+ get activeWindow() {
+ let domWindow = getMostRecentBrowserWindow();
+ if (ignoreWindow(domWindow))
+ return null;
+ return modelsFor.get(domWindow);
+ },
+
+ open: function(options) {
+ if (typeof options == "string")
+ options = { url: options };
+
+ let { url, isPrivate } = options;
+ if (url)
+ url = data.url(url);
+
+ let args = Cc["@mozilla.org/supports-string;1"].
+ createInstance(Ci.nsISupportsString);
+ args.data = url;
+
+ let features = {
+ chrome: true,
+ all: true,
+ dialog: false
+ };
+ features.private = supportPrivateWindows && isPrivate;
+
+ let domWindow = open(null, {
+ parent: null,
+ name: "_blank",
+ features,
+ args
+ })
+
+ let window = makeNewWindow(domWindow, true);
+ setListeners(window, options);
+ return window;
+ }
+});
+
+const browserWindows = new BrowserWindows();
+exports.browserWindows = browserWindows;
+
+function windowEmit(window, event, ...args) {
+ if (window instanceof BrowserWindow && (event == "open" || event == "close"))
+ emitOnObject(window, event, browserWindows, window, ...args);
+ else
+ emit(window, event, window, ...args);
+
+ if (window instanceof BrowserWindow)
+ emit(browserWindows, event, window, ...args);
+}
+
+function makeNewWindow(domWindow, browserHint = false) {
+ if (browserHint || isBrowser(domWindow))
+ return new BrowserWindow(domWindow);
+ else
+ return new Window(domWindow);
+}
+
+for (let domWindow of windows(null, {includePrivate: supportPrivateWindows})) {
+ let window = makeNewWindow(domWindow);
+ if (window instanceof BrowserWindow)
+ addListItem(browserWindows, window);
+}
+
+var windowEventListener = (event, domWindow, ...args) => {
+ let toplevelWindow = getToplevelWindow(domWindow);
+
+ if (ignoreWindow(toplevelWindow))
+ return;
+
+ let window = modelsFor.get(toplevelWindow);
+ if (!window)
+ window = makeNewWindow(toplevelWindow);
+
+ if (isBrowser(toplevelWindow)) {
+ if (event == "open")
+ addListItem(browserWindows, window);
+ else if (event == "close")
+ removeListItem(browserWindows, window);
+ }
+
+ windowEmit(window, event, ...args);
+
+ // The window object shouldn't be reachable after closed
+ if (event == "close") {
+ viewsFor.delete(window);
+ modelsFor.delete(toplevelWindow);
+ }
+};
+observer.on("*", windowEventListener);
+
+viewFor.define(BrowserWindow, window => {
+ return viewsFor.get(window);
+})
+
+const isBrowserWindow = (x) => x instanceof BrowserWindow;
+isPrivate.when(isBrowserWindow, (w) => isWindowPrivate(viewsFor.get(w)));
+isFocused.when(isBrowserWindow, (w) => isFocused(viewsFor.get(w)));
diff --git a/toolkit/jetpack/sdk/windows/observer.js b/toolkit/jetpack/sdk/windows/observer.js
new file mode 100644
index 000000000..5ba2535f1
--- /dev/null
+++ b/toolkit/jetpack/sdk/windows/observer.js
@@ -0,0 +1,53 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { EventTarget } = require("../event/target");
+const { emit } = require("../event/core");
+const { WindowTracker, windowIterator } = require("../deprecated/window-utils");
+const { DOMEventAssembler } = require("../deprecated/events/assembler");
+const { Class } = require("../core/heritage");
+const { Cu } = require("chrome");
+
+// Event emitter objects used to register listeners and emit events on them
+// when they occur.
+const Observer = Class({
+ initialize() {
+ // Using `WindowTracker` to track window events.
+ WindowTracker({
+ onTrack: chromeWindow => {
+ emit(this, "open", chromeWindow);
+ this.observe(chromeWindow);
+ },
+ onUntrack: chromeWindow => {
+ emit(this, "close", chromeWindow);
+ this.ignore(chromeWindow);
+ }
+ });
+ },
+ implements: [EventTarget, DOMEventAssembler],
+ /**
+ * Events that are supported and emitted by the module.
+ */
+ supportedEventsTypes: [ "activate", "deactivate" ],
+ /**
+ * Function handles all the supported events on all the windows that are
+ * observed. Method is used to proxy events to the listeners registered on
+ * this event emitter.
+ * @param {Event} event
+ * Keyboard event being emitted.
+ */
+ handleEvent(event) {
+ // Ignore events from windows in the child process as they can't be top-level
+ if (Cu.isCrossProcessWrapper(event.target))
+ return;
+ emit(this, event.type, event.target, event);
+ }
+});
+
+exports.observer = new Observer();
diff --git a/toolkit/jetpack/sdk/windows/tabs-fennec.js b/toolkit/jetpack/sdk/windows/tabs-fennec.js
new file mode 100644
index 000000000..0ef5ec9f5
--- /dev/null
+++ b/toolkit/jetpack/sdk/windows/tabs-fennec.js
@@ -0,0 +1,172 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { Class } = require('../core/heritage');
+const { Tab } = require('../tabs/tab');
+const { browserWindows } = require('./fennec');
+const { windowNS } = require('../window/namespace');
+const { tabsNS, tabNS } = require('../tabs/namespace');
+const { openTab, getTabs, getSelectedTab, getTabForBrowser: getRawTabForBrowser,
+ getTabContentWindow } = require('../tabs/utils');
+const { Options } = require('../tabs/common');
+const { getTabForBrowser, getTabForRawTab } = require('../tabs/helpers');
+const { on, once, off, emit } = require('../event/core');
+const { method } = require('../lang/functional');
+const { EVENTS } = require('../tabs/events');
+const { EventTarget } = require('../event/target');
+const { when: unload } = require('../system/unload');
+const { windowIterator } = require('../deprecated/window-utils');
+const { List, addListItem, removeListItem } = require('../util/list');
+const { isPrivateBrowsingSupported, data } = require('../self');
+const { isTabPBSupported, ignoreWindow } = require('../private-browsing/utils');
+
+const mainWindow = windowNS(browserWindows.activeWindow).window;
+
+const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec';
+
+const supportPrivateTabs = isPrivateBrowsingSupported && isTabPBSupported;
+
+const Tabs = Class({
+ implements: [ List ],
+ extends: EventTarget,
+ initialize: function initialize(options) {
+ let tabsInternals = tabsNS(this);
+ let window = tabsNS(this).window = options.window || mainWindow;
+
+ EventTarget.prototype.initialize.call(this, options);
+ List.prototype.initialize.apply(this, getTabs(window).map(Tab));
+
+ // TabOpen event
+ window.BrowserApp.deck.addEventListener(EVENTS.open.dom, onTabOpen, false);
+
+ // TabSelect
+ window.BrowserApp.deck.addEventListener(EVENTS.activate.dom, onTabSelect, false);
+ },
+ get activeTab() {
+ return getTabForRawTab(getSelectedTab(tabsNS(this).window));
+ },
+ open: function(options) {
+ options = Options(options);
+ let activeWin = browserWindows.activeWindow;
+
+ if (options.isPinned) {
+ console.error(ERR_FENNEC_MSG); // TODO
+ }
+
+ let url = options.url ? data.url(options.url) : options.url;
+ let rawTab = openTab(windowNS(activeWin).window, url, {
+ inBackground: options.inBackground,
+ isPrivate: supportPrivateTabs && options.isPrivate
+ });
+
+ // by now the tab has been created
+ let tab = getTabForRawTab(rawTab);
+
+ if (options.onClose)
+ tab.on('close', options.onClose);
+
+ if (options.onOpen) {
+ // NOTE: on Fennec this will be true
+ if (tabNS(tab).opened)
+ options.onOpen(tab);
+
+ tab.on('open', options.onOpen);
+ }
+
+ if (options.onReady)
+ tab.on('ready', options.onReady);
+
+ if (options.onLoad)
+ tab.on('load', options.onLoad);
+
+ if (options.onPageShow)
+ tab.on('pageshow', options.onPageShow);
+
+ if (options.onActivate)
+ tab.on('activate', options.onActivate);
+
+ return tab;
+ }
+});
+var gTabs = exports.tabs = Tabs(mainWindow);
+
+function tabsUnloader(event, window) {
+ window = window || (event && event.target);
+ if (!(window && window.BrowserApp))
+ return;
+ window.BrowserApp.deck.removeEventListener(EVENTS.open.dom, onTabOpen, false);
+ window.BrowserApp.deck.removeEventListener(EVENTS.activate.dom, onTabSelect, false);
+}
+
+// unload handler
+unload(function() {
+ for (let window in windowIterator()) {
+ tabsUnloader(null, window);
+ }
+});
+
+function addTab(tab) {
+ addListItem(gTabs, tab);
+ return tab;
+}
+
+function removeTab(tab) {
+ removeListItem(gTabs, tab);
+ return tab;
+}
+
+// TabOpen
+function onTabOpen(event) {
+ let browser = event.target;
+
+ // Eventually ignore private tabs
+ if (ignoreWindow(browser.contentWindow))
+ return;
+
+ let tab = getTabForBrowser(browser);
+ if (tab === null) {
+ let rawTab = getRawTabForBrowser(browser);
+
+ // create a Tab instance for this new tab
+ tab = addTab(Tab(rawTab));
+ }
+
+ tabNS(tab).opened = true;
+
+ tab.on('ready', () => emit(gTabs, 'ready', tab));
+ tab.once('close', onTabClose);
+
+ tab.on('pageshow', (_tab, persisted) =>
+ emit(gTabs, 'pageshow', tab, persisted));
+
+ emit(tab, 'open', tab);
+ emit(gTabs, 'open', tab);
+}
+
+// TabSelect
+function onTabSelect(event) {
+ let browser = event.target;
+
+ // Eventually ignore private tabs
+ if (ignoreWindow(browser.contentWindow))
+ return;
+
+ // Set value whenever new tab becomes active.
+ let tab = getTabForBrowser(browser);
+ emit(tab, 'activate', tab);
+ emit(gTabs, 'activate', tab);
+
+ for (let t of gTabs) {
+ if (t === tab) continue;
+ emit(t, 'deactivate', t);
+ emit(gTabs, 'deactivate', t);
+ }
+}
+
+// TabClose
+function onTabClose(tab) {
+ removeTab(tab);
+ emit(gTabs, EVENTS.close.name, tab);
+}
diff --git a/toolkit/jetpack/sdk/worker/utils.js b/toolkit/jetpack/sdk/worker/utils.js
new file mode 100644
index 000000000..fca19be63
--- /dev/null
+++ b/toolkit/jetpack/sdk/worker/utils.js
@@ -0,0 +1,19 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+module.metadata = {
+ 'stability': 'deprecated'
+};
+
+const {
+ requiresAddonGlobal, attach, detach, destroy, WorkerHost
+} = require('../content/utils');
+
+exports.WorkerHost = WorkerHost;
+exports.detach = detach;
+exports.attach = attach;
+exports.destroy = destroy;
+exports.requiresAddonGlobal = requiresAddonGlobal;
diff --git a/toolkit/jetpack/sdk/zip/utils.js b/toolkit/jetpack/sdk/zip/utils.js
new file mode 100644
index 000000000..e600380cb
--- /dev/null
+++ b/toolkit/jetpack/sdk/zip/utils.js
@@ -0,0 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Cc, Ci } = require("chrome");
+
+function getZipReader(aFile) {
+ return new Promise(resolve => {
+ let zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].
+ createInstance(Ci.nsIZipReader);
+ zipReader.open(aFile);
+ resolve(zipReader);
+ });
+};
+exports.getZipReader = getZipReader;
diff --git a/toolkit/jetpack/test.js b/toolkit/jetpack/test.js
new file mode 100644
index 000000000..f0219f0a4
--- /dev/null
+++ b/toolkit/jetpack/test.js
@@ -0,0 +1,11 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+module.exports = require("sdk/test");
diff --git a/toolkit/jetpack/toolkit/loader.js b/toolkit/jetpack/toolkit/loader.js
new file mode 100644
index 000000000..4c22550d8
--- /dev/null
+++ b/toolkit/jetpack/toolkit/loader.js
@@ -0,0 +1,1147 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+;((factory) => { // Module boilerplate :(
+ if (typeof(require) === 'function') { // CommonJS
+ require("chrome").Cu.import(module.uri, exports);
+ }
+ else if (~String(this).indexOf('BackstagePass')) { // JSM
+ let module = { uri: __URI__, id: "toolkit/loader", exports: Object.create(null) }
+ factory(module);
+ Object.assign(this, module.exports);
+ this.EXPORTED_SYMBOLS = Object.getOwnPropertyNames(module.exports);
+ }
+ else {
+ throw Error("Loading environment is not supported");
+ }
+})(module => {
+
+'use strict';
+
+module.metadata = {
+ "stability": "unstable"
+};
+
+const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu,
+ results: Cr, manager: Cm } = Components;
+const systemPrincipal = CC('@mozilla.org/systemprincipal;1', 'nsIPrincipal')();
+const { loadSubScript } = Cc['@mozilla.org/moz/jssubscript-loader;1'].
+ getService(Ci.mozIJSSubScriptLoader);
+const { addObserver, notifyObservers } = Cc['@mozilla.org/observer-service;1'].
+ getService(Ci.nsIObserverService);
+const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
+const { join: pathJoin, normalize, dirname } = Cu.import("resource://gre/modules/osfile/ospath_unix.jsm");
+
+XPCOMUtils.defineLazyServiceGetter(this, "resProto",
+ "@mozilla.org/network/protocol;1?name=resource",
+ "nsIResProtocolHandler");
+XPCOMUtils.defineLazyServiceGetter(this, "zipCache",
+ "@mozilla.org/libjar/zip-reader-cache;1",
+ "nsIZipReaderCache");
+
+XPCOMUtils.defineLazyGetter(this, "XulApp", () => {
+ let xulappURI = module.uri.replace("toolkit/loader.js",
+ "sdk/system/xul-app.jsm");
+ return Cu.import(xulappURI, {});
+});
+
+// Define some shortcuts.
+const bind = Function.call.bind(Function.bind);
+const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
+const prototypeOf = Object.getPrototypeOf;
+const getOwnIdentifiers = x => [...Object.getOwnPropertyNames(x),
+ ...Object.getOwnPropertySymbols(x)];
+
+const NODE_MODULES = new Set([
+ "assert",
+ "buffer_ieee754",
+ "buffer",
+ "child_process",
+ "cluster",
+ "console",
+ "constants",
+ "crypto",
+ "_debugger",
+ "dgram",
+ "dns",
+ "domain",
+ "events",
+ "freelist",
+ "fs",
+ "http",
+ "https",
+ "_linklist",
+ "module",
+ "net",
+ "os",
+ "path",
+ "punycode",
+ "querystring",
+ "readline",
+ "repl",
+ "stream",
+ "string_decoder",
+ "sys",
+ "timers",
+ "tls",
+ "tty",
+ "url",
+ "util",
+ "vm",
+ "zlib",
+]);
+
+const COMPONENT_ERROR = '`Components` is not available in this context.\n' +
+ 'Functionality provided by Components may be available in an SDK\n' +
+ 'module: https://developer.mozilla.org/en-US/Add-ons/SDK \n\n' +
+ 'However, if you still need to import Components, you may use the\n' +
+ '`chrome` module\'s properties for shortcuts to Component properties:\n\n' +
+ 'Shortcuts: \n' +
+ ' Cc = Components' + '.classes \n' +
+ ' Ci = Components' + '.interfaces \n' +
+ ' Cu = Components' + '.utils \n' +
+ ' CC = Components' + '.Constructor \n' +
+ 'Example: \n' +
+ ' let { Cc, Ci } = require(\'chrome\');\n';
+
+// Workaround for bug 674195. Freezing objects from other compartments fail,
+// so we use `Object.freeze` from the same component instead.
+function freeze(object) {
+ if (prototypeOf(object) === null) {
+ Object.freeze(object);
+ }
+ else {
+ prototypeOf(prototypeOf(object.isPrototypeOf)).
+ constructor. // `Object` from the owner compartment.
+ freeze(object);
+ }
+ return object;
+}
+
+// Returns map of given `object`-s own property descriptors.
+const descriptor = iced(function descriptor(object) {
+ let value = {};
+ getOwnIdentifiers(object).forEach(function(name) {
+ value[name] = getOwnPropertyDescriptor(object, name)
+ });
+ return value;
+});
+Loader.descriptor = descriptor;
+
+// Freeze important built-ins so they can't be used by untrusted code as a
+// message passing channel.
+freeze(Object);
+freeze(Object.prototype);
+freeze(Function);
+freeze(Function.prototype);
+freeze(Array);
+freeze(Array.prototype);
+freeze(String);
+freeze(String.prototype);
+
+// This function takes `f` function sets it's `prototype` to undefined and
+// freezes it. We need to do this kind of deep freeze with all the exposed
+// functions so that untrusted code won't be able to use them a message
+// passing channel.
+function iced(f) {
+ if (!Object.isFrozen(f)) {
+ f.prototype = undefined;
+ }
+ return freeze(f);
+}
+
+// Defines own properties of given `properties` object on the given
+// target object overriding any existing property with a conflicting name.
+// Returns `target` object. Note we only export this function because it's
+// useful during loader bootstrap when other util modules can't be used &
+// thats only case where this export should be used.
+const override = iced(function override(target, source) {
+ let properties = descriptor(target)
+ let extension = descriptor(source || {})
+ getOwnIdentifiers(extension).forEach(function(name) {
+ properties[name] = extension[name];
+ });
+ return Object.defineProperties({}, properties);
+});
+Loader.override = override;
+
+function sourceURI(uri) { return String(uri).split(" -> ").pop(); }
+Loader.sourceURI = iced(sourceURI);
+
+function isntLoaderFrame(frame) { return frame.fileName !== module.uri }
+
+function parseURI(uri) { return String(uri).split(" -> ").pop(); }
+Loader.parseURI = parseURI;
+
+function parseStack(stack) {
+ let lines = String(stack).split("\n");
+ return lines.reduce(function(frames, line) {
+ if (line) {
+ let atIndex = line.indexOf("@");
+ let columnIndex = line.lastIndexOf(":");
+ let lineIndex = line.lastIndexOf(":", columnIndex - 1);
+ let fileName = parseURI(line.slice(atIndex + 1, lineIndex));
+ let lineNumber = parseInt(line.slice(lineIndex + 1, columnIndex));
+ let columnNumber = parseInt(line.slice(columnIndex + 1));
+ let name = line.slice(0, atIndex).split("(").shift();
+ frames.unshift({
+ fileName: fileName,
+ name: name,
+ lineNumber: lineNumber,
+ columnNumber: columnNumber
+ });
+ }
+ return frames;
+ }, []);
+}
+Loader.parseStack = parseStack;
+
+function serializeStack(frames) {
+ return frames.reduce(function(stack, frame) {
+ return frame.name + "@" +
+ frame.fileName + ":" +
+ frame.lineNumber + ":" +
+ frame.columnNumber + "\n" +
+ stack;
+ }, "");
+}
+Loader.serializeStack = serializeStack;
+
+class DefaultMap extends Map {
+ constructor(createItem, items = undefined) {
+ super(items);
+
+ this.createItem = createItem;
+ }
+
+ get(key) {
+ if (!this.has(key)) {
+ this.set(key, this.createItem(key));
+ }
+
+ return super.get(key);
+ }
+}
+
+const urlCache = {
+ /**
+ * Returns a list of fully-qualified URLs for entries within the zip
+ * file at the given URI which are either directories or files with a
+ * .js or .json extension.
+ *
+ * @param {nsIJARURI} uri
+ * @param {string} baseURL
+ * The original base URL, prior to resolution.
+ *
+ * @returns {Set<string>}
+ */
+ getZipFileContents(uri, baseURL) {
+ // Make sure the path has a trailing slash, and strip off the leading
+ // slash, so that we can easily check whether it is a path prefix.
+ let basePath = addTrailingSlash(uri.JAREntry).slice(1);
+ let file = uri.JARFile.QueryInterface(Ci.nsIFileURL).file;
+
+ let enumerator = zipCache.getZip(file).findEntries("(*.js|*.json|*/)");
+
+ let results = new Set();
+ for (let entry of XPCOMUtils.IterStringEnumerator(enumerator)) {
+ if (entry.startsWith(basePath)) {
+ let path = entry.slice(basePath.length);
+
+ results.add(baseURL + path);
+ }
+ }
+
+ return results;
+ },
+
+ zipContentsCache: new DefaultMap(baseURL => {
+ let uri = NetUtil.newURI(baseURL);
+
+ if (baseURL.startsWith("resource:")) {
+ uri = NetUtil.newURI(resProto.resolveURI(uri));
+ }
+
+ if (uri instanceof Ci.nsIJARURI) {
+ return urlCache.getZipFileContents(uri, baseURL);
+ }
+
+ return null;
+ }),
+
+ filesCache: new DefaultMap(url => {
+ try {
+ let uri = NetUtil.newURI(url).QueryInterface(Ci.nsIFileURL);
+
+ return uri.file.exists();
+ } catch (e) {
+ return false;
+ }
+ }),
+
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference]),
+
+ observe() {
+ // Clear any module resolution caches when the startup cache is flushed,
+ // since it probably means we're loading new copies of extensions.
+ this.zipContentsCache.clear();
+ this.filesCache.clear();
+ },
+
+ /**
+ * Returns the base URL for the given URL, if one can be determined. For
+ * a resource: URL, this is the root of the resource package. For a jar:
+ * URL, it is the root of the JAR file. Otherwise, null is returned.
+ *
+ * @param {string} url
+ * @returns {string?}
+ */
+ getBaseURL(url) {
+ // By using simple string matching for the common case of resource: URLs
+ // backed by jar: URLs, we can avoid creating any nsIURI objects for the
+ // common case where the JAR contents are already cached.
+ if (url.startsWith("resource://")) {
+ return /^resource:\/\/[^\/]+\//.exec(url)[0];
+ }
+
+ let uri = NetUtil.newURI(url);
+ if (uri instanceof Ci.nsIJARURI) {
+ return `jar:${uri.JARFile.spec}!/`;
+ }
+
+ return null;
+ },
+
+ /**
+ * Returns true if the target of the given URL exists as a local file,
+ * or as an entry in a local zip file.
+ *
+ * @param {string} url
+ * @returns {boolean}
+ */
+ exists(url) {
+ if (!/\.(?:js|json)$/.test(url)) {
+ url = addTrailingSlash(url);
+ }
+
+ let baseURL = this.getBaseURL(url);
+ let scripts = baseURL && this.zipContentsCache.get(baseURL);
+ if (scripts) {
+ return scripts.has(url);
+ }
+
+ return this.filesCache.get(url);
+ },
+}
+addObserver(urlCache, "startupcache-invalidate", true);
+
+function readURI(uri) {
+ let nsURI = NetUtil.newURI(uri);
+ if (nsURI.scheme == "resource") {
+ // Resolve to a real URI, this will catch any obvious bad paths without
+ // logging assertions in debug builds, see bug 1135219
+ uri = resProto.resolveURI(nsURI);
+ }
+
+ let stream = NetUtil.newChannel({
+ uri: NetUtil.newURI(uri, 'UTF-8'),
+ loadUsingSystemPrincipal: true}
+ ).open2();
+ let count = stream.available();
+ let data = NetUtil.readInputStreamToString(stream, count, {
+ charset: 'UTF-8'
+ });
+
+ stream.close();
+
+ return data;
+}
+
+// Combines all arguments into a resolved, normalized path
+function join(base, ...paths) {
+ // If this is an absolute URL, we need to normalize only the path portion,
+ // or we wind up stripping too many slashes and producing invalid URLs.
+ let match = /^((?:resource|file|chrome)\:\/\/[^\/]*|jar:[^!]+!)(.*)/.exec(base);
+ if (match) {
+ return match[1] + normalize(pathJoin(match[2], ...paths));
+ }
+
+ return normalize(pathJoin(base, ...paths));
+}
+Loader.join = join;
+
+// Function takes set of options and returns a JS sandbox. Function may be
+// passed set of options:
+// - `name`: A string value which identifies the sandbox in about:memory. Will
+// throw exception if omitted.
+// - `principal`: String URI or `nsIPrincipal` for the sandbox. Defaults to
+// system principal.
+// - `prototype`: Ancestor for the sandbox that will be created. Defaults to
+// `{}`.
+// - `wantXrays`: A Boolean value indicating whether code outside the sandbox
+// wants X-ray vision with respect to objects inside the sandbox. Defaults
+// to `true`.
+// - `sandbox`: A sandbox to share JS compartment with. If omitted new
+// compartment will be created.
+// - `metadata`: A metadata object associated with the sandbox. It should
+// be JSON-serializable.
+// For more details see:
+// https://developer.mozilla.org/en/Components.utils.Sandbox
+const Sandbox = iced(function Sandbox(options) {
+ // Normalize options and rename to match `Cu.Sandbox` expectations.
+ options = {
+ // Do not expose `Components` if you really need them (bad idea!) you
+ // still can expose via prototype.
+ wantComponents: false,
+ sandboxName: options.name,
+ principal: 'principal' in options ? options.principal : systemPrincipal,
+ wantXrays: 'wantXrays' in options ? options.wantXrays : true,
+ wantGlobalProperties: 'wantGlobalProperties' in options ?
+ options.wantGlobalProperties : [],
+ sandboxPrototype: 'prototype' in options ? options.prototype : {},
+ invisibleToDebugger: 'invisibleToDebugger' in options ?
+ options.invisibleToDebugger : false,
+ metadata: 'metadata' in options ? options.metadata : {},
+ waiveIntereposition: !!options.waiveIntereposition
+ };
+
+ if (options.metadata && options.metadata.addonID) {
+ options.addonId = options.metadata.addonID;
+ }
+
+ let sandbox = Cu.Sandbox(options.principal, options);
+
+ // Each sandbox at creation gets set of own properties that will be shadowing
+ // ones from it's prototype. We override delete such `sandbox` properties
+ // to avoid shadowing.
+ delete sandbox.Iterator;
+ delete sandbox.Components;
+ delete sandbox.importFunction;
+ delete sandbox.debug;
+
+ return sandbox;
+});
+Loader.Sandbox = Sandbox;
+
+// Evaluates code from the given `uri` into given `sandbox`. If
+// `options.source` is passed, then that code is evaluated instead.
+// Optionally following options may be given:
+// - `options.encoding`: Source encoding, defaults to 'UTF-8'.
+// - `options.line`: Line number to start count from for stack traces.
+// Defaults to 1.
+// - `options.version`: Version of JS used, defaults to '1.8'.
+const evaluate = iced(function evaluate(sandbox, uri, options) {
+ let { source, line, version, encoding } = override({
+ encoding: 'UTF-8',
+ line: 1,
+ version: '1.8',
+ source: null
+ }, options);
+
+ return source ? Cu.evalInSandbox(source, sandbox, version, uri, line)
+ : loadSubScript(uri, sandbox, encoding);
+});
+Loader.evaluate = evaluate;
+
+// Populates `exports` of the given CommonJS `module` object, in the context
+// of the given `loader` by evaluating code associated with it.
+const load = iced(function load(loader, module) {
+ let { sandboxes, globals, loadModuleHook } = loader;
+ let require = Require(loader, module);
+
+ // We expose set of properties defined by `CommonJS` specification via
+ // prototype of the sandbox. Also globals are deeper in the prototype
+ // chain so that each module has access to them as well.
+ let descriptors = descriptor({
+ require: require,
+ module: module,
+ exports: module.exports,
+ get Components() {
+ // Expose `Components` property to throw error on usage with
+ // additional information
+ throw new ReferenceError(COMPONENT_ERROR);
+ }
+ });
+
+ let sandbox;
+ if ((loader.useSharedGlobalSandbox || isSystemURI(module.uri)) &&
+ loader.sharedGlobalBlocklist.indexOf(module.id) == -1) {
+ // Create a new object in this sandbox, that will be used as
+ // the scope object for this particular module
+ sandbox = new loader.sharedGlobalSandbox.Object();
+ // Inject all expected globals in the scope object
+ getOwnIdentifiers(globals).forEach(function(name) {
+ descriptors[name] = getOwnPropertyDescriptor(globals, name)
+ descriptors[name].configurable = true;
+ });
+ Object.defineProperties(sandbox, descriptors);
+ }
+ else {
+ sandbox = Sandbox({
+ name: module.uri,
+ prototype: Object.create(globals, descriptors),
+ wantXrays: false,
+ wantGlobalProperties: module.id == "sdk/indexed-db" ? ["indexedDB"] : [],
+ invisibleToDebugger: loader.invisibleToDebugger,
+ metadata: {
+ addonID: loader.id,
+ URI: module.uri
+ }
+ });
+ }
+ sandboxes[module.uri] = sandbox;
+
+ try {
+ evaluate(sandbox, module.uri);
+ }
+ catch (error) {
+ let { message, fileName, lineNumber } = error;
+ let stack = error.stack || Error().stack;
+ let frames = parseStack(stack).filter(isntLoaderFrame);
+ let toString = String(error);
+ let file = sourceURI(fileName);
+
+ // Note that `String(error)` where error is from subscript loader does
+ // not puts `:` after `"Error"` unlike regular errors thrown by JS code.
+ // If there is a JS stack then this error has already been handled by an
+ // inner module load.
+ if (/^Error opening input stream/.test(String(error))) {
+ let caller = frames.slice(0).pop();
+ fileName = caller.fileName;
+ lineNumber = caller.lineNumber;
+ message = "Module `" + module.id + "` is not found at " + module.uri;
+ toString = message;
+ }
+ // Workaround for a Bug 910653. Errors thrown by subscript loader
+ // do not include `stack` field and above created error won't have
+ // fileName or lineNumber of the module being loaded, so we ensure
+ // it does.
+ else if (frames[frames.length - 1].fileName !== file) {
+ frames.push({ fileName: file, lineNumber: lineNumber, name: "" });
+ }
+
+ let prototype = typeof(error) === "object" ? error.constructor.prototype :
+ Error.prototype;
+
+ throw Object.create(prototype, {
+ message: { value: message, writable: true, configurable: true },
+ fileName: { value: fileName, writable: true, configurable: true },
+ lineNumber: { value: lineNumber, writable: true, configurable: true },
+ stack: { value: serializeStack(frames), writable: true, configurable: true },
+ toString: { value: () => toString, writable: true, configurable: true },
+ });
+ }
+
+ if (loadModuleHook) {
+ module = loadModuleHook(module, require);
+ }
+
+ if (loader.checkCompatibility) {
+ let err = XulApp.incompatibility(module);
+ if (err) {
+ throw err;
+ }
+ }
+
+ if (module.exports && typeof(module.exports) === 'object')
+ freeze(module.exports);
+
+ return module;
+});
+Loader.load = load;
+
+// Utility function to normalize module `uri`s so they have `.js` extension.
+function normalizeExt(uri) {
+ return isJSURI(uri) ? uri :
+ isJSONURI(uri) ? uri :
+ isJSMURI(uri) ? uri :
+ uri + '.js';
+}
+
+// Strips `rootURI` from `string` -- used to remove absolute resourceURI
+// from a relative path
+function stripBase(rootURI, string) {
+ return string.replace(rootURI, './');
+}
+
+// Utility function to join paths. In common case `base` is a
+// `requirer.uri` but in some cases it may be `baseURI`. In order to
+// avoid complexity we require `baseURI` with a trailing `/`.
+const resolve = iced(function resolve(id, base) {
+ if (!isRelative(id))
+ return id;
+
+ let baseDir = dirname(base);
+ if (!baseDir)
+ return normalize(id);
+
+ let resolved = join(baseDir, id);
+
+ // Joining and normalizing removes the './' from relative files.
+ // We need to ensure the resolution still has the root
+ if (isRelative(base))
+ resolved = './' + resolved;
+
+ return resolved;
+});
+Loader.resolve = resolve;
+
+// Attempts to load `path` and then `path.js`
+// Returns `path` with valid file, or `undefined` otherwise
+function resolveAsFile(path) {
+ // Append '.js' to path name unless it's another support filetype
+ path = normalizeExt(path);
+ if (urlCache.exists(path)) {
+ return path;
+ }
+
+ return null;
+}
+
+// Attempts to load `path/package.json`'s `main` entry,
+// followed by `path/index.js`, or `undefined` otherwise
+function resolveAsDirectory(path) {
+ try {
+ // If `path/package.json` exists, parse the `main` entry
+ // and attempt to load that
+ let manifestPath = addTrailingSlash(path) + 'package.json';
+
+ let main = (urlCache.exists(manifestPath) &&
+ getManifestMain(JSON.parse(readURI(manifestPath))));
+ if (main) {
+ let found = resolveAsFile(join(path, main));
+ if (found) {
+ return found
+ }
+ }
+ } catch (e) {}
+
+ return resolveAsFile(addTrailingSlash(path) + 'index.js');
+}
+
+function resolveRelative(rootURI, modulesDir, id) {
+ let fullId = join(rootURI, modulesDir, id);
+
+ let resolvedPath = (resolveAsFile(fullId) ||
+ resolveAsDirectory(fullId));
+ if (resolvedPath) {
+ return stripBase(rootURI, resolvedPath);
+ }
+
+ return null;
+}
+
+// From `resolve` module
+// https://github.com/substack/node-resolve/blob/master/lib/node-modules-paths.js
+function* getNodeModulePaths(rootURI, start) {
+ let moduleDir = 'node_modules';
+
+ let parts = start.split('/');
+ while (parts.length) {
+ let leaf = parts.pop();
+ let path = join(...parts, leaf, moduleDir);
+ if (leaf !== moduleDir && urlCache.exists(join(rootURI, path))) {
+ yield path;
+ }
+ }
+
+ if (urlCache.exists(join(rootURI, moduleDir))) {
+ yield moduleDir;
+ }
+}
+
+// Node-style module lookup
+// Takes an id and path and attempts to load a file using node's resolving
+// algorithm.
+// `id` should already be resolved relatively at this point.
+// http://nodejs.org/api/modules.html#modules_all_together
+const nodeResolve = iced(function nodeResolve(id, requirer, { rootURI }) {
+ // Resolve again
+ id = Loader.resolve(id, requirer);
+
+ // If this is already an absolute URI then there is no resolution to do
+ if (isAbsoluteURI(id)) {
+ return null;
+ }
+
+ // we assume that extensions are correct, i.e., a directory doesnt't have '.js'
+ // and a js file isn't named 'file.json.js'
+ let resolvedPath;
+
+ if ((resolvedPath = resolveRelative(rootURI, "", id))) {
+ return resolvedPath;
+ }
+
+ // If the requirer is an absolute URI then the node module resolution below
+ // won't work correctly as we prefix everything with rootURI
+ if (isAbsoluteURI(requirer)) {
+ return null;
+ }
+
+ // If manifest has dependencies, attempt to look up node modules
+ // in the `dependencies` list
+ for (let modulesDir of getNodeModulePaths(rootURI, dirname(requirer))) {
+ if ((resolvedPath = resolveRelative(rootURI, modulesDir, id))) {
+ return resolvedPath;
+ }
+ }
+
+ // We would not find lookup for things like `sdk/tabs`, as that's part of
+ // the alias mapping. If during `generateMap`, the runtime lookup resolves
+ // with `resolveURI` -- if during runtime, then `resolve` will throw.
+ return null;
+});
+
+Loader.nodeResolve = nodeResolve;
+
+function addTrailingSlash(path) {
+ return path.replace(/\/*$/, "/");
+}
+
+const resolveURI = iced(function resolveURI(id, mapping) {
+ // Do not resolve if already a resource URI
+ if (isAbsoluteURI(id))
+ return normalizeExt(id);
+
+ for (let [path, uri] of mapping) {
+ // Strip off any trailing slashes to make comparisons simpler
+ let stripped = path.replace(/\/+$/, "");
+
+ // We only want to match path segments explicitly. Examples:
+ // * "foo/bar" matches for "foo/bar"
+ // * "foo/bar" matches for "foo/bar/baz"
+ // * "foo/bar" does not match for "foo/bar-1"
+ // * "foo/bar/" does not match for "foo/bar"
+ // * "foo/bar/" matches for "foo/bar/baz"
+ //
+ // Check for an empty path, an exact match, or a substring match
+ // with the next character being a forward slash.
+ if(stripped === "" || id === stripped || id.startsWith(stripped + "/")) {
+ return normalizeExt(id.replace(path, uri));
+ }
+ }
+ return null;
+});
+Loader.resolveURI = resolveURI;
+
+// Creates version of `require` that will be exposed to the given `module`
+// in the context of the given `loader`. Each module gets own limited copy
+// of `require` that is allowed to load only a modules that are associated
+// with it during link time.
+const Require = iced(function Require(loader, requirer) {
+ let {
+ modules, mapping, resolve: loaderResolve, load,
+ manifest, rootURI, isNative, requireMap,
+ requireHook
+ } = loader;
+
+ if (isSystemURI(requirer.uri)) {
+ // Built-in modules don't require the expensive module resolution
+ // algorithm used by SDK add-ons, so give them the more efficient standard
+ // resolve instead.
+ isNative = false;
+ loaderResolve = Loader.resolve;
+ }
+
+ function require(id) {
+ if (!id) // Throw if `id` is not passed.
+ throw Error('You must provide a module name when calling require() from '
+ + requirer.id, requirer.uri);
+
+ if (requireHook) {
+ return requireHook(id, _require);
+ }
+
+ return _require(id);
+ }
+
+ function _require(id) {
+ let { uri, requirement } = getRequirements(id);
+ let module = null;
+ // If module is already cached by loader then just use it.
+ if (uri in modules) {
+ module = modules[uri];
+ }
+ else if (isJSMURI(uri)) {
+ module = modules[uri] = Module(requirement, uri);
+ module.exports = Cu.import(uri, {});
+ freeze(module);
+ }
+ else if (isJSONURI(uri)) {
+ let data;
+
+ // First attempt to load and parse json uri
+ // ex: `test.json`
+ // If that doesn't exist, check for `test.json.js`
+ // for node parity
+ try {
+ data = JSON.parse(readURI(uri));
+ module = modules[uri] = Module(requirement, uri);
+ module.exports = data;
+ freeze(module);
+ }
+ catch (err) {
+ // If error thrown from JSON parsing, throw that, do not
+ // attempt to find .json.js file
+ if (err && /JSON\.parse/.test(err.message))
+ throw err;
+ uri = uri + '.js';
+ }
+ }
+
+ // If not yet cached, load and cache it.
+ // We also freeze module to prevent it from further changes
+ // at runtime.
+ if (!(uri in modules)) {
+ // Many of the loader's functionalities are dependent
+ // on modules[uri] being set before loading, so we set it and
+ // remove it if we have any errors.
+ module = modules[uri] = Module(requirement, uri);
+ try {
+ freeze(load(loader, module));
+ }
+ catch (e) {
+ // Clear out modules cache so we can throw on a second invalid require
+ delete modules[uri];
+ // Also clear out the Sandbox that was created
+ delete loader.sandboxes[uri];
+ throw e;
+ }
+ }
+
+ return module.exports;
+ }
+
+ // Resolution function taking a module name/path and
+ // returning a resourceURI and a `requirement` used by the loader.
+ // Used by both `require` and `require.resolve`.
+ function getRequirements(id) {
+ if (!id) // Throw if `id` is not passed.
+ throw Error('you must provide a module name when calling require() from '
+ + requirer.id, requirer.uri);
+
+ let requirement, uri;
+
+ // TODO should get native Firefox modules before doing node-style lookups
+ // to save on loading time
+ if (isNative) {
+ // If a requireMap is available from `generateMap`, use that to
+ // immediately resolve the node-style mapping.
+ // TODO: write more tests for this use case
+ if (requireMap && requireMap[requirer.id])
+ requirement = requireMap[requirer.id][id];
+
+ let { overrides } = manifest.jetpack;
+ for (let key in overrides) {
+ // ignore any overrides using relative keys
+ if (/^[.\/]/.test(key)) {
+ continue;
+ }
+
+ // If the override is for x -> y,
+ // then using require("x/lib/z") to get reqire("y/lib/z")
+ // should also work
+ if (id == key || id.startsWith(key + "/")) {
+ id = overrides[key] + id.substr(key.length);
+ id = id.replace(/^[.\/]+/, "");
+ }
+ }
+
+ // For native modules, we want to check if it's a module specified
+ // in 'modules', like `chrome`, or `@loader` -- if it exists,
+ // just set the uri to skip resolution
+ if (!requirement && modules[id])
+ uri = requirement = id;
+
+ // If no requireMap was provided, or resolution not found in
+ // the requireMap, and not a npm dependency, attempt a runtime lookup
+ if (!requirement && !NODE_MODULES.has(id)) {
+ // If `isNative` defined, this is using the new, native-style
+ // loader, not cuddlefish, so lets resolve using node's algorithm
+ // and get back a path that needs to be resolved via paths mapping
+ // in `resolveURI`
+ requirement = loaderResolve(id, requirer.id, {
+ manifest: manifest,
+ rootURI: rootURI
+ });
+ }
+
+ // If not found in the map, not a node module, and wasn't able to be
+ // looked up, it's something
+ // found in the paths most likely, like `sdk/tabs`, which should
+ // be resolved relatively if needed using traditional resolve
+ if (!requirement) {
+ requirement = isRelative(id) ? Loader.resolve(id, requirer.id) : id;
+ }
+ }
+ else if (modules[id]) {
+ uri = requirement = id;
+ }
+ else if (requirer) {
+ // Resolve `id` to its requirer if it's relative.
+ requirement = loaderResolve(id, requirer.id);
+ }
+ else {
+ requirement = id;
+ }
+
+ // Resolves `uri` of module using loaders resolve function.
+ uri = uri || resolveURI(requirement, mapping);
+
+ // Throw if `uri` can not be resolved.
+ if (!uri) {
+ throw Error('Module: Can not resolve "' + id + '" module required by ' +
+ requirer.id + ' located at ' + requirer.uri, requirer.uri);
+ }
+
+ return { uri: uri, requirement: requirement };
+ }
+
+ // Expose the `resolve` function for this `Require` instance
+ require.resolve = _require.resolve = function resolve(id) {
+ let { uri } = getRequirements(id);
+ return uri;
+ }
+
+ // This is like webpack's require.context. It returns a new require
+ // function that prepends the prefix to any requests.
+ require.context = prefix => {
+ return id => {
+ return require(prefix + id);
+ };
+ };
+
+ // Make `require.main === module` evaluate to true in main module scope.
+ require.main = loader.main === requirer ? requirer : undefined;
+ return iced(require);
+});
+Loader.Require = Require;
+
+const main = iced(function main(loader, id) {
+ // If no main entry provided, and native loader is used,
+ // read the entry in the manifest
+ if (!id && loader.isNative)
+ id = getManifestMain(loader.manifest);
+ let uri = resolveURI(id, loader.mapping);
+ let module = loader.main = loader.modules[uri] = Module(id, uri);
+ return loader.load(loader, module).exports;
+});
+Loader.main = main;
+
+// Makes module object that is made available to CommonJS modules when they
+// are evaluated, along with `exports` and `require`.
+const Module = iced(function Module(id, uri) {
+ return Object.create(null, {
+ id: { enumerable: true, value: id },
+ exports: { enumerable: true, writable: true, value: Object.create(null),
+ configurable: true },
+ uri: { value: uri }
+ });
+});
+Loader.Module = Module;
+
+// Takes `loader`, and unload `reason` string and notifies all observers that
+// they should cleanup after them-self.
+const unload = iced(function unload(loader, reason) {
+ // subject is a unique object created per loader instance.
+ // This allows any code to cleanup on loader unload regardless of how
+ // it was loaded. To handle unload for specific loader subject may be
+ // asserted against loader.destructor or require('@loader/unload')
+ // Note: We don not destroy loader's module cache or sandboxes map as
+ // some modules may do cleanup in subsequent turns of event loop. Destroying
+ // cache may cause module identity problems in such cases.
+ let subject = { wrappedJSObject: loader.destructor };
+ notifyObservers(subject, 'sdk:loader:destroy', reason);
+});
+Loader.unload = unload;
+
+// Function makes new loader that can be used to load CommonJS modules
+// described by a given `options.manifest`. Loader takes following options:
+// - `globals`: Optional map of globals, that all module scopes will inherit
+// from. Map is also exposed under `globals` property of the returned loader
+// so it can be extended further later. Defaults to `{}`.
+// - `modules` Optional map of built-in module exports mapped by module id.
+// These modules will incorporated into module cache. Each module will be
+// frozen.
+// - `resolve` Optional module `id` resolution function. If given it will be
+// used to resolve module URIs, by calling it with require term, requirer
+// module object (that has `uri` property) and `baseURI` of the loader.
+// If `resolve` does not returns `uri` string exception will be thrown by
+// an associated `require` call.
+function Loader(options) {
+ if (options.sharedGlobalBlacklist && !options.sharedGlobalBlocklist) {
+ options.sharedGlobalBlocklist = options.sharedGlobalBlacklist;
+ }
+ let {
+ modules, globals, resolve, paths, rootURI, manifest, requireMap, isNative,
+ metadata, sharedGlobal, sharedGlobalBlocklist, checkCompatibility, waiveIntereposition
+ } = override({
+ paths: {},
+ modules: {},
+ globals: {
+ get console() {
+ // Import Console.jsm from here to prevent loading it until someone uses it
+ let { ConsoleAPI } = Cu.import("resource://gre/modules/Console.jsm");
+ let console = new ConsoleAPI({
+ consoleID: options.id ? "addon/" + options.id : ""
+ });
+ Object.defineProperty(this, "console", { value: console });
+ return this.console;
+ }
+ },
+ checkCompatibility: false,
+ resolve: options.isNative ?
+ // Make the returned resolve function have the same signature
+ (id, requirer) => Loader.nodeResolve(id, requirer, { rootURI: rootURI }) :
+ Loader.resolve,
+ sharedGlobalBlocklist: ["sdk/indexed-db"],
+ waiveIntereposition: false
+ }, options);
+
+ // Create overrides defaults, none at the moment
+ if (typeof manifest != "object" || !manifest) {
+ manifest = {};
+ }
+ if (typeof manifest.jetpack != "object" || !manifest.jetpack) {
+ manifest.jetpack = {
+ overrides: {}
+ };
+ }
+ if (typeof manifest.jetpack.overrides != "object" || !manifest.jetpack.overrides) {
+ manifest.jetpack.overrides = {};
+ }
+
+ // We create an identity object that will be dispatched on an unload
+ // event as subject. This way unload listeners will be able to assert
+ // which loader is unloaded. Please note that we intentionally don't
+ // use `loader` as subject to prevent a loader access leakage through
+ // observer notifications.
+ let destructor = freeze(Object.create(null));
+
+ // Make mapping array that is sorted from longest path to shortest path.
+ let mapping = Object.keys(paths)
+ .sort((a, b) => b.length - a.length)
+ .map(path => [path, paths[path]]);
+
+ // Define pseudo modules.
+ modules = override({
+ '@loader/unload': destructor,
+ '@loader/options': options,
+ 'chrome': { Cc: Cc, Ci: Ci, Cu: Cu, Cr: Cr, Cm: Cm,
+ CC: bind(CC, Components), components: Components,
+ // `ChromeWorker` has to be inject in loader global scope.
+ // It is done by bootstrap.js:loadSandbox for the SDK.
+ ChromeWorker: ChromeWorker
+ }
+ }, modules);
+
+ const builtinModuleExports = modules;
+ modules = {};
+ for (let id of Object.keys(builtinModuleExports)) {
+ // We resolve `uri` from `id` since modules are cached by `uri`.
+ let uri = resolveURI(id, mapping);
+ // In native loader, the mapping will not contain values for
+ // pseudomodules -- store them as their ID rather than the URI
+ if (isNative && !uri)
+ uri = id;
+ let module = Module(id, uri);
+
+ // Lazily expose built-in modules in order to
+ // allow them to be loaded lazily.
+ Object.defineProperty(module, "exports", {
+ enumerable: true,
+ get: function() {
+ return builtinModuleExports[id];
+ }
+ });
+
+ modules[uri] = freeze(module);
+ }
+
+ // Create the unique sandbox we will be using for all modules,
+ // so that we prevent creating a new comportment per module.
+ // The side effect is that all modules will share the same
+ // global objects.
+ let sharedGlobalSandbox = Sandbox({
+ name: "Addon-SDK",
+ wantXrays: false,
+ wantGlobalProperties: [],
+ invisibleToDebugger: options.invisibleToDebugger || false,
+ metadata: {
+ addonID: options.id,
+ URI: "Addon-SDK"
+ },
+ prototype: options.sandboxPrototype || {}
+ });
+
+ // Loader object is just a representation of a environment
+ // state. We freeze it and mark make it's properties non-enumerable
+ // as they are pure implementation detail that no one should rely upon.
+ let returnObj = {
+ destructor: { enumerable: false, value: destructor },
+ globals: { enumerable: false, value: globals },
+ mapping: { enumerable: false, value: mapping },
+ // Map of module objects indexed by module URIs.
+ modules: { enumerable: false, value: modules },
+ metadata: { enumerable: false, value: metadata },
+ useSharedGlobalSandbox: { enumerable: false, value: !!sharedGlobal },
+ sharedGlobalSandbox: { enumerable: false, value: sharedGlobalSandbox },
+ sharedGlobalBlocklist: { enumerable: false, value: sharedGlobalBlocklist },
+ sharedGlobalBlacklist: { enumerable: false, value: sharedGlobalBlocklist },
+ // Map of module sandboxes indexed by module URIs.
+ sandboxes: { enumerable: false, value: {} },
+ resolve: { enumerable: false, value: resolve },
+ // ID of the addon, if provided.
+ id: { enumerable: false, value: options.id },
+ // Whether the modules loaded should be ignored by the debugger
+ invisibleToDebugger: { enumerable: false,
+ value: options.invisibleToDebugger || false },
+ load: { enumerable: false, value: options.load || load },
+ checkCompatibility: { enumerable: false, value: checkCompatibility },
+ requireHook: { enumerable: false, value: options.requireHook },
+ loadModuleHook: { enumerable: false, value: options.loadModuleHook },
+ // Main (entry point) module, it can be set only once, since loader
+ // instance can have only one main module.
+ main: new function() {
+ let main;
+ return {
+ enumerable: false,
+ get: function() { return main; },
+ // Only set main if it has not being set yet!
+ set: function(module) { main = main || module; }
+ }
+ }
+ };
+
+ if (isNative) {
+ returnObj.isNative = { enumerable: false, value: true };
+ returnObj.manifest = { enumerable: false, value: manifest };
+ returnObj.requireMap = { enumerable: false, value: requireMap };
+ returnObj.rootURI = { enumerable: false, value: addTrailingSlash(rootURI) };
+ }
+
+ return freeze(Object.create(null, returnObj));
+};
+Loader.Loader = Loader;
+
+var isSystemURI = uri => /^resource:\/\/(gre|devtools|testing-common)\//.test(uri);
+
+var isJSONURI = uri => uri.endsWith('.json');
+var isJSMURI = uri => uri.endsWith('.jsm');
+var isJSURI = uri => uri.endsWith('.js');
+var isAbsoluteURI = uri => uri.startsWith("resource://") ||
+ uri.startsWith("chrome://") ||
+ uri.startsWith("file://");
+var isRelative = id => id.startsWith(".");
+
+// Default `main` entry to './index.js' and ensure is relative,
+// since node allows 'lib/index.js' without relative `./`
+function getManifestMain(manifest) {
+ let main = manifest.main || './index.js';
+ return isRelative(main) ? main : './' + main;
+}
+
+module.exports = iced(Loader);
+});
diff --git a/toolkit/jetpack/toolkit/require.js b/toolkit/jetpack/toolkit/require.js
new file mode 100644
index 000000000..dc3d26ab2
--- /dev/null
+++ b/toolkit/jetpack/toolkit/require.js
@@ -0,0 +1,91 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const make = (exports, rootURI, components) => {
+ const { Loader: { Loader, Require, Module, main } } =
+ components.utils.import(rootURI + "toolkit/loader.js", {});
+
+ const loader = Loader({
+ id: "toolkit/require",
+ rootURI: rootURI,
+ isNative: true,
+ paths: {
+ "": rootURI,
+ "devtools/": "resource://devtools/"
+ }
+ });
+
+ // Implement require.unload(uri) that can be used to unload
+ // already loaded module which is convinient during development phase.
+ const unload = uri => {
+ delete loader.sandboxes[uri];
+ delete loader.modules[uri];
+ };
+
+ const builtins = new Set(Object.keys(loader.modules));
+
+ // Below we define `require` & `require.resolve` that resolve passed
+ // module id relative to the caller URI. This is not perfect but good
+ // enough for common case & there is always an option to pass absolute
+ // id when that
+ // but presumably well enough to cover
+
+ const require = (id, options={}) => {
+ const { reload, all } = options;
+ const requirerURI = components.stack.caller.filename;
+ const requirer = Module(requirerURI, requirerURI);
+ const require = Require(loader, requirer);
+ if (reload) {
+ // To load JS code into modules, loader uses `mozIJSSubScriptLoader`
+ // which uses startup cache to avoid reading source from the same URI
+ // more than once. Unless we invalidate statup cache changes to a module
+ // won't be reflected even after reload. Therefor we must dispatch an
+ // nsIObserverService notification that causes cache invalidation.
+ // Note: This is not ideal since it destroys whole cache, but since there
+ // is no way to invalidate individual entries, we assume performance hit
+ // during development is acceptable.
+ components.classes["@mozilla.org/observer-service;1"].
+ getService(components.interfaces.nsIObserverService).
+ notifyObservers({}, "startupcache-invalidate", null);
+
+ if (all) {
+ for (let uri of Object.keys(loader.sandboxes)) {
+ unload(uri);
+ }
+ }
+ else {
+ unload(require.resolve(id));
+ }
+ }
+ return require(id);
+ };
+
+ require.resolve = id => {
+ const requirerURI = components.stack.caller.filename;
+ const requirer = Module(requirerURI, requirerURI);
+ return Require(loader, requirer).resolve(id);
+ };
+
+ exports.require = require;
+}
+
+// If loaded in the context of commonjs module, reload as JSM into an
+// exports object.
+if (typeof(require) === "function" && typeof(module) === "object") {
+ require("chrome").Cu.import(module.uri, module.exports);
+}
+// If loaded in the context of JSM make a loader & require and define
+// new symbols as exported ones.
+else if (typeof(__URI__) === "string" && this["Components"]) {
+ const builtin = Object.keys(this);
+ const uri = __URI__.replace("toolkit/require.js", "");
+ make(this, uri, this["Components"]);
+
+ this.EXPORTED_SYMBOLS = Object.
+ keys(this).
+ filter($ => builtin.indexOf($) < 0);
+}
+else {
+ throw Error("Loading require.js in this environment isn't supported")
+}
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/about.dtd b/toolkit/locales/en-US/chrome/mozapps/webextensions/about.dtd
index 4f9098966..4f9098966 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/about.dtd
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/about.dtd
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/blocklist.dtd b/toolkit/locales/en-US/chrome/mozapps/webextensions/blocklist.dtd
index f393cc906..f393cc906 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/blocklist.dtd
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/blocklist.dtd
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd b/toolkit/locales/en-US/chrome/mozapps/webextensions/extensions.dtd
index 99c940b33..99c940b33 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/extensions.dtd
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.properties b/toolkit/locales/en-US/chrome/mozapps/webextensions/extensions.properties
index 10c0f81c3..10c0f81c3 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/extensions.properties
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/newaddon.dtd b/toolkit/locales/en-US/chrome/mozapps/webextensions/newaddon.dtd
index 1307cebb9..1307cebb9 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/newaddon.dtd
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/newaddon.dtd
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/newaddon.properties b/toolkit/locales/en-US/chrome/mozapps/webextensions/newaddon.properties
index bd5997a26..bd5997a26 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/newaddon.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/newaddon.properties
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/update.dtd b/toolkit/locales/en-US/chrome/mozapps/webextensions/update.dtd
index 6dd64a9c6..6dd64a9c6 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/update.dtd
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/update.dtd
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/update.properties b/toolkit/locales/en-US/chrome/mozapps/webextensions/update.properties
index c2d4ed90f..c2d4ed90f 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/update.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/update.properties
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/xpinstallConfirm.dtd b/toolkit/locales/en-US/chrome/mozapps/webextensions/xpinstallConfirm.dtd
index 6a7d17a16..6a7d17a16 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/xpinstallConfirm.dtd
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/xpinstallConfirm.dtd
diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/xpinstallConfirm.properties b/toolkit/locales/en-US/chrome/mozapps/webextensions/xpinstallConfirm.properties
index d0b4e46ad..d0b4e46ad 100644
--- a/toolkit/locales/en-US/chrome/mozapps/extensions/xpinstallConfirm.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/webextensions/xpinstallConfirm.properties
diff --git a/toolkit/locales/jar.mn b/toolkit/locales/jar.mn
index c28cf6f49..e42f0de00 100644
--- a/toolkit/locales/jar.mn
+++ b/toolkit/locales/jar.mn
@@ -105,15 +105,17 @@
locale/@AB_CD@/mozapps/downloads/settingsChange.dtd (%chrome/mozapps/downloads/settingsChange.dtd)
locale/@AB_CD@/mozapps/downloads/downloads.dtd (%chrome/mozapps/downloads/downloads.dtd)
locale/@AB_CD@/mozapps/downloads/downloads.properties (%chrome/mozapps/downloads/downloads.properties)
- locale/@AB_CD@/mozapps/extensions/extensions.dtd (%chrome/mozapps/extensions/extensions.dtd)
+#ifdef MOZ_WEBEXTENSIONS
+ locale/@AB_CD@/mozapps/extensions/extensions.dtd (%chrome/mozapps/webextensions/extensions.dtd)
#ifndef MOZ_FENNEC
- locale/@AB_CD@/mozapps/extensions/extensions.properties (%chrome/mozapps/extensions/extensions.properties)
- locale/@AB_CD@/mozapps/extensions/blocklist.dtd (%chrome/mozapps/extensions/blocklist.dtd)
- locale/@AB_CD@/mozapps/extensions/about.dtd (%chrome/mozapps/extensions/about.dtd)
- locale/@AB_CD@/mozapps/extensions/update.dtd (%chrome/mozapps/extensions/update.dtd)
- locale/@AB_CD@/mozapps/extensions/update.properties (%chrome/mozapps/extensions/update.properties)
- locale/@AB_CD@/mozapps/extensions/newaddon.dtd (%chrome/mozapps/extensions/newaddon.dtd)
- locale/@AB_CD@/mozapps/extensions/newaddon.properties (%chrome/mozapps/extensions/newaddon.properties)
+ locale/@AB_CD@/mozapps/extensions/extensions.properties (%chrome/mozapps/webextensions/extensions.properties)
+ locale/@AB_CD@/mozapps/extensions/blocklist.dtd (%chrome/mozapps/webextensions/blocklist.dtd)
+ locale/@AB_CD@/mozapps/extensions/about.dtd (%chrome/mozapps/webextensions/about.dtd)
+ locale/@AB_CD@/mozapps/extensions/update.dtd (%chrome/mozapps/webextensions/update.dtd)
+ locale/@AB_CD@/mozapps/extensions/update.properties (%chrome/mozapps/webextensions/update.properties)
+ locale/@AB_CD@/mozapps/extensions/newaddon.dtd (%chrome/mozapps/webextensions/newaddon.dtd)
+ locale/@AB_CD@/mozapps/extensions/newaddon.properties (%chrome/mozapps/webextensions/newaddon.properties)
+#endif
#endif
locale/@AB_CD@/mozapps/handling/handling.dtd (%chrome/mozapps/handling/handling.dtd)
locale/@AB_CD@/mozapps/handling/handling.properties (%chrome/mozapps/handling/handling.properties)
@@ -128,8 +130,10 @@
locale/@AB_CD@/mozapps/update/updates.properties (%chrome/mozapps/update/updates.properties)
#endif
locale/@AB_CD@/mozapps/update/history.dtd (%chrome/mozapps/update/history.dtd)
- locale/@AB_CD@/mozapps/xpinstall/xpinstallConfirm.dtd (%chrome/mozapps/extensions/xpinstallConfirm.dtd)
- locale/@AB_CD@/mozapps/xpinstall/xpinstallConfirm.properties (%chrome/mozapps/extensions/xpinstallConfirm.properties)
+#ifdef MOZ_WEBEXTENSIONS
+ locale/@AB_CD@/mozapps/xpinstall/xpinstallConfirm.dtd (%chrome/mozapps/webextensions/xpinstallConfirm.dtd)
+ locale/@AB_CD@/mozapps/xpinstall/xpinstallConfirm.properties (%chrome/mozapps/webextensions/xpinstallConfirm.properties)
+#endif
% locale pluginproblem @AB_CD@ %locale/@AB_CD@/pluginproblem/
locale/@AB_CD@/pluginproblem/pluginproblem.dtd (%chrome/pluginproblem/pluginproblem.dtd)
% locale alerts @AB_CD@ %locale/@AB_CD@/alerts/
diff --git a/toolkit/moz.build b/toolkit/moz.build
index 8fe5126ca..9501938ae 100644
--- a/toolkit/moz.build
+++ b/toolkit/moz.build
@@ -9,10 +9,10 @@ DIRS += [
'content',
'forgetaboutsite',
'identity',
+ 'jetpack',
'locales',
'modules',
'mozapps/downloads',
- 'mozapps/extensions',
'mozapps/handling',
'mozapps/preferences',
'obsolete',
@@ -21,6 +21,9 @@ DIRS += [
'themes',
]
+if CONFIG['MOZ_WEBEXTENSIONS']:
+ DIRS += ['mozapps/webextensions']
+
if CONFIG['MOZ_UPDATER'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
DIRS += ['mozapps/update']
diff --git a/toolkit/mozapps/extensions/.eslintrc.js b/toolkit/mozapps/webextensions/.eslintrc.js
index 2b90bd053..2b90bd053 100644
--- a/toolkit/mozapps/extensions/.eslintrc.js
+++ b/toolkit/mozapps/webextensions/.eslintrc.js
diff --git a/toolkit/mozapps/extensions/AddonContentPolicy.cpp b/toolkit/mozapps/webextensions/AddonContentPolicy.cpp
index 90e53b2ea..90e53b2ea 100644
--- a/toolkit/mozapps/extensions/AddonContentPolicy.cpp
+++ b/toolkit/mozapps/webextensions/AddonContentPolicy.cpp
diff --git a/toolkit/mozapps/extensions/AddonContentPolicy.h b/toolkit/mozapps/webextensions/AddonContentPolicy.h
index 4c8af4828..4c8af4828 100644
--- a/toolkit/mozapps/extensions/AddonContentPolicy.h
+++ b/toolkit/mozapps/webextensions/AddonContentPolicy.h
diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/webextensions/AddonManager.jsm
index c5cb80091..c5cb80091 100644
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/webextensions/AddonManager.jsm
diff --git a/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp b/toolkit/mozapps/webextensions/AddonManagerWebAPI.cpp
index 3f2a7a529..3f2a7a529 100644
--- a/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
+++ b/toolkit/mozapps/webextensions/AddonManagerWebAPI.cpp
diff --git a/toolkit/mozapps/extensions/AddonManagerWebAPI.h b/toolkit/mozapps/webextensions/AddonManagerWebAPI.h
index 6830bc91f..6830bc91f 100644
--- a/toolkit/mozapps/extensions/AddonManagerWebAPI.h
+++ b/toolkit/mozapps/webextensions/AddonManagerWebAPI.h
diff --git a/toolkit/mozapps/extensions/AddonPathService.cpp b/toolkit/mozapps/webextensions/AddonPathService.cpp
index 8a405c0ea..8a405c0ea 100644
--- a/toolkit/mozapps/extensions/AddonPathService.cpp
+++ b/toolkit/mozapps/webextensions/AddonPathService.cpp
diff --git a/toolkit/mozapps/extensions/AddonPathService.h b/toolkit/mozapps/webextensions/AddonPathService.h
index f739b018f..f739b018f 100644
--- a/toolkit/mozapps/extensions/AddonPathService.h
+++ b/toolkit/mozapps/webextensions/AddonPathService.h
diff --git a/toolkit/mozapps/extensions/ChromeManifestParser.jsm b/toolkit/mozapps/webextensions/ChromeManifestParser.jsm
index 63f1db785..63f1db785 100644
--- a/toolkit/mozapps/extensions/ChromeManifestParser.jsm
+++ b/toolkit/mozapps/webextensions/ChromeManifestParser.jsm
diff --git a/toolkit/mozapps/extensions/DeferredSave.jsm b/toolkit/mozapps/webextensions/DeferredSave.jsm
index 89f82b265..89f82b265 100644
--- a/toolkit/mozapps/extensions/DeferredSave.jsm
+++ b/toolkit/mozapps/webextensions/DeferredSave.jsm
diff --git a/toolkit/mozapps/extensions/LightweightThemeManager.jsm b/toolkit/mozapps/webextensions/LightweightThemeManager.jsm
index 5dd41831d..5dd41831d 100644
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/webextensions/LightweightThemeManager.jsm
diff --git a/toolkit/mozapps/extensions/addonManager.js b/toolkit/mozapps/webextensions/addonManager.js
index d34cbaf62..d34cbaf62 100644
--- a/toolkit/mozapps/extensions/addonManager.js
+++ b/toolkit/mozapps/webextensions/addonManager.js
diff --git a/toolkit/mozapps/extensions/amContentHandler.js b/toolkit/mozapps/webextensions/amContentHandler.js
index 8dc4dfecd..8dc4dfecd 100644
--- a/toolkit/mozapps/extensions/amContentHandler.js
+++ b/toolkit/mozapps/webextensions/amContentHandler.js
diff --git a/toolkit/mozapps/extensions/amIAddonManager.idl b/toolkit/mozapps/webextensions/amIAddonManager.idl
index 58a58b62d..58a58b62d 100644
--- a/toolkit/mozapps/extensions/amIAddonManager.idl
+++ b/toolkit/mozapps/webextensions/amIAddonManager.idl
diff --git a/toolkit/mozapps/extensions/amIAddonPathService.idl b/toolkit/mozapps/webextensions/amIAddonPathService.idl
index 9c9197a61..9c9197a61 100644
--- a/toolkit/mozapps/extensions/amIAddonPathService.idl
+++ b/toolkit/mozapps/webextensions/amIAddonPathService.idl
diff --git a/toolkit/mozapps/extensions/amIWebInstallListener.idl b/toolkit/mozapps/webextensions/amIWebInstallListener.idl
index eed108097..eed108097 100644
--- a/toolkit/mozapps/extensions/amIWebInstallListener.idl
+++ b/toolkit/mozapps/webextensions/amIWebInstallListener.idl
diff --git a/toolkit/mozapps/extensions/amIWebInstaller.idl b/toolkit/mozapps/webextensions/amIWebInstaller.idl
index 6c5ebca67..6c5ebca67 100644
--- a/toolkit/mozapps/extensions/amIWebInstaller.idl
+++ b/toolkit/mozapps/webextensions/amIWebInstaller.idl
diff --git a/toolkit/mozapps/extensions/amInstallTrigger.js b/toolkit/mozapps/webextensions/amInstallTrigger.js
index 382791d32..382791d32 100644
--- a/toolkit/mozapps/extensions/amInstallTrigger.js
+++ b/toolkit/mozapps/webextensions/amInstallTrigger.js
diff --git a/toolkit/mozapps/extensions/amWebAPI.js b/toolkit/mozapps/webextensions/amWebAPI.js
index 5ad0d23f1..5ad0d23f1 100644
--- a/toolkit/mozapps/extensions/amWebAPI.js
+++ b/toolkit/mozapps/webextensions/amWebAPI.js
diff --git a/toolkit/mozapps/extensions/amWebInstallListener.js b/toolkit/mozapps/webextensions/amWebInstallListener.js
index 0bcc345e8..0bcc345e8 100644
--- a/toolkit/mozapps/extensions/amWebInstallListener.js
+++ b/toolkit/mozapps/webextensions/amWebInstallListener.js
diff --git a/toolkit/mozapps/extensions/content/OpenH264-license.txt b/toolkit/mozapps/webextensions/content/OpenH264-license.txt
index ad37989b8..ad37989b8 100644
--- a/toolkit/mozapps/extensions/content/OpenH264-license.txt
+++ b/toolkit/mozapps/webextensions/content/OpenH264-license.txt
diff --git a/toolkit/mozapps/extensions/content/about.js b/toolkit/mozapps/webextensions/content/about.js
index 4f8fb353e..4f8fb353e 100644
--- a/toolkit/mozapps/extensions/content/about.js
+++ b/toolkit/mozapps/webextensions/content/about.js
diff --git a/toolkit/mozapps/extensions/content/about.xul b/toolkit/mozapps/webextensions/content/about.xul
index 6effcf37a..6effcf37a 100644
--- a/toolkit/mozapps/extensions/content/about.xul
+++ b/toolkit/mozapps/webextensions/content/about.xul
diff --git a/toolkit/mozapps/extensions/content/blocklist.css b/toolkit/mozapps/webextensions/content/blocklist.css
index cb48005a2..cb48005a2 100644
--- a/toolkit/mozapps/extensions/content/blocklist.css
+++ b/toolkit/mozapps/webextensions/content/blocklist.css
diff --git a/toolkit/mozapps/extensions/content/blocklist.js b/toolkit/mozapps/webextensions/content/blocklist.js
index 6d524e6ee..6d524e6ee 100644
--- a/toolkit/mozapps/extensions/content/blocklist.js
+++ b/toolkit/mozapps/webextensions/content/blocklist.js
diff --git a/toolkit/mozapps/extensions/content/blocklist.xml b/toolkit/mozapps/webextensions/content/blocklist.xml
index 74474392f..74474392f 100644
--- a/toolkit/mozapps/extensions/content/blocklist.xml
+++ b/toolkit/mozapps/webextensions/content/blocklist.xml
diff --git a/toolkit/mozapps/extensions/content/blocklist.xul b/toolkit/mozapps/webextensions/content/blocklist.xul
index 240d9e4e1..240d9e4e1 100644
--- a/toolkit/mozapps/extensions/content/blocklist.xul
+++ b/toolkit/mozapps/webextensions/content/blocklist.xul
diff --git a/toolkit/mozapps/extensions/content/eula.js b/toolkit/mozapps/webextensions/content/eula.js
index 537ee7284..537ee7284 100644
--- a/toolkit/mozapps/extensions/content/eula.js
+++ b/toolkit/mozapps/webextensions/content/eula.js
diff --git a/toolkit/mozapps/extensions/content/eula.xul b/toolkit/mozapps/webextensions/content/eula.xul
index 10e657951..10e657951 100644
--- a/toolkit/mozapps/extensions/content/eula.xul
+++ b/toolkit/mozapps/webextensions/content/eula.xul
diff --git a/toolkit/mozapps/extensions/content/extensions.css b/toolkit/mozapps/webextensions/content/extensions.css
index cb5313365..cb5313365 100644
--- a/toolkit/mozapps/extensions/content/extensions.css
+++ b/toolkit/mozapps/webextensions/content/extensions.css
diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/webextensions/content/extensions.js
index 56158d9c6..56158d9c6 100644
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/webextensions/content/extensions.js
diff --git a/toolkit/mozapps/extensions/content/extensions.xml b/toolkit/mozapps/webextensions/content/extensions.xml
index b49645cf0..b49645cf0 100644
--- a/toolkit/mozapps/extensions/content/extensions.xml
+++ b/toolkit/mozapps/webextensions/content/extensions.xml
diff --git a/toolkit/mozapps/extensions/content/extensions.xul b/toolkit/mozapps/webextensions/content/extensions.xul
index 70939d024..70939d024 100644
--- a/toolkit/mozapps/extensions/content/extensions.xul
+++ b/toolkit/mozapps/webextensions/content/extensions.xul
diff --git a/toolkit/mozapps/extensions/content/gmpPrefs.xul b/toolkit/mozapps/webextensions/content/gmpPrefs.xul
index ea7ee92fa..ea7ee92fa 100644
--- a/toolkit/mozapps/extensions/content/gmpPrefs.xul
+++ b/toolkit/mozapps/webextensions/content/gmpPrefs.xul
diff --git a/toolkit/mozapps/extensions/content/list.js b/toolkit/mozapps/webextensions/content/list.js
index a31922703..a31922703 100644
--- a/toolkit/mozapps/extensions/content/list.js
+++ b/toolkit/mozapps/webextensions/content/list.js
diff --git a/toolkit/mozapps/extensions/content/list.xul b/toolkit/mozapps/webextensions/content/list.xul
index 65efeb6a2..65efeb6a2 100644
--- a/toolkit/mozapps/extensions/content/list.xul
+++ b/toolkit/mozapps/webextensions/content/list.xul
diff --git a/toolkit/mozapps/extensions/content/newaddon.js b/toolkit/mozapps/webextensions/content/newaddon.js
index b1ad5631b..b1ad5631b 100644
--- a/toolkit/mozapps/extensions/content/newaddon.js
+++ b/toolkit/mozapps/webextensions/content/newaddon.js
diff --git a/toolkit/mozapps/extensions/content/newaddon.xul b/toolkit/mozapps/webextensions/content/newaddon.xul
index 1d8545249..1d8545249 100644
--- a/toolkit/mozapps/extensions/content/newaddon.xul
+++ b/toolkit/mozapps/webextensions/content/newaddon.xul
diff --git a/toolkit/mozapps/extensions/content/pluginPrefs.xul b/toolkit/mozapps/webextensions/content/pluginPrefs.xul
index c3fdbfa5b..c3fdbfa5b 100644
--- a/toolkit/mozapps/extensions/content/pluginPrefs.xul
+++ b/toolkit/mozapps/webextensions/content/pluginPrefs.xul
diff --git a/toolkit/mozapps/extensions/content/setting.xml b/toolkit/mozapps/webextensions/content/setting.xml
index 2b70eb0d0..2b70eb0d0 100644
--- a/toolkit/mozapps/extensions/content/setting.xml
+++ b/toolkit/mozapps/webextensions/content/setting.xml
diff --git a/toolkit/mozapps/extensions/content/update.js b/toolkit/mozapps/webextensions/content/update.js
index 80d0fa688..80d0fa688 100644
--- a/toolkit/mozapps/extensions/content/update.js
+++ b/toolkit/mozapps/webextensions/content/update.js
diff --git a/toolkit/mozapps/extensions/content/update.xul b/toolkit/mozapps/webextensions/content/update.xul
index 745983814..745983814 100644
--- a/toolkit/mozapps/extensions/content/update.xul
+++ b/toolkit/mozapps/webextensions/content/update.xul
diff --git a/toolkit/mozapps/extensions/content/updateinfo.xsl b/toolkit/mozapps/webextensions/content/updateinfo.xsl
index 5fcccd6d7..5fcccd6d7 100644
--- a/toolkit/mozapps/extensions/content/updateinfo.xsl
+++ b/toolkit/mozapps/webextensions/content/updateinfo.xsl
diff --git a/toolkit/mozapps/extensions/content/xpinstallConfirm.css b/toolkit/mozapps/webextensions/content/xpinstallConfirm.css
index 583facfec..583facfec 100644
--- a/toolkit/mozapps/extensions/content/xpinstallConfirm.css
+++ b/toolkit/mozapps/webextensions/content/xpinstallConfirm.css
diff --git a/toolkit/mozapps/extensions/content/xpinstallConfirm.js b/toolkit/mozapps/webextensions/content/xpinstallConfirm.js
index 5660cdaaf..5660cdaaf 100644
--- a/toolkit/mozapps/extensions/content/xpinstallConfirm.js
+++ b/toolkit/mozapps/webextensions/content/xpinstallConfirm.js
diff --git a/toolkit/mozapps/extensions/content/xpinstallConfirm.xul b/toolkit/mozapps/webextensions/content/xpinstallConfirm.xul
index f1c29eb73..f1c29eb73 100644
--- a/toolkit/mozapps/extensions/content/xpinstallConfirm.xul
+++ b/toolkit/mozapps/webextensions/content/xpinstallConfirm.xul
diff --git a/toolkit/mozapps/extensions/content/xpinstallItem.xml b/toolkit/mozapps/webextensions/content/xpinstallItem.xml
index 5146af84f..5146af84f 100644
--- a/toolkit/mozapps/extensions/content/xpinstallItem.xml
+++ b/toolkit/mozapps/webextensions/content/xpinstallItem.xml
diff --git a/toolkit/mozapps/extensions/docs/SystemAddons.rst b/toolkit/mozapps/webextensions/docs/SystemAddons.rst
index 5f724e9ef..5f724e9ef 100644
--- a/toolkit/mozapps/extensions/docs/SystemAddons.rst
+++ b/toolkit/mozapps/webextensions/docs/SystemAddons.rst
diff --git a/toolkit/mozapps/extensions/docs/index.rst b/toolkit/mozapps/webextensions/docs/index.rst
index ab6ed3c70..ab6ed3c70 100644
--- a/toolkit/mozapps/extensions/docs/index.rst
+++ b/toolkit/mozapps/webextensions/docs/index.rst
diff --git a/toolkit/mozapps/extensions/extensions.manifest b/toolkit/mozapps/webextensions/extensions.manifest
index c7d2ee386..c7d2ee386 100644
--- a/toolkit/mozapps/extensions/extensions.manifest
+++ b/toolkit/mozapps/webextensions/extensions.manifest
diff --git a/toolkit/mozapps/extensions/internal/APIExtensionBootstrap.js b/toolkit/mozapps/webextensions/internal/APIExtensionBootstrap.js
index 0eae2475c..0eae2475c 100644
--- a/toolkit/mozapps/extensions/internal/APIExtensionBootstrap.js
+++ b/toolkit/mozapps/webextensions/internal/APIExtensionBootstrap.js
diff --git a/toolkit/mozapps/extensions/internal/AddonConstants.jsm b/toolkit/mozapps/webextensions/internal/AddonConstants.jsm
index 22d91fdf5..22d91fdf5 100644
--- a/toolkit/mozapps/extensions/internal/AddonConstants.jsm
+++ b/toolkit/mozapps/webextensions/internal/AddonConstants.jsm
diff --git a/toolkit/mozapps/extensions/internal/AddonLogging.jsm b/toolkit/mozapps/webextensions/internal/AddonLogging.jsm
index f05a6fe6c..f05a6fe6c 100644
--- a/toolkit/mozapps/extensions/internal/AddonLogging.jsm
+++ b/toolkit/mozapps/webextensions/internal/AddonLogging.jsm
diff --git a/toolkit/mozapps/extensions/internal/AddonRepository.jsm b/toolkit/mozapps/webextensions/internal/AddonRepository.jsm
index 7f88d44ad..7f88d44ad 100644
--- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm
+++ b/toolkit/mozapps/webextensions/internal/AddonRepository.jsm
diff --git a/toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm b/toolkit/mozapps/webextensions/internal/AddonRepository_SQLiteMigrator.jsm
index e3479643b..e3479643b 100644
--- a/toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm
+++ b/toolkit/mozapps/webextensions/internal/AddonRepository_SQLiteMigrator.jsm
diff --git a/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm b/toolkit/mozapps/webextensions/internal/AddonTestUtils.jsm
index 6422929b1..6422929b1 100644
--- a/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
+++ b/toolkit/mozapps/webextensions/internal/AddonTestUtils.jsm
diff --git a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm b/toolkit/mozapps/webextensions/internal/AddonUpdateChecker.jsm
index 63c16737c..63c16737c 100644
--- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/webextensions/internal/AddonUpdateChecker.jsm
diff --git a/toolkit/mozapps/extensions/internal/Content.js b/toolkit/mozapps/webextensions/internal/Content.js
index 9f366ba32..9f366ba32 100644
--- a/toolkit/mozapps/extensions/internal/Content.js
+++ b/toolkit/mozapps/webextensions/internal/Content.js
diff --git a/toolkit/mozapps/extensions/internal/E10SAddonsRollout.jsm b/toolkit/mozapps/webextensions/internal/E10SAddonsRollout.jsm
index 3bcee44d3..3bcee44d3 100644
--- a/toolkit/mozapps/extensions/internal/E10SAddonsRollout.jsm
+++ b/toolkit/mozapps/webextensions/internal/E10SAddonsRollout.jsm
diff --git a/toolkit/mozapps/extensions/internal/GMPProvider.jsm b/toolkit/mozapps/webextensions/internal/GMPProvider.jsm
index 9bb34a7af..9bb34a7af 100644
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/webextensions/internal/GMPProvider.jsm
diff --git a/toolkit/mozapps/extensions/internal/LightweightThemeImageOptimizer.jsm b/toolkit/mozapps/webextensions/internal/LightweightThemeImageOptimizer.jsm
index 49dfa237f..49dfa237f 100644
--- a/toolkit/mozapps/extensions/internal/LightweightThemeImageOptimizer.jsm
+++ b/toolkit/mozapps/webextensions/internal/LightweightThemeImageOptimizer.jsm
diff --git a/toolkit/mozapps/extensions/internal/PluginProvider.jsm b/toolkit/mozapps/webextensions/internal/PluginProvider.jsm
index 075159a9a..075159a9a 100644
--- a/toolkit/mozapps/extensions/internal/PluginProvider.jsm
+++ b/toolkit/mozapps/webextensions/internal/PluginProvider.jsm
diff --git a/toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm b/toolkit/mozapps/webextensions/internal/ProductAddonChecker.jsm
index f98dd2a94..f98dd2a94 100644
--- a/toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm
+++ b/toolkit/mozapps/webextensions/internal/ProductAddonChecker.jsm
diff --git a/toolkit/mozapps/extensions/internal/SpellCheckDictionaryBootstrap.js b/toolkit/mozapps/webextensions/internal/SpellCheckDictionaryBootstrap.js
index f4f557fc2..f4f557fc2 100644
--- a/toolkit/mozapps/extensions/internal/SpellCheckDictionaryBootstrap.js
+++ b/toolkit/mozapps/webextensions/internal/SpellCheckDictionaryBootstrap.js
diff --git a/toolkit/mozapps/extensions/internal/WebExtensionBootstrap.js b/toolkit/mozapps/webextensions/internal/WebExtensionBootstrap.js
index a920c2eae..a920c2eae 100644
--- a/toolkit/mozapps/extensions/internal/WebExtensionBootstrap.js
+++ b/toolkit/mozapps/webextensions/internal/WebExtensionBootstrap.js
diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/webextensions/internal/XPIProvider.jsm
index 87e09cef1..87e09cef1 100644
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/webextensions/internal/XPIProvider.jsm
diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/webextensions/internal/XPIProviderUtils.js
index d04eb207c..d04eb207c 100644
--- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
+++ b/toolkit/mozapps/webextensions/internal/XPIProviderUtils.js
diff --git a/toolkit/mozapps/extensions/internal/moz.build b/toolkit/mozapps/webextensions/internal/moz.build
index 28c34f8c9..28c34f8c9 100644
--- a/toolkit/mozapps/extensions/internal/moz.build
+++ b/toolkit/mozapps/webextensions/internal/moz.build
diff --git a/toolkit/mozapps/extensions/jar.mn b/toolkit/mozapps/webextensions/jar.mn
index ecf64b7ef..ecf64b7ef 100644
--- a/toolkit/mozapps/extensions/jar.mn
+++ b/toolkit/mozapps/webextensions/jar.mn
diff --git a/toolkit/mozapps/extensions/moz.build b/toolkit/mozapps/webextensions/moz.build
index 12640e115..12640e115 100644
--- a/toolkit/mozapps/extensions/moz.build
+++ b/toolkit/mozapps/webextensions/moz.build
diff --git a/toolkit/mozapps/extensions/nsBlocklistService.js b/toolkit/mozapps/webextensions/nsBlocklistService.js
index 0af90430c..0af90430c 100644
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/webextensions/nsBlocklistService.js
diff --git a/toolkit/mozapps/extensions/nsBlocklistServiceContent.js b/toolkit/mozapps/webextensions/nsBlocklistServiceContent.js
index 1752924b5..1752924b5 100644
--- a/toolkit/mozapps/extensions/nsBlocklistServiceContent.js
+++ b/toolkit/mozapps/webextensions/nsBlocklistServiceContent.js
diff --git a/toolkit/mozapps/extensions/test/AddonManagerTesting.jsm b/toolkit/mozapps/webextensions/test/AddonManagerTesting.jsm
index eb9a92195..eb9a92195 100644
--- a/toolkit/mozapps/extensions/test/AddonManagerTesting.jsm
+++ b/toolkit/mozapps/webextensions/test/AddonManagerTesting.jsm
diff --git a/toolkit/mozapps/extensions/test/Makefile.in b/toolkit/mozapps/webextensions/test/Makefile.in
index 6c667ecab..6c667ecab 100644
--- a/toolkit/mozapps/extensions/test/Makefile.in
+++ b/toolkit/mozapps/webextensions/test/Makefile.in
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_hard1_1/install.rdf
index 7b1b02a17..7b1b02a17 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_hard1_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_hard1_2/install.rdf
index ae364637e..ae364637e 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_hard1_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_hard1_3/install.rdf
index 568c41a43..568c41a43 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_hard1_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_1/install.rdf
index 1281ab53f..1281ab53f 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_2/install.rdf
index 8b6dd09f5..8b6dd09f5 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_3/install.rdf
index fade395f9..fade395f9 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_regexp1_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft1_1/install.rdf
index 4a18f64e0..4a18f64e0 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft1_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft1_2/install.rdf
index 8a2519222..8a2519222 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft1_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft1_3/install.rdf
index 2c55e5ff7..2c55e5ff7 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft1_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft2_1/install.rdf
index eebac4b21..eebac4b21 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft2_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft2_2/install.rdf
index f37741d04..f37741d04 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft2_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft2_3/install.rdf
index e15f99264..e15f99264 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft2_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft3_1/install.rdf
index f4b70a24b..f4b70a24b 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft3_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft3_2/install.rdf
index 987204fa6..987204fa6 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft3_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft3_3/install.rdf
index 19ab4b9fe..19ab4b9fe 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft3_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft4_1/install.rdf
index a3cd06f5f..a3cd06f5f 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft4_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft4_2/install.rdf
index eeff9fb79..eeff9fb79 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft4_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft4_3/install.rdf
index 1d2650603..1d2650603 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft4_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft5_1/install.rdf
index 85d7108d6..85d7108d6 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft5_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft5_2/install.rdf
index 394fd909e..394fd909e 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft5_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/blocklist_soft5_3/install.rdf
index 2a1fec25a..2a1fec25a 100644
--- a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/blocklist_soft5_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/bootstrap_globals/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/bootstrap_globals/bootstrap.js
index a5d5beb34..a5d5beb34 100644
--- a/toolkit/mozapps/extensions/test/addons/bootstrap_globals/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/bootstrap_globals/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/bootstrap_globals/install.rdf b/toolkit/mozapps/webextensions/test/addons/bootstrap_globals/install.rdf
index f11a626fd..f11a626fd 100644
--- a/toolkit/mozapps/extensions/test/addons/bootstrap_globals/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/bootstrap_globals/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/min1max1/install.rdf b/toolkit/mozapps/webextensions/test/addons/min1max1/install.rdf
index 3a0ace227..3a0ace227 100644
--- a/toolkit/mozapps/extensions/test/addons/min1max1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/min1max1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/min1max2/install.rdf b/toolkit/mozapps/webextensions/test/addons/min1max2/install.rdf
index 0184f1963..0184f1963 100644
--- a/toolkit/mozapps/extensions/test/addons/min1max2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/min1max2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/min1max3/install.rdf b/toolkit/mozapps/webextensions/test/addons/min1max3/install.rdf
index dbb1b7318..dbb1b7318 100644
--- a/toolkit/mozapps/extensions/test/addons/min1max3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/min1max3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/min1max3b/install.rdf b/toolkit/mozapps/webextensions/test/addons/min1max3b/install.rdf
index f50c65c6a..f50c65c6a 100644
--- a/toolkit/mozapps/extensions/test/addons/min1max3b/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/min1max3b/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/override1x2-1x3/install.rdf b/toolkit/mozapps/webextensions/test/addons/override1x2-1x3/install.rdf
index 92cf3ec96..92cf3ec96 100644
--- a/toolkit/mozapps/extensions/test/addons/override1x2-1x3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/override1x2-1x3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_1/install.rdf
index 82cfd0472..82cfd0472 100644
--- a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_2/install.rdf
index 80776e6c3..80776e6c3 100644
--- a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/icon.png b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/icon.png
index 41409edfe..41409edfe 100644
--- a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/icon.png
+++ b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/icon.png
diff --git a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/install.rdf
index bade9c069..bade9c069 100644
--- a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/preview.png b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/preview.png
index 321ce47cf..321ce47cf 100644
--- a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_3/preview.png
+++ b/toolkit/mozapps/webextensions/test/addons/test_AddonRepository_3/preview.png
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/install.rdf
index f02a3869c..f02a3869c 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/version.jsm b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/version.jsm
index 7fe60e632..7fe60e632 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/version.jsm
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_1/version.jsm
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/install.rdf
index 480f03fd1..480f03fd1 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/version.jsm b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/version.jsm
index 532741e12..532741e12 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/version.jsm
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_2/version.jsm
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/install.rdf
index e9385cbb3..e9385cbb3 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/version.jsm b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/version.jsm
index 1b813faaf..1b813faaf 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/version.jsm
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_3/version.jsm
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_4/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_4/install.rdf
index 2b88e0ad0..2b88e0ad0 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_4/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap1_4/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bootstrap2_1/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap2_1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bootstrap2_1/install.rdf
index e0e8ca978..e0e8ca978 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap2_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bootstrap_const/bootstrap.js
index 0e45caec4..0e45caec4 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap_const/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bootstrap_const/install.rdf
index 898282991..898282991 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bootstrap_const/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_2/install.rdf
index 791a6263f..791a6263f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_a_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_a_1/install.rdf
index 36d15b8aa..36d15b8aa 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_a_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_a_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_a_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_a_2/install.rdf
index 3521a503c..3521a503c 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_a_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_a_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_b_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_b_1/install.rdf
index d92a4ec41..d92a4ec41 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_b_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_b_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_b_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_b_2/install.rdf
index c3ad76b84..c3ad76b84 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_b_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_b_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_c_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_c_1/install.rdf
index a937b6e76..a937b6e76 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_c_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_c_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_c_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_c_2/install.rdf
index 8afca3ff9..8afca3ff9 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_c_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_c_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_d_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_d_1/install.rdf
index 4c0dcc2ef..4c0dcc2ef 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_d_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_d_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_d_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_d_2/install.rdf
index 2b113809a..2b113809a 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_d_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_d_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_e_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_e_1/install.rdf
index 03eb7180e..03eb7180e 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_e_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_e_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_e_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_e_2/install.rdf
index 3ed7cd932..3ed7cd932 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_e_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_e_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_f_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_f_1/install.rdf
index cacf824c1..cacf824c1 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_f_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_f_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_f_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_f_2/install.rdf
index 09954ec36..09954ec36 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_f_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_f_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_g_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_g_1/install.rdf
index 5e4a6f6a2..5e4a6f6a2 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_g_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_g_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug299716_g_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug299716_g_2/install.rdf
index 913233cec..913233cec 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug299716_g_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug299716_g_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_1/install.rdf
index fd0dd50b7..fd0dd50b7 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_2/install.rdf
index 607b68357..607b68357 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_3/install.rdf
index 3a4c7eafc..3a4c7eafc 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_4/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_4/install.rdf
index 8557df116..8557df116 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_4/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_4/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_5/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_5/install.rdf
index 343a9d44c..343a9d44c 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_5/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_5/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_6/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_6/install.rdf
index 5a724cc99..5a724cc99 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_6/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_6/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_7/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_7/install.rdf
index 70fe81168..70fe81168 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_7/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_7/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_8/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_8/install.rdf
index 2aface3b4..2aface3b4 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_8/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_8/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug324121_9/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug324121_9/install.rdf
index 7804e833c..7804e833c 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug324121_9/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug324121_9/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug335238_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug335238_1/install.rdf
index c60b5711b..c60b5711b 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug335238_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug335238_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug335238_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug335238_2/install.rdf
index 23faf5a34..23faf5a34 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug335238_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug335238_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug335238_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug335238_3/install.rdf
index d44448208..d44448208 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug335238_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug335238_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug335238_4/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug335238_4/install.rdf
index 6ec052d36..6ec052d36 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug335238_4/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug335238_4/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug371495/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug371495/install.rdf
index c60caf594..c60caf594 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug371495/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug371495/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug394300_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug394300_1/install.rdf
index 2e5ace760..2e5ace760 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug394300_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug394300_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug394300_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug394300_2/install.rdf
index ae54424d1..ae54424d1 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug394300_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug394300_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug397778/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug397778/install.rdf
index cfcfd406f..cfcfd406f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug397778/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug397778/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug425657/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug425657/install.rdf
index e4e1b339b..e4e1b339b 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug425657/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug425657/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug470377_1/install.rdf
index 5397e8a87..5397e8a87 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug470377_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug470377_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug470377_2/install.rdf
index b1dde7f7a..b1dde7f7a 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug470377_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug470377_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug470377_3/install.rdf
index ae483434a..ae483434a 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug470377_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug470377_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_4/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug470377_4/install.rdf
index 97abacc5e..97abacc5e 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug470377_4/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug470377_4/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_5/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug470377_5/install.rdf
index bff1104a7..bff1104a7 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug470377_5/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug470377_5/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug521905/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug521905/install.rdf
index 444bdc556..444bdc556 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug521905/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug521905/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug567173/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug567173/install.rdf
index f97bd1302..f97bd1302 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug567173/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug567173/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug567184/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bug567184/bootstrap.js
index 09c083532..09c083532 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug567184/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug567184/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug567184/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug567184/install.rdf
index 1e13ceb87..1e13ceb87 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug567184/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug567184/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug587088_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug587088_1/install.rdf
index 83220ce06..83220ce06 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug587088_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug587088_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug587088_1/testfile b/toolkit/mozapps/webextensions/test/addons/test_bug587088_1/testfile
index d2277257f..d2277257f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug587088_1/testfile
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug587088_1/testfile
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug587088_1/testfile1 b/toolkit/mozapps/webextensions/test/addons/test_bug587088_1/testfile1
index e69de29bb..e69de29bb 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug587088_1/testfile1
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug587088_1/testfile1
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug587088_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug587088_2/install.rdf
index ba23ab802..ba23ab802 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug587088_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug587088_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug587088_2/testfile b/toolkit/mozapps/webextensions/test/addons/test_bug587088_2/testfile
index 07afddfa7..07afddfa7 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug587088_2/testfile
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug587088_2/testfile
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug587088_2/testfile2 b/toolkit/mozapps/webextensions/test/addons/test_bug587088_2/testfile2
index e69de29bb..e69de29bb 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug587088_2/testfile2
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug587088_2/testfile2
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug594058/directory/file1 b/toolkit/mozapps/webextensions/test/addons/test_bug594058/directory/file1
index e69de29bb..e69de29bb 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug594058/directory/file1
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug594058/directory/file1
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug594058/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug594058/install.rdf
index 682831949..682831949 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug594058/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug594058/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug595573/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug595573/install.rdf
index 36c03fd00..36c03fd00 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug595573/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug595573/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug655254/install.rdf
index a3fa0d707..a3fa0d707 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug655254/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug655254_2/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bug655254_2/bootstrap.js
index b79648e89..b79648e89 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug655254_2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug655254_2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug655254_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug655254_2/install.rdf
index 71827885f..71827885f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug655254_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug655254_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug659772/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug659772/install.rdf
index 3b34c63d3..3b34c63d3 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug659772/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug659772/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug675371/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_bug675371/chrome.manifest
index 17d5c99ec..17d5c99ec 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug675371/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug675371/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug675371/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug675371/install.rdf
index ca2881e5a..ca2881e5a 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug675371/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug675371/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug675371/test.js b/toolkit/mozapps/webextensions/test/addons/test_bug675371/test.js
index b942a8064..b942a8064 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug675371/test.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug675371/test.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug740612_1/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bug740612_1/bootstrap.js
index 6703e7f7d..6703e7f7d 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug740612_1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug740612_1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug740612_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug740612_1/install.rdf
index b2316273f..b2316273f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug740612_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug740612_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug740612_2/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_bug740612_2/bootstrap.js
index 2ad481453..2ad481453 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug740612_2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug740612_2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug740612_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug740612_2/install.rdf
index ff4d613ef..ff4d613ef 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug740612_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug740612_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_bug757663/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_bug757663/install.rdf
index be8d85b1b..be8d85b1b 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug757663/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_bug757663/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_cacheflush1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_cacheflush1/install.rdf
index 5e64b65c1..5e64b65c1 100644
--- a/toolkit/mozapps/extensions/test/addons/test_cacheflush1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_cacheflush1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_cacheflush2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_cacheflush2/install.rdf
index 7728002ea..7728002ea 100644
--- a/toolkit/mozapps/extensions/test/addons/test_cacheflush2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_cacheflush2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_1/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_1/chrome.manifest
index 4d63b6b06..4d63b6b06 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_1/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_1/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_1/install.rdf
index 486be8670..486be8670 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_2/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_2/chrome.manifest
index 3b0195077..3b0195077 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_2/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_2/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_2/install.rdf
index 9a9ee4823..9a9ee4823 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/chrome.manifest
index 73190ed8f..73190ed8f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/inner.jar b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/inner.jar
index b4a40052f..b4a40052f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/inner.jar
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/inner.jar
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/install.rdf
index 3a4a709e0..3a4a709e0 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/chrome.manifest
index 60d4f01f0..60d4f01f0 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/components/components.manifest b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/components/components.manifest
index 1e0aea440..1e0aea440 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/components/components.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/components/components.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/components/other/something.manifest b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/components/other/something.manifest
index 73d58dd66..73d58dd66 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/components/other/something.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/components/other/something.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/install.rdf
index 463e3f27e..463e3f27e 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_4/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_4/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_5/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_5/chrome.manifest
index b0aa32adc..b0aa32adc 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_5/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_5/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_5/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_5/install.rdf
index 7836bced8..7836bced8 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_5/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_5/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_6/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_6/chrome.manifest
index 4ebb75c30..4ebb75c30 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_6/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_6/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_6/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_6/install.rdf
index 5d94de0ea..5d94de0ea 100644
--- a/toolkit/mozapps/extensions/test/addons/test_chromemanifest_6/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_chromemanifest_6/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_data_directory/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_data_directory/install.rdf
index aebfe3b68..aebfe3b68 100644
--- a/toolkit/mozapps/extensions/test/addons/test_data_directory/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_data_directory/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_db_sanity_1_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_db_sanity_1_1/install.rdf
index e1f2b5173..e1f2b5173 100644
--- a/toolkit/mozapps/extensions/test/addons/test_db_sanity_1_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_db_sanity_1_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_db_sanity_1_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_db_sanity_1_2/install.rdf
index da9b067ab..da9b067ab 100644
--- a/toolkit/mozapps/extensions/test/addons/test_db_sanity_1_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_db_sanity_1_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_complete_v2/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_v2/bootstrap.js
index c5a80c7b9..c5a80c7b9 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_complete_v2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_v2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_complete_v2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_v2/install.rdf
index 3ebbe16b0..3ebbe16b0 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_complete_v2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_v2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_complete_webextension_v2/manifest.json b/toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_webextension_v2/manifest.json
index 1a98f4660..1a98f4660 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_complete_webextension_v2/manifest.json
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_complete_webextension_v2/manifest.json
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_defer_v2/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_v2/bootstrap.js
index dea028488..dea028488 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_defer_v2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_v2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_defer_v2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_v2/install.rdf
index 75c7666bb..75c7666bb 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_defer_v2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_v2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_defer_webextension_v2/manifest.json b/toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_webextension_v2/manifest.json
index 9561979dc..9561979dc 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_defer_webextension_v2/manifest.json
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_defer_webextension_v2/manifest.json
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_v2/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_v2/bootstrap.js
index fb8fc9540..fb8fc9540 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_v2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_v2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_v2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_v2/install.rdf
index aec4b202e..aec4b202e 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_v2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_v2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_webextension_v2/manifest.json b/toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_webextension_v2/manifest.json
index d9200ec11..d9200ec11 100644
--- a/toolkit/mozapps/extensions/test/addons/test_delay_update_ignore_webextension_v2/manifest.json
+++ b/toolkit/mozapps/webextensions/test/addons/test_delay_update_ignore_webextension_v2/manifest.json
diff --git a/toolkit/mozapps/extensions/test/addons/test_dictionary/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_dictionary/chrome.manifest
index c945c928c..c945c928c 100644
--- a/toolkit/mozapps/extensions/test/addons/test_dictionary/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_dictionary/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_dictionary/dictionaries/ab-CD.dic b/toolkit/mozapps/webextensions/test/addons/test_dictionary/dictionaries/ab-CD.dic
index 3feac546d..3feac546d 100644
--- a/toolkit/mozapps/extensions/test/addons/test_dictionary/dictionaries/ab-CD.dic
+++ b/toolkit/mozapps/webextensions/test/addons/test_dictionary/dictionaries/ab-CD.dic
diff --git a/toolkit/mozapps/extensions/test/addons/test_dictionary/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_dictionary/install.rdf
index 9e66ab237..9e66ab237 100644
--- a/toolkit/mozapps/extensions/test/addons/test_dictionary/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_dictionary/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_dictionary_2/dictionaries/ab-CD.dic b/toolkit/mozapps/webextensions/test/addons/test_dictionary_2/dictionaries/ab-CD.dic
index b35b9c1a6..b35b9c1a6 100644
--- a/toolkit/mozapps/extensions/test/addons/test_dictionary_2/dictionaries/ab-CD.dic
+++ b/toolkit/mozapps/webextensions/test/addons/test_dictionary_2/dictionaries/ab-CD.dic
diff --git a/toolkit/mozapps/extensions/test/addons/test_dictionary_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_dictionary_2/install.rdf
index a74a114fd..a74a114fd 100644
--- a/toolkit/mozapps/extensions/test/addons/test_dictionary_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_dictionary_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_dictionary_3/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_dictionary_3/install.rdf
index c056e87ff..c056e87ff 100644
--- a/toolkit/mozapps/extensions/test/addons/test_dictionary_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_dictionary_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_dictionary_4/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_dictionary_4/install.rdf
index 7470284ba..7470284ba 100644
--- a/toolkit/mozapps/extensions/test/addons/test_dictionary_4/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_dictionary_4/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_dictionary_5/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_dictionary_5/install.rdf
index 11eba90d7..11eba90d7 100644
--- a/toolkit/mozapps/extensions/test/addons/test_dictionary_5/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_dictionary_5/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_distribution1_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_distribution1_2/install.rdf
index 8bd5966c9..8bd5966c9 100644
--- a/toolkit/mozapps/extensions/test/addons/test_distribution1_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_distribution1_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_experiment1/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_experiment1/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/addons/test_experiment1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_experiment1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_experiment1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_experiment1/install.rdf
index 414a36b30..414a36b30 100644
--- a/toolkit/mozapps/extensions/test/addons/test_experiment1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_experiment1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_filepointer/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_filepointer/install.rdf
index 5e64b65c1..5e64b65c1 100644
--- a/toolkit/mozapps/extensions/test/addons/test_filepointer/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_filepointer/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_getresource/icon.png b/toolkit/mozapps/webextensions/test/addons/test_getresource/icon.png
index 40765b0e2..40765b0e2 100644
--- a/toolkit/mozapps/extensions/test/addons/test_getresource/icon.png
+++ b/toolkit/mozapps/webextensions/test/addons/test_getresource/icon.png
diff --git a/toolkit/mozapps/extensions/test/addons/test_getresource/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_getresource/install.rdf
index 8d2740dbb..8d2740dbb 100644
--- a/toolkit/mozapps/extensions/test/addons/test_getresource/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_getresource/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_getresource/subdir/subfile.txt b/toolkit/mozapps/webextensions/test/addons/test_getresource/subdir/subfile.txt
index a28d18162..a28d18162 100644
--- a/toolkit/mozapps/extensions/test/addons/test_getresource/subdir/subfile.txt
+++ b/toolkit/mozapps/webextensions/test/addons/test_getresource/subdir/subfile.txt
diff --git a/toolkit/mozapps/extensions/test/addons/test_hotfix_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_hotfix_1/install.rdf
index 7fcc1a09e..7fcc1a09e 100644
--- a/toolkit/mozapps/extensions/test/addons/test_hotfix_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_hotfix_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_hotfix_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_hotfix_2/install.rdf
index fd843dbe9..fd843dbe9 100644
--- a/toolkit/mozapps/extensions/test/addons/test_hotfix_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_hotfix_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install1/icon.png b/toolkit/mozapps/webextensions/test/addons/test_install1/icon.png
index 41409edfe..41409edfe 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install1/icon.png
+++ b/toolkit/mozapps/webextensions/test/addons/test_install1/icon.png
diff --git a/toolkit/mozapps/extensions/test/addons/test_install1/icon64.png b/toolkit/mozapps/webextensions/test/addons/test_install1/icon64.png
index 41409edfe..41409edfe 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install1/icon64.png
+++ b/toolkit/mozapps/webextensions/test/addons/test_install1/icon64.png
diff --git a/toolkit/mozapps/extensions/test/addons/test_install1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install1/install.rdf
index efe3f18ae..efe3f18ae 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install2_1/icon.png b/toolkit/mozapps/webextensions/test/addons/test_install2_1/icon.png
index 41409edfe..41409edfe 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install2_1/icon.png
+++ b/toolkit/mozapps/webextensions/test/addons/test_install2_1/icon.png
diff --git a/toolkit/mozapps/extensions/test/addons/test_install2_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install2_1/install.rdf
index 116eb7069..116eb7069 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install2_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install2_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install2_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install2_2/install.rdf
index 7197ea1fb..7197ea1fb 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install2_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install2_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install3/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install3/install.rdf
index 8e72017ad..8e72017ad 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install4/addon4.xpi b/toolkit/mozapps/webextensions/test/addons/test_install4/addon4.xpi
index e57a4f5b6..e57a4f5b6 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install4/addon4.xpi
+++ b/toolkit/mozapps/webextensions/test/addons/test_install4/addon4.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/addons/test_install4/addon5.jar b/toolkit/mozapps/webextensions/test/addons/test_install4/addon5.jar
index 93fbfbe6e..93fbfbe6e 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install4/addon5.jar
+++ b/toolkit/mozapps/webextensions/test/addons/test_install4/addon5.jar
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/addons/test_install4/addon6.xpi b/toolkit/mozapps/webextensions/test/addons/test_install4/addon6.xpi
index 3613dab04..3613dab04 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install4/addon6.xpi
+++ b/toolkit/mozapps/webextensions/test/addons/test_install4/addon6.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/addons/test_install4/addon7.jar b/toolkit/mozapps/webextensions/test/addons/test_install4/addon7.jar
index 1af178887..1af178887 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install4/addon7.jar
+++ b/toolkit/mozapps/webextensions/test/addons/test_install4/addon7.jar
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/addons/test_install4/badaddon.jar b/toolkit/mozapps/webextensions/test/addons/test_install4/badaddon.jar
index 33695b99f..33695b99f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install4/badaddon.jar
+++ b/toolkit/mozapps/webextensions/test/addons/test_install4/badaddon.jar
diff --git a/toolkit/mozapps/extensions/test/addons/test_install4/badaddon.xpi b/toolkit/mozapps/webextensions/test/addons/test_install4/badaddon.xpi
index 33695b99f..33695b99f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install4/badaddon.xpi
+++ b/toolkit/mozapps/webextensions/test/addons/test_install4/badaddon.xpi
diff --git a/toolkit/mozapps/extensions/test/addons/test_install4/icon.png b/toolkit/mozapps/webextensions/test/addons/test_install4/icon.png
index 57f2c2eb6..57f2c2eb6 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install4/icon.png
+++ b/toolkit/mozapps/webextensions/test/addons/test_install4/icon.png
diff --git a/toolkit/mozapps/extensions/test/addons/test_install4/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install4/install.rdf
index 5e99ae29a..5e99ae29a 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install4/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install4/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install5/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_install5/chrome.manifest
index 703adf2a7..703adf2a7 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install5/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_install5/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_install5/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install5/install.rdf
index 1f96e4b49..1f96e4b49 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install5/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install5/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install6/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install6/install.rdf
index b1f97c1fd..b1f97c1fd 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install6/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install6/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install7/addon1.xpi b/toolkit/mozapps/webextensions/test/addons/test_install7/addon1.xpi
index 9c283d1d4..9c283d1d4 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install7/addon1.xpi
+++ b/toolkit/mozapps/webextensions/test/addons/test_install7/addon1.xpi
diff --git a/toolkit/mozapps/extensions/test/addons/test_install7/addon2.xpi b/toolkit/mozapps/webextensions/test/addons/test_install7/addon2.xpi
index 9c283d1d4..9c283d1d4 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install7/addon2.xpi
+++ b/toolkit/mozapps/webextensions/test/addons/test_install7/addon2.xpi
diff --git a/toolkit/mozapps/extensions/test/addons/test_install7/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install7/install.rdf
index 5e99ae29a..5e99ae29a 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install7/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install7/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_install8/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_install8/install.rdf
index 5e99ae29a..5e99ae29a 100644
--- a/toolkit/mozapps/extensions/test/addons/test_install8/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_install8/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_jetpack/bootstrap.js
index 2449baeb8..2449baeb8 100644
--- a/toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_jetpack/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json b/toolkit/mozapps/webextensions/test/addons/test_jetpack/harness-options.json
index 9e26dfeeb..9e26dfeeb 100644
--- a/toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json
+++ b/toolkit/mozapps/webextensions/test/addons/test_jetpack/harness-options.json
diff --git a/toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_jetpack/install.rdf
index e88794a60..e88794a60 100644
--- a/toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_jetpack/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_langpack/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_langpack/chrome.manifest
index 16fe819a2..16fe819a2 100644
--- a/toolkit/mozapps/extensions/test/addons/test_langpack/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_langpack/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_langpack/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_langpack/install.rdf
index 056f6dff5..056f6dff5 100644
--- a/toolkit/mozapps/extensions/test/addons/test_langpack/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_langpack/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_locale/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_locale/install.rdf
index d8d027b93..d8d027b93 100644
--- a/toolkit/mozapps/extensions/test/addons/test_locale/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_locale/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_locked2_5/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_locked2_5/install.rdf
index 09655c2a6..09655c2a6 100644
--- a/toolkit/mozapps/extensions/test/addons/test_locked2_5/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_locked2_5/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_locked2_6/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_locked2_6/install.rdf
index 75f110d2a..75f110d2a 100644
--- a/toolkit/mozapps/extensions/test/addons/test_locked2_6/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_locked2_6/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_migrate4_6/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_migrate4_6/install.rdf
index 5924982f7..5924982f7 100644
--- a/toolkit/mozapps/extensions/test/addons/test_migrate4_6/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_migrate4_6/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_migrate4_7/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_migrate4_7/install.rdf
index 072751cf2..072751cf2 100644
--- a/toolkit/mozapps/extensions/test/addons/test_migrate4_7/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_migrate4_7/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_migrate6/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_migrate6/install.rdf
index ff8280ae3..ff8280ae3 100644
--- a/toolkit/mozapps/extensions/test/addons/test_migrate6/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_migrate6/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_migrate7/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_migrate7/install.rdf
index fd1df0e08..fd1df0e08 100644
--- a/toolkit/mozapps/extensions/test/addons/test_migrate7/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_migrate7/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_migrate8/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/test_migrate8/chrome.manifest
index 8570bae82..8570bae82 100644
--- a/toolkit/mozapps/extensions/test/addons/test_migrate8/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/test_migrate8/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/test_migrate8/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_migrate8/install.rdf
index 61ed24763..61ed24763 100644
--- a/toolkit/mozapps/extensions/test/addons/test_migrate8/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_migrate8/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_migrate9/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_migrate9/install.rdf
index 116dd0176..116dd0176 100644
--- a/toolkit/mozapps/extensions/test/addons/test_migrate9/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_migrate9/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_symbol/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_symbol/bootstrap.js
index 4eb8b4875..4eb8b4875 100644
--- a/toolkit/mozapps/extensions/test/addons/test_symbol/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_symbol/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_symbol/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_symbol/install.rdf
index adccda552..adccda552 100644
--- a/toolkit/mozapps/extensions/test/addons/test_symbol/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_symbol/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_theme/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_theme/install.rdf
index e1a37d0a4..e1a37d0a4 100644
--- a/toolkit/mozapps/extensions/test/addons/test_theme/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_theme/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_theme/preview.png b/toolkit/mozapps/webextensions/test/addons/test_theme/preview.png
index 321ce47cf..321ce47cf 100644
--- a/toolkit/mozapps/extensions/test/addons/test_theme/preview.png
+++ b/toolkit/mozapps/webextensions/test/addons/test_theme/preview.png
diff --git a/toolkit/mozapps/extensions/test/addons/test_undoincompatible/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_undoincompatible/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/addons/test_undoincompatible/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_undoincompatible/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_undoincompatible/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_undoincompatible/install.rdf
index b038ebc51..b038ebc51 100644
--- a/toolkit/mozapps/extensions/test/addons/test_undoincompatible/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_undoincompatible/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_undouninstall1/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_undouninstall1/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/addons/test_undouninstall1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_undouninstall1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_undouninstall1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_undouninstall1/install.rdf
index 4178fe929..4178fe929 100644
--- a/toolkit/mozapps/extensions/test/addons/test_undouninstall1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_undouninstall1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_update/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_update/install.rdf
index 801a35a8f..801a35a8f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_update/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_update/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_update12/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_update12/install.rdf
index 3589cb55c..3589cb55c 100644
--- a/toolkit/mozapps/extensions/test/addons/test_update12/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_update12/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_update8/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_update8/install.rdf
index 43e31af42..43e31af42 100644
--- a/toolkit/mozapps/extensions/test/addons/test_update8/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_update8/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_update_multi1/bootstrap.js
index 24c778c09..24c778c09 100644
--- a/toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_update_multi1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_update_multi1/install.rdf
index 9f955562c..9f955562c 100644
--- a/toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_update_multi1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi2/addon.xpi b/toolkit/mozapps/webextensions/test/addons/test_update_multi2/addon.xpi
index febff06fa..febff06fa 100644
--- a/toolkit/mozapps/extensions/test/addons/test_update_multi2/addon.xpi
+++ b/toolkit/mozapps/webextensions/test/addons/test_update_multi2/addon.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_update_multi2/install.rdf
index 44bdb05ba..44bdb05ba 100644
--- a/toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_update_multi2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_updateid1/bootstrap.js
index 24c778c09..24c778c09 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_updateid1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_updateid1/install.rdf
index 803b64e5f..803b64e5f 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_updateid1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js b/toolkit/mozapps/webextensions/test/addons/test_updateid2/bootstrap.js
index 24c778c09..24c778c09 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/addons/test_updateid2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf b/toolkit/mozapps/webextensions/test/addons/test_updateid2/install.rdf
index 041af57f0..041af57f0 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/test_updateid2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/upgradeable1x2-3_1/install.rdf b/toolkit/mozapps/webextensions/test/addons/upgradeable1x2-3_1/install.rdf
index 76e662977..76e662977 100644
--- a/toolkit/mozapps/extensions/test/addons/upgradeable1x2-3_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/upgradeable1x2-3_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/upgradeable1x2-3_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/upgradeable1x2-3_2/install.rdf
index e57672c42..e57672c42 100644
--- a/toolkit/mozapps/extensions/test/addons/upgradeable1x2-3_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/upgradeable1x2-3_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/webextension_1/chrome.manifest b/toolkit/mozapps/webextensions/test/addons/webextension_1/chrome.manifest
index 16108ce18..16108ce18 100644
--- a/toolkit/mozapps/extensions/test/addons/webextension_1/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/addons/webextension_1/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/addons/webextension_1/manifest.json b/toolkit/mozapps/webextensions/test/addons/webextension_1/manifest.json
index 2ca5f40f7..2ca5f40f7 100644
--- a/toolkit/mozapps/extensions/test/addons/webextension_1/manifest.json
+++ b/toolkit/mozapps/webextensions/test/addons/webextension_1/manifest.json
diff --git a/toolkit/mozapps/extensions/test/addons/webextension_2/install.rdf b/toolkit/mozapps/webextensions/test/addons/webextension_2/install.rdf
index 653481ed0..653481ed0 100644
--- a/toolkit/mozapps/extensions/test/addons/webextension_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/addons/webextension_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/addons/webextension_2/manifest.json b/toolkit/mozapps/webextensions/test/addons/webextension_2/manifest.json
index 5b470d430..5b470d430 100644
--- a/toolkit/mozapps/extensions/test/addons/webextension_2/manifest.json
+++ b/toolkit/mozapps/webextensions/test/addons/webextension_2/manifest.json
diff --git a/toolkit/mozapps/extensions/test/addons/webextension_3/_locales/en/messages.json b/toolkit/mozapps/webextensions/test/addons/webextension_3/_locales/en/messages.json
index 36868d414..36868d414 100644
--- a/toolkit/mozapps/extensions/test/addons/webextension_3/_locales/en/messages.json
+++ b/toolkit/mozapps/webextensions/test/addons/webextension_3/_locales/en/messages.json
diff --git a/toolkit/mozapps/extensions/test/addons/webextension_3/_locales/fr/messages.json b/toolkit/mozapps/webextensions/test/addons/webextension_3/_locales/fr/messages.json
index c3d02ffde..c3d02ffde 100644
--- a/toolkit/mozapps/extensions/test/addons/webextension_3/_locales/fr/messages.json
+++ b/toolkit/mozapps/webextensions/test/addons/webextension_3/_locales/fr/messages.json
diff --git a/toolkit/mozapps/extensions/test/addons/webextension_3/manifest.json b/toolkit/mozapps/webextensions/test/addons/webextension_3/manifest.json
index b6ae6f10f..b6ae6f10f 100644
--- a/toolkit/mozapps/extensions/test/addons/webextension_3/manifest.json
+++ b/toolkit/mozapps/webextensions/test/addons/webextension_3/manifest.json
diff --git a/toolkit/mozapps/extensions/test/browser/.eslintrc.js b/toolkit/mozapps/webextensions/test/browser/.eslintrc.js
index 2852eb81d..2852eb81d 100644
--- a/toolkit/mozapps/extensions/test/browser/.eslintrc.js
+++ b/toolkit/mozapps/webextensions/test/browser/.eslintrc.js
diff --git a/toolkit/mozapps/extensions/test/browser/addon_about.xul b/toolkit/mozapps/webextensions/test/browser/addon_about.xul
index c2b8b935e..c2b8b935e 100644
--- a/toolkit/mozapps/extensions/test/browser/addon_about.xul
+++ b/toolkit/mozapps/webextensions/test/browser/addon_about.xul
diff --git a/toolkit/mozapps/extensions/test/browser/addon_prefs.xul b/toolkit/mozapps/webextensions/test/browser/addon_prefs.xul
index 85cfe6b2d..85cfe6b2d 100644
--- a/toolkit/mozapps/extensions/test/browser/addon_prefs.xul
+++ b/toolkit/mozapps/webextensions/test/browser/addon_prefs.xul
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_1.xpi
index d13e5d66e..d13e5d66e 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_1/install.rdf
index 5199c2f3f..5199c2f3f 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_10.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_10.xpi
index e1d6ac586..e1d6ac586 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_10.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_10.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_10/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_10/install.rdf
index c061814b6..c061814b6 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_10/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_10/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_2.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_2.xpi
index 1380e7b5b..1380e7b5b 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_2.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_2/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_2/install.rdf
index 1be5422b2..1be5422b2 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_3.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_3.xpi
index 46326b04c..46326b04c 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_3.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_3.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_3/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_3/install.rdf
index 54887a30e..54887a30e 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_3/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_3/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_4.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_4.xpi
index 95de79b79..95de79b79 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_4.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_4.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_4/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_4/install.rdf
index 79946b0f0..79946b0f0 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_4/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_4/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_5.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_5.xpi
index 005d7ef21..005d7ef21 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_5.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_5.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_5/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_5/install.rdf
index 067af1ba1..067af1ba1 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_5/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_5/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_6.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_6.xpi
index 89f751a03..89f751a03 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_6.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_6.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_6/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_6/install.rdf
index 37d7e6a7c..37d7e6a7c 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_6/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_6/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_7.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_7.xpi
index 77de37c2a..77de37c2a 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_7.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_7.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_7/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_7/install.rdf
index 461facbb2..461facbb2 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_7/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_7/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_8_1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_8_1.xpi
index 666ae0910..666ae0910 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_8_1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_8_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_8_1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_8_1/install.rdf
index 2111b9c64..2111b9c64 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_8_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_8_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_9_1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_9_1.xpi
index ad9367dc1..ad9367dc1 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_9_1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_9_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_9_1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_9_1/install.rdf
index 032e9adaf..032e9adaf 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug557956_9_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug557956_9_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_1.xpi
index 20ae35539..20ae35539 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_1/install.rdf
index d9f0ca745..d9f0ca745 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_2.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_2.xpi
index 3c99022cf..3c99022cf 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_2.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_2/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_2/install.rdf
index 8809ffb58..8809ffb58 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug567127_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug567127_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_1.xpi
index c438cbd0b..c438cbd0b 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_1/install.rdf
index c768d7881..c768d7881 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_2.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_2.xpi
index a87191efe..a87191efe 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_2.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_2/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_2/install.rdf
index bed489c3e..bed489c3e 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_bug596336_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_bug596336_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop1.xpi
index d8b4d083c..d8b4d083c 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop1/install.rdf
index 9bcd43e87..9bcd43e87 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop2.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop2.xpi
index e4441cb19..e4441cb19 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop2.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop2/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop2/install.rdf
index 4789abfaf..4789abfaf 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_dragdrop2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_dragdrop2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_experiment1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_experiment1.xpi
index 1c2b793f1..1c2b793f1 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_experiment1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_experiment1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_experiment1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_experiment1/install.rdf
index 92f20a4ef..92f20a4ef 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_experiment1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_experiment1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1.xpi
index be453ce9c..be453ce9c 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/bootstrap.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/bootstrap.js
index 7871af738..7871af738 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/chrome.manifest b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/chrome.manifest
index 8884e3974..8884e3974 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/install.rdf
index 18fcec167..18fcec167 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/options.xul b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/options.xul
index cd4f72387..cd4f72387 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/options.xul
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/options.xul
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/settings.dtd b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/settings.dtd
index 6864a3d5a..6864a3d5a 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/settings.dtd
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1/settings.dtd
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom.xpi
index 6e937c5cc..6e937c5cc 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/binding.xml b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/binding.xml
index 6ac72a03c..6ac72a03c 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/binding.xml
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/binding.xml
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/bootstrap.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/bootstrap.js
index 7871af738..7871af738 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/chrome.manifest b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/chrome.manifest
index f1eaef1d0..f1eaef1d0 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/install.rdf
index a04046a74..a04046a74 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/options.xul b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/options.xul
index 148fb9856..148fb9856 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/options.xul
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/options.xul
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/string.dtd b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/string.dtd
index 0b2dcc8fe..0b2dcc8fe 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_custom/string.dtd
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_custom/string.dtd
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info.xpi
index 4c939c05b..4c939c05b 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/bootstrap.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/bootstrap.js
index 7871af738..7871af738 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/install.rdf
index ba90bd57b..ba90bd57b 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/options.xul b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/options.xul
index 095d3bcef..095d3bcef 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1_info/options.xul
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_inlinesettings1_info/options.xul
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_install1_1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_install1_1.xpi
index d6df8f9d0..d6df8f9d0 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_install1_1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_install1_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_install1_1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_install1_1/install.rdf
index b11b6d7e4..b11b6d7e4 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_install1_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_install1_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_install1_2.xpi
index 5468e6cb0..5468e6cb0 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_install1_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_install1_2/install.rdf
index 81898b24d..81898b24d 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_install1_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_installssl.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_installssl.xpi
index 999535a97..999535a97 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_installssl.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_installssl.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_installssl/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_installssl/install.rdf
index 7ce6cd09a..7ce6cd09a 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_installssl/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_installssl/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_searching.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_searching.xpi
index efef815aa..efef815aa 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_searching.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_searching.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_searching/bootstrap.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_searching/bootstrap.js
index 7b86e419a..7b86e419a 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_searching/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_searching/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_searching/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_searching/install.rdf
index 02cc935ea..02cc935ea 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_searching/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_searching/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1.xpi
index 956812aaa..956812aaa 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/bootstrap.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/bootstrap.js
index ff5b80ae8..ff5b80ae8 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/chrome.manifest b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/chrome.manifest
index f1a7ccee1..f1a7ccee1 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/frame-script.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/frame-script.js
index f4674b840..f4674b840 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/frame-script.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/frame-script.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/install.rdf
index c52307b4a..c52307b4a 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2.xpi
index 7ef3db940..7ef3db940 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/bootstrap.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/bootstrap.js
index ff5b80ae8..ff5b80ae8 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/chrome.manifest b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/chrome.manifest
index f1a7ccee1..f1a7ccee1 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/chrome.manifest
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/chrome.manifest
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/frame-script.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/frame-script.js
index e35092a55..e35092a55 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/frame-script.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/frame-script.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/install.rdf
index 2fae190b4..2fae190b4 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_update1_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_update1_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install.xpi b/toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install.xpi
index 4fa7b8bfa..4fa7b8bfa 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install/bootstrap.js b/toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install/bootstrap.js
index bd11077c2..bd11077c2 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install/install.rdf b/toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install/install.rdf
index 2cae124e1..2cae124e1 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_webapi_install/install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/addons/browser_webapi_install/install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/addons/options_signed.xpi b/toolkit/mozapps/webextensions/test/browser/addons/options_signed.xpi
index a063fd1c4..a063fd1c4 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/options_signed.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/addons/options_signed.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/addons/options_signed/manifest.json b/toolkit/mozapps/webextensions/test/browser/addons/options_signed/manifest.json
index e808cd5ab..e808cd5ab 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/options_signed/manifest.json
+++ b/toolkit/mozapps/webextensions/test/browser/addons/options_signed/manifest.json
diff --git a/toolkit/mozapps/extensions/test/browser/addons/options_signed/options.html b/toolkit/mozapps/webextensions/test/browser/addons/options_signed/options.html
index ea804601b..ea804601b 100644
--- a/toolkit/mozapps/extensions/test/browser/addons/options_signed/options.html
+++ b/toolkit/mozapps/webextensions/test/browser/addons/options_signed/options.html
diff --git a/toolkit/mozapps/extensions/test/browser/blockNoPlugins.xml b/toolkit/mozapps/webextensions/test/browser/blockNoPlugins.xml
index e4e191b37..e4e191b37 100644
--- a/toolkit/mozapps/extensions/test/browser/blockNoPlugins.xml
+++ b/toolkit/mozapps/webextensions/test/browser/blockNoPlugins.xml
diff --git a/toolkit/mozapps/extensions/test/browser/blockPluginHard.xml b/toolkit/mozapps/webextensions/test/browser/blockPluginHard.xml
index 24eb5bc6f..24eb5bc6f 100644
--- a/toolkit/mozapps/extensions/test/browser/blockPluginHard.xml
+++ b/toolkit/mozapps/webextensions/test/browser/blockPluginHard.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser-common.ini b/toolkit/mozapps/webextensions/test/browser/browser-common.ini
index eda266e2f..eda266e2f 100644
--- a/toolkit/mozapps/extensions/test/browser/browser-common.ini
+++ b/toolkit/mozapps/webextensions/test/browser/browser-common.ini
diff --git a/toolkit/mozapps/extensions/test/browser/browser-window.ini b/toolkit/mozapps/webextensions/test/browser/browser-window.ini
index fcda90fc6..fcda90fc6 100644
--- a/toolkit/mozapps/extensions/test/browser/browser-window.ini
+++ b/toolkit/mozapps/webextensions/test/browser/browser-window.ini
diff --git a/toolkit/mozapps/extensions/test/browser/browser.ini b/toolkit/mozapps/webextensions/test/browser/browser.ini
index a23841d33..a23841d33 100644
--- a/toolkit/mozapps/extensions/test/browser/browser.ini
+++ b/toolkit/mozapps/webextensions/test/browser/browser.ini
diff --git a/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js b/toolkit/mozapps/webextensions/test/browser/browser_CTP_plugins.js
index dd2992f81..dd2992f81 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_CTP_plugins.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_about.js b/toolkit/mozapps/webextensions/test/browser/browser_about.js
index f781cf146..f781cf146 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_about.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_about.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js b/toolkit/mozapps/webextensions/test/browser/browser_addonrepository_performance.js
index 879d7331e..879d7331e 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_addonrepository_performance.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug523784.js b/toolkit/mozapps/webextensions/test/browser/browser_bug523784.js
index e61fafd6b..e61fafd6b 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug523784.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug523784.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug557943.js b/toolkit/mozapps/webextensions/test/browser/browser_bug557943.js
index 94a8b6f49..94a8b6f49 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug557943.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug557943.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug557956.js b/toolkit/mozapps/webextensions/test/browser/browser_bug557956.js
index 136e7cb74..136e7cb74 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug557956.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug557956.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug557956.rdf b/toolkit/mozapps/webextensions/test/browser/browser_bug557956.rdf
index c72eb9363..c72eb9363 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug557956.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug557956.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug557956.xml b/toolkit/mozapps/webextensions/test/browser/browser_bug557956.xml
index c32ed3062..c32ed3062 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug557956.xml
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug557956.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug557956_8_2.xpi b/toolkit/mozapps/webextensions/test/browser/browser_bug557956_8_2.xpi
index e99f3c3bd..e99f3c3bd 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug557956_8_2.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug557956_8_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug557956_9_2.xpi b/toolkit/mozapps/webextensions/test/browser/browser_bug557956_9_2.xpi
index 23686b608..23686b608 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug557956_9_2.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug557956_9_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js b/toolkit/mozapps/webextensions/test/browser/browser_bug562797.js
index 55e882a05..55e882a05 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug562797.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug562854.js b/toolkit/mozapps/webextensions/test/browser/browser_bug562854.js
index 53e890b71..53e890b71 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562854.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug562854.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug562890.js b/toolkit/mozapps/webextensions/test/browser/browser_bug562890.js
index ccb12c489..ccb12c489 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562890.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug562890.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug562899.js b/toolkit/mozapps/webextensions/test/browser/browser_bug562899.js
index 9807be98f..9807be98f 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562899.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug562899.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug562992.js b/toolkit/mozapps/webextensions/test/browser/browser_bug562992.js
index 1cd4d90cd..1cd4d90cd 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562992.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug562992.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js b/toolkit/mozapps/webextensions/test/browser/browser_bug567127.js
index 1d9a75416..1d9a75416 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug567127.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug567137.js b/toolkit/mozapps/webextensions/test/browser/browser_bug567137.js
index bb9b9a894..bb9b9a894 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567137.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug567137.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug570760.js b/toolkit/mozapps/webextensions/test/browser/browser_bug570760.js
index 0606a9a31..0606a9a31 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug570760.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug570760.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug572561.js b/toolkit/mozapps/webextensions/test/browser/browser_bug572561.js
index 69102060e..69102060e 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug572561.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug572561.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug573062.js b/toolkit/mozapps/webextensions/test/browser/browser_bug573062.js
index 6554451fb..6554451fb 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug573062.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug573062.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug577990.js b/toolkit/mozapps/webextensions/test/browser/browser_bug577990.js
index 913b3b954..913b3b954 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug577990.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug577990.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug580298.js b/toolkit/mozapps/webextensions/test/browser/browser_bug580298.js
index d3d338203..d3d338203 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug580298.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug580298.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug581076.js b/toolkit/mozapps/webextensions/test/browser/browser_bug581076.js
index b02a6cc3e..b02a6cc3e 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug581076.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug581076.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug586574.js b/toolkit/mozapps/webextensions/test/browser/browser_bug586574.js
index fb5ebf01b..fb5ebf01b 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug586574.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug586574.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug587970.js b/toolkit/mozapps/webextensions/test/browser/browser_bug587970.js
index ef05ba4ea..ef05ba4ea 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug587970.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug587970.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug590347.js b/toolkit/mozapps/webextensions/test/browser/browser_bug590347.js
index f805f0e19..f805f0e19 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug590347.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug590347.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug591465.js b/toolkit/mozapps/webextensions/test/browser/browser_bug591465.js
index f759ffc1f..f759ffc1f 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug591465.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug591465.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug591465.xml b/toolkit/mozapps/webextensions/test/browser/browser_bug591465.xml
index 9c2e102e7..9c2e102e7 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug591465.xml
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug591465.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug591663.js b/toolkit/mozapps/webextensions/test/browser/browser_bug591663.js
index 4a4f735af..4a4f735af 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug591663.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug591663.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug593535.js b/toolkit/mozapps/webextensions/test/browser/browser_bug593535.js
index fd23d0036..fd23d0036 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug593535.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug593535.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug593535.xml b/toolkit/mozapps/webextensions/test/browser/browser_bug593535.xml
index 411d9f383..411d9f383 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug593535.xml
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug593535.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug596336.js b/toolkit/mozapps/webextensions/test/browser/browser_bug596336.js
index ec32e376f..ec32e376f 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug596336.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug596336.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug608316.js b/toolkit/mozapps/webextensions/test/browser/browser_bug608316.js
index 72bb61f49..72bb61f49 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug608316.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug608316.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug610764.js b/toolkit/mozapps/webextensions/test/browser/browser_bug610764.js
index 58de88130..58de88130 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug610764.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug610764.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug616841.js b/toolkit/mozapps/webextensions/test/browser/browser_bug616841.js
index 3cf6f5346..3cf6f5346 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug616841.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug616841.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug618502.js b/toolkit/mozapps/webextensions/test/browser/browser_bug618502.js
index 5bcc6baf1..5bcc6baf1 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug618502.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug618502.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug679604.js b/toolkit/mozapps/webextensions/test/browser/browser_bug679604.js
index e1ec605c2..e1ec605c2 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug679604.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug679604.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug714593.js b/toolkit/mozapps/webextensions/test/browser/browser_bug714593.js
index b9a7faa5e..b9a7faa5e 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug714593.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_bug714593.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_cancelCompatCheck.js b/toolkit/mozapps/webextensions/test/browser/browser_cancelCompatCheck.js
index e7c672212..e7c672212 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_cancelCompatCheck.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_cancelCompatCheck.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_checkAddonCompatibility.js b/toolkit/mozapps/webextensions/test/browser/browser_checkAddonCompatibility.js
index 6c42e0126..6c42e0126 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_checkAddonCompatibility.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_checkAddonCompatibility.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_details.js b/toolkit/mozapps/webextensions/test/browser/browser_details.js
index ce4c51b5a..ce4c51b5a 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_details.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_details.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_discovery.js b/toolkit/mozapps/webextensions/test/browser/browser_discovery.js
index ec336df2d..ec336df2d 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_discovery.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_discovery.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_discovery_install.js b/toolkit/mozapps/webextensions/test/browser/browser_discovery_install.js
index 63516bd53..63516bd53 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_discovery_install.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_discovery_install.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js b/toolkit/mozapps/webextensions/test/browser/browser_dragdrop.js
index 960e7e933..960e7e933 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_dragdrop.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_eula.js b/toolkit/mozapps/webextensions/test/browser/browser_eula.js
index befe9f1f2..befe9f1f2 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_eula.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_eula.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_eula.xml b/toolkit/mozapps/webextensions/test/browser/browser_eula.xml
index 965ab8a0b..965ab8a0b 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_eula.xml
+++ b/toolkit/mozapps/webextensions/test/browser/browser_eula.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser_experiments.js b/toolkit/mozapps/webextensions/test/browser/browser_experiments.js
index 18a548de5..18a548de5 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_experiments.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_experiments.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js b/toolkit/mozapps/webextensions/test/browser/browser_globalwarnings.js
index 663905a90..663905a90 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_globalwarnings.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js b/toolkit/mozapps/webextensions/test/browser/browser_gmpProvider.js
index 52079a263..52079a263 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_gmpProvider.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_hotfix.js b/toolkit/mozapps/webextensions/test/browser/browser_hotfix.js
index b7bb3f580..b7bb3f580 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_hotfix.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_hotfix.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js b/toolkit/mozapps/webextensions/test/browser/browser_inlinesettings.js
index e2814ddf4..e2814ddf4 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_inlinesettings.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js b/toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_browser.js
index 5a704530a..5a704530a 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_browser.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_custom.js b/toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_custom.js
index ecd10852d..ecd10852d 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_custom.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_custom.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_info.js b/toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_info.js
index ce618b7fa..ce618b7fa 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_info.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_inlinesettings_info.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_install.js b/toolkit/mozapps/webextensions/test/browser/browser_install.js
index 880a4624d..880a4624d 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_install.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_install.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_install.rdf b/toolkit/mozapps/webextensions/test/browser/browser_install.rdf
index 437bf9b85..437bf9b85 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_install.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/browser_install.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/browser_install.rdf^headers^ b/toolkit/mozapps/webextensions/test/browser/browser_install.rdf^headers^
index 2e4f8163b..2e4f8163b 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_install.rdf^headers^
+++ b/toolkit/mozapps/webextensions/test/browser/browser_install.rdf^headers^
diff --git a/toolkit/mozapps/extensions/test/browser/browser_install.xml b/toolkit/mozapps/webextensions/test/browser/browser_install.xml
index 0643c811a..0643c811a 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_install.xml
+++ b/toolkit/mozapps/webextensions/test/browser/browser_install.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser_install1_3.xpi b/toolkit/mozapps/webextensions/test/browser/browser_install1_3.xpi
index de3c90353..de3c90353 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_install1_3.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/browser_install1_3.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/browser_installssl.js b/toolkit/mozapps/webextensions/test/browser/browser_installssl.js
index b0726ef9e..b0726ef9e 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_installssl.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_installssl.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_list.js b/toolkit/mozapps/webextensions/test/browser/browser_list.js
index 49427329f..49427329f 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_list.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_list.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js b/toolkit/mozapps/webextensions/test/browser/browser_manualupdates.js
index 0c5eb2da6..0c5eb2da6 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_manualupdates.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_metadataTimeout.js b/toolkit/mozapps/webextensions/test/browser/browser_metadataTimeout.js
index 98be4b7f8..98be4b7f8 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_metadataTimeout.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_metadataTimeout.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_newaddon.js b/toolkit/mozapps/webextensions/test/browser/browser_newaddon.js
index d450828ba..d450828ba 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_newaddon.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_newaddon.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_openDialog.js b/toolkit/mozapps/webextensions/test/browser/browser_openDialog.js
index f95365a4c..f95365a4c 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_openDialog.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_openDialog.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_plugin_enabled_state_locked.js b/toolkit/mozapps/webextensions/test/browser/browser_plugin_enabled_state_locked.js
index a9c7be4bc..a9c7be4bc 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_plugin_enabled_state_locked.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_plugin_enabled_state_locked.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js b/toolkit/mozapps/webextensions/test/browser/browser_pluginprefs.js
index 458e8e334..458e8e334 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_pluginprefs.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_purchase.js b/toolkit/mozapps/webextensions/test/browser/browser_purchase.js
index a815d10d5..a815d10d5 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_purchase.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_purchase.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_purchase.xml b/toolkit/mozapps/webextensions/test/browser/browser_purchase.xml
index 9d4b18880..9d4b18880 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_purchase.xml
+++ b/toolkit/mozapps/webextensions/test/browser/browser_purchase.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js b/toolkit/mozapps/webextensions/test/browser/browser_recentupdates.js
index 02007dbbf..02007dbbf 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_recentupdates.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_searching.js b/toolkit/mozapps/webextensions/test/browser/browser_searching.js
index 907d9b105..907d9b105 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_searching.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_searching.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_searching.xml b/toolkit/mozapps/webextensions/test/browser/browser_searching.xml
index a3537b269..a3537b269 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_searching.xml
+++ b/toolkit/mozapps/webextensions/test/browser/browser_searching.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser_searching_empty.xml b/toolkit/mozapps/webextensions/test/browser/browser_searching_empty.xml
index 24f6cb89f..24f6cb89f 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_searching_empty.xml
+++ b/toolkit/mozapps/webextensions/test/browser/browser_searching_empty.xml
diff --git a/toolkit/mozapps/extensions/test/browser/browser_sorting.js b/toolkit/mozapps/webextensions/test/browser/browser_sorting.js
index b57e7a6f7..b57e7a6f7 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_sorting.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_sorting.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_sorting_plugins.js b/toolkit/mozapps/webextensions/test/browser/browser_sorting_plugins.js
index 2bb6b4ba4..2bb6b4ba4 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_sorting_plugins.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_sorting_plugins.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_system_addons_are_e10s.js b/toolkit/mozapps/webextensions/test/browser/browser_system_addons_are_e10s.js
index 37ab76542..37ab76542 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_system_addons_are_e10s.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_system_addons_are_e10s.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_tabsettings.js b/toolkit/mozapps/webextensions/test/browser/browser_tabsettings.js
index 2838698c7..2838698c7 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_tabsettings.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_tabsettings.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_task_next_test.js b/toolkit/mozapps/webextensions/test/browser/browser_task_next_test.js
index 5ff2aff78..5ff2aff78 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_task_next_test.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_task_next_test.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_types.js b/toolkit/mozapps/webextensions/test/browser/browser_types.js
index 8abb0ff73..8abb0ff73 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_types.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_types.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js b/toolkit/mozapps/webextensions/test/browser/browser_uninstalling.js
index a9329e496..a9329e496 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_uninstalling.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_update.js b/toolkit/mozapps/webextensions/test/browser/browser_update.js
index 09ceb1240..09ceb1240 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_update.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_update.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_updateid.js b/toolkit/mozapps/webextensions/test/browser/browser_updateid.js
index 0fe3eeec5..0fe3eeec5 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_updateid.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_updateid.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_updatessl.js b/toolkit/mozapps/webextensions/test/browser/browser_updatessl.js
index 8b816c927..8b816c927 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_updatessl.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_updatessl.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf b/toolkit/mozapps/webextensions/test/browser/browser_updatessl.rdf
index f24573847..f24573847 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/browser_updatessl.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf^headers^ b/toolkit/mozapps/webextensions/test/browser/browser_updatessl.rdf^headers^
index 2e4f8163b..2e4f8163b 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf^headers^
+++ b/toolkit/mozapps/webextensions/test/browser/browser_updatessl.rdf^headers^
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi.js b/toolkit/mozapps/webextensions/test/browser/browser_webapi.js
index ca8e41aad..ca8e41aad 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_webapi.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_access.js b/toolkit/mozapps/webextensions/test/browser/browser_webapi_access.js
index f4b1dc745..f4b1dc745 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_access.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_webapi_access.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_addon_listener.js b/toolkit/mozapps/webextensions/test/browser/browser_webapi_addon_listener.js
index b8049f13c..b8049f13c 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_addon_listener.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_webapi_addon_listener.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_enable.js b/toolkit/mozapps/webextensions/test/browser/browser_webapi_enable.js
index 27d8029c5..27d8029c5 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_enable.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_webapi_enable.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js b/toolkit/mozapps/webextensions/test/browser/browser_webapi_install.js
index bc31c2331..bc31c2331 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_webapi_install.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_uninstall.js b/toolkit/mozapps/webextensions/test/browser/browser_webapi_uninstall.js
index 724f6fefe..724f6fefe 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_uninstall.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_webapi_uninstall.js
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webext_options.js b/toolkit/mozapps/webextensions/test/browser/browser_webext_options.js
index b13213f0b..b13213f0b 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webext_options.js
+++ b/toolkit/mozapps/webextensions/test/browser/browser_webext_options.js
diff --git a/toolkit/mozapps/extensions/test/browser/cancelCompatCheck.sjs b/toolkit/mozapps/webextensions/test/browser/cancelCompatCheck.sjs
index 38bc25d08..38bc25d08 100644
--- a/toolkit/mozapps/extensions/test/browser/cancelCompatCheck.sjs
+++ b/toolkit/mozapps/webextensions/test/browser/cancelCompatCheck.sjs
diff --git a/toolkit/mozapps/extensions/test/browser/discovery.html b/toolkit/mozapps/webextensions/test/browser/discovery.html
index 72f4fe374..72f4fe374 100644
--- a/toolkit/mozapps/extensions/test/browser/discovery.html
+++ b/toolkit/mozapps/webextensions/test/browser/discovery.html
diff --git a/toolkit/mozapps/extensions/test/browser/discovery_frame.html b/toolkit/mozapps/webextensions/test/browser/discovery_frame.html
index 8ec722812..8ec722812 100644
--- a/toolkit/mozapps/extensions/test/browser/discovery_frame.html
+++ b/toolkit/mozapps/webextensions/test/browser/discovery_frame.html
diff --git a/toolkit/mozapps/extensions/test/browser/discovery_install.html b/toolkit/mozapps/webextensions/test/browser/discovery_install.html
index c6499ec03..c6499ec03 100644
--- a/toolkit/mozapps/extensions/test/browser/discovery_install.html
+++ b/toolkit/mozapps/webextensions/test/browser/discovery_install.html
diff --git a/toolkit/mozapps/extensions/test/browser/head.js b/toolkit/mozapps/webextensions/test/browser/head.js
index 5a749099d..5a749099d 100644
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/webextensions/test/browser/head.js
diff --git a/toolkit/mozapps/extensions/test/browser/more_options.xul b/toolkit/mozapps/webextensions/test/browser/more_options.xul
index 28dbb0a2e..28dbb0a2e 100644
--- a/toolkit/mozapps/extensions/test/browser/more_options.xul
+++ b/toolkit/mozapps/webextensions/test/browser/more_options.xul
diff --git a/toolkit/mozapps/extensions/test/browser/moz.build b/toolkit/mozapps/webextensions/test/browser/moz.build
index af04aaeef..af04aaeef 100644
--- a/toolkit/mozapps/extensions/test/browser/moz.build
+++ b/toolkit/mozapps/webextensions/test/browser/moz.build
diff --git a/toolkit/mozapps/extensions/test/browser/options.xul b/toolkit/mozapps/webextensions/test/browser/options.xul
index 1b6827915..1b6827915 100644
--- a/toolkit/mozapps/extensions/test/browser/options.xul
+++ b/toolkit/mozapps/webextensions/test/browser/options.xul
diff --git a/toolkit/mozapps/extensions/test/browser/plugin_test.html b/toolkit/mozapps/webextensions/test/browser/plugin_test.html
index 0709eda06..0709eda06 100644
--- a/toolkit/mozapps/extensions/test/browser/plugin_test.html
+++ b/toolkit/mozapps/webextensions/test/browser/plugin_test.html
diff --git a/toolkit/mozapps/extensions/test/browser/redirect.sjs b/toolkit/mozapps/webextensions/test/browser/redirect.sjs
index 8f9d1c08a..8f9d1c08a 100644
--- a/toolkit/mozapps/extensions/test/browser/redirect.sjs
+++ b/toolkit/mozapps/webextensions/test/browser/redirect.sjs
diff --git a/toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml b/toolkit/mozapps/webextensions/test/browser/releaseNotes.xhtml
index 63ae07901..63ae07901 100644
--- a/toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml
+++ b/toolkit/mozapps/webextensions/test/browser/releaseNotes.xhtml
diff --git a/toolkit/mozapps/extensions/test/browser/signed_hotfix.rdf b/toolkit/mozapps/webextensions/test/browser/signed_hotfix.rdf
index 39bd936c9..39bd936c9 100644
--- a/toolkit/mozapps/extensions/test/browser/signed_hotfix.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/signed_hotfix.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/signed_hotfix.xpi b/toolkit/mozapps/webextensions/test/browser/signed_hotfix.xpi
index bd1890573..bd1890573 100644
--- a/toolkit/mozapps/extensions/test/browser/signed_hotfix.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/signed_hotfix.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/unsigned_hotfix.rdf b/toolkit/mozapps/webextensions/test/browser/unsigned_hotfix.rdf
index 2b4ba9362..2b4ba9362 100644
--- a/toolkit/mozapps/extensions/test/browser/unsigned_hotfix.rdf
+++ b/toolkit/mozapps/webextensions/test/browser/unsigned_hotfix.rdf
diff --git a/toolkit/mozapps/extensions/test/browser/unsigned_hotfix.xpi b/toolkit/mozapps/webextensions/test/browser/unsigned_hotfix.xpi
index f2d475bd2..f2d475bd2 100644
--- a/toolkit/mozapps/extensions/test/browser/unsigned_hotfix.xpi
+++ b/toolkit/mozapps/webextensions/test/browser/unsigned_hotfix.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/browser/webapi_addon_listener.html b/toolkit/mozapps/webextensions/test/browser/webapi_addon_listener.html
index 56128fd9c..56128fd9c 100644
--- a/toolkit/mozapps/extensions/test/browser/webapi_addon_listener.html
+++ b/toolkit/mozapps/webextensions/test/browser/webapi_addon_listener.html
diff --git a/toolkit/mozapps/extensions/test/browser/webapi_checkavailable.html b/toolkit/mozapps/webextensions/test/browser/webapi_checkavailable.html
index 141f09cc6..141f09cc6 100644
--- a/toolkit/mozapps/extensions/test/browser/webapi_checkavailable.html
+++ b/toolkit/mozapps/webextensions/test/browser/webapi_checkavailable.html
diff --git a/toolkit/mozapps/extensions/test/browser/webapi_checkchromeframe.xul b/toolkit/mozapps/webextensions/test/browser/webapi_checkchromeframe.xul
index 76e642604..76e642604 100644
--- a/toolkit/mozapps/extensions/test/browser/webapi_checkchromeframe.xul
+++ b/toolkit/mozapps/webextensions/test/browser/webapi_checkchromeframe.xul
diff --git a/toolkit/mozapps/extensions/test/browser/webapi_checkframed.html b/toolkit/mozapps/webextensions/test/browser/webapi_checkframed.html
index 146769978..146769978 100644
--- a/toolkit/mozapps/extensions/test/browser/webapi_checkframed.html
+++ b/toolkit/mozapps/webextensions/test/browser/webapi_checkframed.html
diff --git a/toolkit/mozapps/extensions/test/browser/webapi_checknavigatedwindow.html b/toolkit/mozapps/webextensions/test/browser/webapi_checknavigatedwindow.html
index ba3653310..ba3653310 100644
--- a/toolkit/mozapps/extensions/test/browser/webapi_checknavigatedwindow.html
+++ b/toolkit/mozapps/webextensions/test/browser/webapi_checknavigatedwindow.html
diff --git a/toolkit/mozapps/extensions/test/mochitest/.eslintrc.js b/toolkit/mozapps/webextensions/test/mochitest/.eslintrc.js
index 383da0f41..383da0f41 100644
--- a/toolkit/mozapps/extensions/test/mochitest/.eslintrc.js
+++ b/toolkit/mozapps/webextensions/test/mochitest/.eslintrc.js
diff --git a/toolkit/mozapps/extensions/test/mochitest/file_bug687194.xpi b/toolkit/mozapps/webextensions/test/mochitest/file_bug687194.xpi
index e215cffad..e215cffad 100644
--- a/toolkit/mozapps/extensions/test/mochitest/file_bug687194.xpi
+++ b/toolkit/mozapps/webextensions/test/mochitest/file_bug687194.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/mochitest/file_empty.html b/toolkit/mozapps/webextensions/test/mochitest/file_empty.html
index b6c8a53b4..b6c8a53b4 100644
--- a/toolkit/mozapps/extensions/test/mochitest/file_empty.html
+++ b/toolkit/mozapps/webextensions/test/mochitest/file_empty.html
diff --git a/toolkit/mozapps/extensions/test/mochitest/mochitest.ini b/toolkit/mozapps/webextensions/test/mochitest/mochitest.ini
index b14cfe87a..b14cfe87a 100644
--- a/toolkit/mozapps/extensions/test/mochitest/mochitest.ini
+++ b/toolkit/mozapps/webextensions/test/mochitest/mochitest.ini
diff --git a/toolkit/mozapps/extensions/test/mochitest/test_bug609794.html b/toolkit/mozapps/webextensions/test/mochitest/test_bug609794.html
index d13e6ef2f..d13e6ef2f 100644
--- a/toolkit/mozapps/extensions/test/mochitest/test_bug609794.html
+++ b/toolkit/mozapps/webextensions/test/mochitest/test_bug609794.html
diff --git a/toolkit/mozapps/extensions/test/mochitest/test_bug687194.html b/toolkit/mozapps/webextensions/test/mochitest/test_bug687194.html
index 8f99ea73a..8f99ea73a 100644
--- a/toolkit/mozapps/extensions/test/mochitest/test_bug687194.html
+++ b/toolkit/mozapps/webextensions/test/mochitest/test_bug687194.html
diff --git a/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html b/toolkit/mozapps/webextensions/test/mochitest/test_bug887098.html
index 535799b27..535799b27 100644
--- a/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html
+++ b/toolkit/mozapps/webextensions/test/mochitest/test_bug887098.html
diff --git a/toolkit/mozapps/extensions/test/moz.build b/toolkit/mozapps/webextensions/test/moz.build
index 716659198..716659198 100644
--- a/toolkit/mozapps/extensions/test/moz.build
+++ b/toolkit/mozapps/webextensions/test/moz.build
diff --git a/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js b/toolkit/mozapps/webextensions/test/xpcshell/.eslintrc.js
index ba65517f9..ba65517f9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/.eslintrc.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm b/toolkit/mozapps/webextensions/test/xpcshell/data/BootstrapMonitor.jsm
index 7c1e4aa9d..7c1e4aa9d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/BootstrapMonitor.jsm
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_change.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_change.xml
index a229a653a..a229a653a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_change.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_change.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update1.rdf
index 588290968..588290968 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update1.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update2.rdf
index 5c3747f5f..5c3747f5f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update2.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update3.rdf
index d60708414..d60708414 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/addon_update3.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/app_update.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/app_update.xml
index 85a66fe55..85a66fe55 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/app_update.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/app_update.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/blocklist_update1.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/blocklist_update1.xml
index 87011cd39..87011cd39 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/blocklist_update1.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/blocklist_update1.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/blocklist_update2.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/blocklist_update2.xml
index 867a34255..867a34255 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/blocklist_update2.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/blocklist_update2.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/manual_update.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/manual_update.xml
index df9276525..df9276525 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/manual_update.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/blocklistchange/manual_update.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/bug455906_block.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_block.xml
index 1f673ef2f..1f673ef2f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/bug455906_block.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_block.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/bug455906_empty.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_empty.xml
index 88d22f281..88d22f281 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/bug455906_empty.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_empty.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/bug455906_start.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_start.xml
index daba6f4c1..daba6f4c1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/bug455906_start.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_start.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/bug455906_warn.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_warn.xml
index 232fd0d07..232fd0d07 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/bug455906_warn.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/bug455906_warn.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/corrupt.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/corrupt.xpi
index 35d7bd5e5..35d7bd5e5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/corrupt.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/corrupt.xpi
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/corruptfile.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/corruptfile.xpi
index 0c30989aa..0c30989aa 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/corruptfile.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/corruptfile.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/empty.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/empty.xpi
index 74ed2b817..74ed2b817 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/empty.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/empty.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/from_sources/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/from_sources/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/install.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/from_sources/install.rdf
index f02a3869c..f02a3869c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/install.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/from_sources/install.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/pluginInfoURL_block.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/pluginInfoURL_block.xml
index 75e252a46..75e252a46 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/pluginInfoURL_block.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/pluginInfoURL_block.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.txt b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad.txt
index f17f98b15..f17f98b15 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.txt
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad.txt
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad.xml
index 0e3d415c4..0e3d415c4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad2.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad2.xml
index 55ad1c7d5..55ad1c7d5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad2.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/bad2.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/empty.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/empty.xml
index 42cb20bd0..42cb20bd0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/empty.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/empty.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/good.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/good.xml
index e1da86fa5..e1da86fa5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/good.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/good.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/missing.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/missing.xml
index 8c9501478..8c9501478 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/missing.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/missing.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/unsigned.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/unsigned.xpi
index 51b00475a..51b00475a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/unsigned.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/productaddons/unsigned.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js
index 0cf01d319..0cf01d319 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf
index 9d08c357c..9d08c357c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt
index 11686f61c..11686f61c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js
index 718c82be4..718c82be4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf
index 0a345dd92..0a345dd92 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt
index 11686f61c..11686f61c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi
index 9d6f0c708..9d6f0c708 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi
index 4496a90cf..4496a90cf 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_good.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_good.xpi
index e61e3c721..e61e3c721 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_good.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/hotfix_good.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_hash.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_63_hash.xpi
index 1682a7506..1682a7506 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_hash.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_63_hash.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_plain.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_63_plain.xpi
index cd67e25fc..cd67e25fc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_plain.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_63_plain.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_hash.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_64_hash.xpi
index e4040a274..e4040a274 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_hash.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_64_hash.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_plain.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_64_plain.xpi
index ca453b9d5..ca453b9d5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_plain.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_64_plain.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_65_hash.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_65_hash.xpi
index 69579d2dc..69579d2dc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_65_hash.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/long_65_hash.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_badid.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_badid.xpi
index 6e23eb214..6e23eb214 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_badid.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_badid.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_broken.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_broken.xpi
index 0ba0f30d1..0ba0f30d1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_broken.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_broken.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_signed.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_signed.xpi
index 33101f63c..33101f63c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_signed.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_signed.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi
index 3146870d8..3146870d8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf
index 97ae60988..97ae60988 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt
index 11686f61c..11686f61c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf
index df2fd8081..df2fd8081 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt
index 11686f61c..11686f61c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi
index ec38fcc65..ec38fcc65 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi
index fc2842399..fc2842399 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi
index 327c8a187..327c8a187 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi
index efad21d1b..efad21d1b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi
index d6ddbcec3..d6ddbcec3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi
index 5898d83e4..5898d83e4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi
index 9d50f0825..9d50f0825 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi
index 6ba1efd72..6ba1efd72 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_1.xpi
index 2fc2fd189..2fc2fd189 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi
index e7e50c8ea..e7e50c8ea 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_2.xpi
index a858cf74a..a858cf74a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system1_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_1.xpi
index 911632e49..911632e49 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_2.xpi
index 102a053bb..102a053bb 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_3.xpi
index 295e77611..295e77611 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system2_3.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_1.xpi
index 954995619..954995619 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_2.xpi
index dc8632aef..dc8632aef 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_3.xpi
index 3f818172a..3f818172a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system3_3.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system4_1.xpi
index 1f70b1a75..1f70b1a75 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system4_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system5_1.xpi
index fc636e97f..fc636e97f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system5_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi
index ff620966d..ff620966d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi
index e474dbd59..e474dbd59 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi
index 1ccde90c5..1ccde90c5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_complete.xpi
index 94d9e47d2..94d9e47d2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_complete.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi
index 28c8561c6..28c8561c6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer.xpi
index daf55c0d4..daf55c0d4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi
index 75cacbbc8..75cacbbc8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi
index 2eb6b7fc9..2eb6b7fc9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi
index fb588b3e0..fb588b3e0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi
index 7a5eb265d..7a5eb265d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi
index dc6749355..dc6749355 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_failed_update.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_failed_update.xpi
index 3c673ac2e..3c673ac2e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_failed_update.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/system_addons/system_failed_update.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository.xml
index 0bebca2c1..0bebca2c1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_cache.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_cache.xml
index f707f1217..f707f1217 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_cache.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_cache.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_ignore.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_ignore.xml
index 003095727..003095727 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_ignore.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_ignore.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_normal.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_normal.xml
index fec8b09ca..fec8b09ca 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_normal.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_normal.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_strict.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_strict.xml
index f99256b87..f99256b87 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_compatmode_strict.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_compatmode_strict.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_empty.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_empty.xml
index 4cd5c1443..4cd5c1443 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_empty.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_empty.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_failed.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_failed.xml
index d02fa0249..d02fa0249 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_failed.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_failed.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_getAddonsByIDs.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_getAddonsByIDs.xml
index 8a6167969..8a6167969 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_getAddonsByIDs.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_AddonRepository_getAddonsByIDs.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_backgroundupdate.rdf
index ab7cdef34..ab7cdef34 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_backgroundupdate.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_metadata_filters_1.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_metadata_filters_1.xml
index 368a6ed53..368a6ed53 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_metadata_filters_1.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_metadata_filters_1.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_prefs_1.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_prefs_1.xml
index 41df457b0..41df457b0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_prefs_1.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_prefs_1.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_regexp_1.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_regexp_1.xml
index 20035c6a2..20035c6a2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_blocklist_regexp_1.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_blocklist_regexp_1.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug299716.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug299716.rdf
index d60d8ca3f..d60d8ca3f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug299716.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug299716.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug299716_2.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug299716_2.rdf
index 94a4ea450..94a4ea450 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug299716_2.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug299716_2.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug324121.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug324121.rdf
index 2c453f756..2c453f756 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug324121.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug324121.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug393285.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug393285.xml
index 1767b4332..1767b4332 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug393285.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug393285.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug394300.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug394300.rdf
index 94e12527f..94e12527f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug394300.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug394300.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug424262.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug424262.xml
index d797debbb..d797debbb 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug424262.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug424262.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug449027_app.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug449027_app.xml
index f12ca1fa6..f12ca1fa6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug449027_app.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug449027_app.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug449027_toolkit.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug449027_toolkit.xml
index ad8ec5ed9..ad8ec5ed9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug449027_toolkit.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug449027_toolkit.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug468528.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug468528.xml
index 85f0da57c..85f0da57c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug468528.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug468528.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_1.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_1.rdf
index 5397e8a87..5397e8a87 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_1.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_1.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_2.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_2.rdf
index b1dde7f7a..b1dde7f7a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_2.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_2.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_3.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_3.rdf
index ae483434a..ae483434a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_3.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_3.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_4.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_4.rdf
index 97abacc5e..97abacc5e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_4.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_4.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_5.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_5.rdf
index bff1104a7..bff1104a7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/install_5.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/install_5.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_1.rdf
index e4ad91ae9..e4ad91ae9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_1.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_2.rdf
index 10fcafd39..10fcafd39 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_2.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_3.rdf
index 684002462..684002462 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_3.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_4.rdf
index 6e7116239..6e7116239 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_4.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_5.rdf
index c926af934..c926af934 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug470377/update_5.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_1.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_1.xml
index c4cc2fe37..c4cc2fe37 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_1.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_1.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_2.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_2.xml
index cc0a0c69d..cc0a0c69d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_2.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_2.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_empty.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_empty.xml
index 0261794f8..0261794f8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_empty.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_empty.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_outdated_1.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_outdated_1.xml
index d651f8799..d651f8799 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_outdated_1.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_outdated_1.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_outdated_2.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_outdated_2.xml
index 208444681..208444681 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug514327_3_outdated_2.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug514327_3_outdated_2.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug526598_1.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug526598_1.xpi
index 2dbcc0b50..2dbcc0b50 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug526598_1.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug526598_1.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug526598_2.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug526598_2.xpi
index 86fc6baaa..86fc6baaa 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug526598_2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug526598_2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug541420.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug541420.xpi
index adb7be9ad..adb7be9ad 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug541420.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug541420.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug542391.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug542391.rdf
index db82cf675..db82cf675 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug542391.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug542391.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug554133.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug554133.xml
index 736c10514..736c10514 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug554133.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug554133.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug619730.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug619730.xml
index f2511c0de..f2511c0de 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug619730.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug619730.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug655254.rdf
index 9857dcb55..9857dcb55 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_bug655254.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_compatoverrides.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_compatoverrides.xml
index c0d67d033..c0d67d033 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_compatoverrides.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_compatoverrides.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_corrupt.rdf
index f3341bdcf..f3341bdcf 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_corrupt.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js
index a81c90bf0..a81c90bf0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js
index 25ffd8565..25ffd8565 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js
index 7693c9c2d..7693c9c2d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.json b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_complete.json
index cf3defdc7..cf3defdc7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.json
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_complete.json
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_complete.rdf
index 8af39cb0e..8af39cb0e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_complete.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.json b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_defer.json
index 2fcab10b5..2fcab10b5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.json
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_defer.json
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_defer.rdf
index d44d4880f..d44d4880f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_defer.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.json b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_ignore.json
index b7f48149d..b7f48149d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.json
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_ignore.json
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_ignore.rdf
index 866884f8d..866884f8d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_delay_updates_ignore.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_dictionary.rdf
index 364b3bba1..364b3bba1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_dictionary.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/bootstrap.js
index 01682d3b7..01682d3b7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/install.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/install.rdf
index ebe547ccc..ebe547ccc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/install.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/install.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/subdir/dummy.txt b/toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/subdir/dummy.txt
index 051aef85a..051aef85a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/subdir/dummy.txt
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/subdir/dummy.txt
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/subdir/subdir2/dummy2.txt b/toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/subdir/subdir2/dummy2.txt
index 9eddc4493..9eddc4493 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_distribution2_2/subdir/subdir2/dummy2.txt
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_distribution2_2/subdir/subdir2/dummy2.txt
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist.xml
index d535d2c3f..d535d2c3f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist2.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist2.xml
index 0ad8f6819..0ad8f6819 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist2.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist2.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml
index f64676355..f64676355 100755..100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml
index 248868a2e..248868a2e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_1.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_1.rdf
index 016726021..016726021 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_1.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_1.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_2.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_2.rdf
index 35a2befee..35a2befee 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_2.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_2.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_3.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_3.rdf
index 7180da143..7180da143 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_3.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_hotfix_3.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_install.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_install.rdf
index fe82334fa..fe82334fa 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_install.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_install.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_install.xml
index 33f14a2fd..33f14a2fd 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_install.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_migrate.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_migrate.rdf
index d1dc992d5..d1dc992d5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_migrate.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_migrate.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_migrate4.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_migrate4.rdf
index a3bf4f8ae..a3bf4f8ae 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_migrate4.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_migrate4.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_no_update.json b/toolkit/mozapps/webextensions/test/xpcshell/data/test_no_update.json
index 2773c7f98..2773c7f98 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_no_update.json
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_no_update.json
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/ancient.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/ancient.xml
index 699257f87..699257f87 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/ancient.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/ancient.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/new.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/new.xml
index 8cbfb5d6a..8cbfb5d6a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/new.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/new.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/old.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/old.xml
index 75bd6e934..75bd6e934 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_overrideblocklist/old.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_overrideblocklist/old.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_pluginBlocklistCtp.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_pluginBlocklistCtp.xml
index d3564aebd..d3564aebd 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_pluginBlocklistCtp.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_pluginBlocklistCtp.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_pluginBlocklistCtpUndo.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_pluginBlocklistCtpUndo.xml
index 7cd8496b3..7cd8496b3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_pluginBlocklistCtpUndo.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_pluginBlocklistCtpUndo.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_proxy/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/test_proxy/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_proxy/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_proxy/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_softblocked1.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_softblocked1.xml
index a1d18470c..a1d18470c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_softblocked1.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_softblocked1.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_sourceURI.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_sourceURI.xml
index 949288e3f..949288e3f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_sourceURI.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_sourceURI.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_temporary/bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/data/test_temporary/bootstrap.js
index 1666f2972..1666f2972 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_temporary/bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_temporary/bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_update.json b/toolkit/mozapps/webextensions/test/xpcshell/data/test_update.json
index 027a9b233..027a9b233 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_update.json
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_update.json
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_update.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_update.rdf
index 4d4640f60..4d4640f60 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_update.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_update.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_update.xml b/toolkit/mozapps/webextensions/test/xpcshell/data/test_update.xml
index 62928815b..62928815b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_update.xml
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_update.xml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_update_multi.rdf
index f28a3f26d..f28a3f26d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_update_multi.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.json b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecheck.json
index 811e50158..811e50158 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.json
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecheck.json
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecheck.rdf
index c5d97ada0..c5d97ada0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecheck.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf
index ec6e88ec4..ec6e88ec4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_normal.rdf
index 2ef88860e..2ef88860e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_normal.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_strict.rdf
index 2f72c181d..2f72c181d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updatecompatmode_strict.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updateid.rdf
index c13928520..c13928520 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/test_updateid.rdf
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/unsigned.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/unsigned.xpi
index 51b00475a..51b00475a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/unsigned.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/unsigned.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpi b/toolkit/mozapps/webextensions/test/xpcshell/data/webext-implicit-id.xpi
index 6b4abaa69..6b4abaa69 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpi
+++ b/toolkit/mozapps/webextensions/test/xpcshell/data/webext-implicit-id.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/webextensions/test/xpcshell/head_addons.js
index 960caceeb..960caceeb 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/head_addons.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_unpack.js b/toolkit/mozapps/webextensions/test/xpcshell/head_unpack.js
index 6310bbc60..6310bbc60 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/head_unpack.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/head_unpack.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js b/toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository.js
index dd0dc1981..dd0dc1981 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js b/toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository_cache.js
index 203235940..203235940 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository_cache.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js b/toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository_compatmode.js
index 6aec96ea1..6aec96ea1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_AddonRepository_compatmode.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_ChromeManifestParser.js b/toolkit/mozapps/webextensions/test/xpcshell/test_ChromeManifestParser.js
index 605c4224b..605c4224b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_ChromeManifestParser.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_ChromeManifestParser.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_DeferredSave.js b/toolkit/mozapps/webextensions/test/xpcshell/test_DeferredSave.js
index 2a6ff291e..2a6ff291e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_DeferredSave.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_DeferredSave.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js b/toolkit/mozapps/webextensions/test/xpcshell/test_LightweightThemeManager.js
index 61a46b251..61a46b251 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_LightweightThemeManager.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js b/toolkit/mozapps/webextensions/test/xpcshell/test_ProductAddonChecker.js
index 6c562db65..6c562db65 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_ProductAddonChecker.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js b/toolkit/mozapps/webextensions/test/xpcshell/test_XPIStates.js
index 99ab8ab13..99ab8ab13 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_XPIStates.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_XPIcancel.js b/toolkit/mozapps/webextensions/test/xpcshell/test_XPIcancel.js
index d733778a5..d733778a5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_XPIcancel.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_XPIcancel.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_addon_path_service.js b/toolkit/mozapps/webextensions/test/xpcshell/test_addon_path_service.js
index 56ce3c614..56ce3c614 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_addon_path_service.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_addon_path_service.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_asyncBlocklistLoad.js b/toolkit/mozapps/webextensions/test/xpcshell/test_asyncBlocklistLoad.js
index 38e563979..38e563979 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_asyncBlocklistLoad.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_asyncBlocklistLoad.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js b/toolkit/mozapps/webextensions/test/xpcshell/test_backgroundupdate.js
index 3890b76e1..3890b76e1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_backgroundupdate.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bad_json.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bad_json.js
index d3ccf68f3..d3ccf68f3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bad_json.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bad_json.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js b/toolkit/mozapps/webextensions/test/xpcshell/test_badschema.js
index 6ebf088d6..6ebf088d6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_badschema.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_gfx.js b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_gfx.js
index cbcd5cb7e..cbcd5cb7e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_gfx.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_gfx.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_metadata_filters.js
index 5befa6fa0..5befa6fa0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_metadata_filters.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_prefs.js
index 41ef62f98..41ef62f98 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_prefs.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_regexp.js
index c89ccdef8..c89ccdef8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklist_regexp.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklistchange.js
index d065f700d..d065f700d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_blocklistchange.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap.js
index ff58599bc..ff58599bc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_const.js
index 101d49510..101d49510 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_const.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_globals.js
index 29b538d21..29b538d21 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_globals.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_resource.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_resource.js
index 7b7883225..7b7883225 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_resource.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bootstrap_resource.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug1180901.js
index c13531dff..c13531dff 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug1180901.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901_2.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug1180901_2.js
index 8e9f30ef2..8e9f30ef2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901_2.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug1180901_2.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug299716.js
index 66656abe6..66656abe6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug299716.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716_2.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug299716_2.js
index c183edad4..c183edad4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716_2.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug299716_2.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug324121.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug324121.js
index 84b6c6189..84b6c6189 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug324121.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug324121.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug335238.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug335238.js
index 251bdca70..251bdca70 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug335238.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug335238.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug371495.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug371495.js
index 43656f126..43656f126 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug371495.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug371495.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug384052.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug384052.js
index aeaaf3d8f..aeaaf3d8f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug384052.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug384052.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug393285.js
index ebc330cdd..ebc330cdd 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug393285.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug394300.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug394300.js
index bd393b91c..bd393b91c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug394300.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug394300.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug397778.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug397778.js
index aa18a6946..aa18a6946 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug397778.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug397778.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug406118.js
index e22ab87c9..e22ab87c9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug406118.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug424262.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug424262.js
index 8b29e15a5..8b29e15a5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug424262.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug424262.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug425657.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug425657.js
index f11a942fb..f11a942fb 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug425657.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug425657.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug430120.js
index e13f36a7c..e13f36a7c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug430120.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug449027.js
index 1512a7f92..1512a7f92 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug449027.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug455906.js
index 06e29b376..06e29b376 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug455906.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug465190.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug465190.js
index e8e2353e2..e8e2353e2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug465190.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug465190.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug468528.js
index 01c976a17..01c976a17 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug468528.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_1.js
index 920c3731a..920c3731a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_1.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1_strictcompat.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_1_strictcompat.js
index 6fa11eb39..6fa11eb39 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1_strictcompat.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_1_strictcompat.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_2.js
index 0c912ceff..0c912ceff 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_2.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_3.js
index 0d1d30f3b..0d1d30f3b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_3.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_3_strictcompat.js
index 100ea99d7..100ea99d7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_3_strictcompat.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_4.js
index c51c38b0c..c51c38b0c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug470377_4.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_1.js
index 46b65ffff..46b65ffff 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_1.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_2.js
index 261739da4..261739da4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_2.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_3.js
index 634361991..634361991 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug514327_3.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug521905.js
index b507fc100..b507fc100 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug521905.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug526598.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug526598.js
index debf59172..debf59172 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug526598.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug526598.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug541420.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug541420.js
index b7af5453f..b7af5453f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug541420.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug541420.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug542391.js
index aa1bbd53f..aa1bbd53f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug542391.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug554133.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug554133.js
index c252e1ced..c252e1ced 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug554133.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug554133.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug559800.js
index 866ad3ad7..866ad3ad7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug559800.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug563256.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug563256.js
index 497e66526..497e66526 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug563256.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug563256.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug564030.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug564030.js
index 92ba3d68f..92ba3d68f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug564030.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug564030.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug566626.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug566626.js
index 641ff87c9..641ff87c9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug566626.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug566626.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug567184.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug567184.js
index 0e7863068..0e7863068 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug567184.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug567184.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug569138.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug569138.js
index 4869fc117..4869fc117 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug569138.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug569138.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug570173.js
index 2c87d8c79..2c87d8c79 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug570173.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug576735.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug576735.js
index df64e159d..df64e159d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug576735.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug576735.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug587088.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug587088.js
index 8d9857e7f..8d9857e7f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug587088.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug587088.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug594058.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug594058.js
index 858579815..858579815 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug594058.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug594058.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug595081.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug595081.js
index db53dc747..db53dc747 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug595081.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug595081.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug595573.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug595573.js
index 7e2bf7d77..7e2bf7d77 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug595573.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug595573.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug596607.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug596607.js
index bdcf93a1f..bdcf93a1f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug596607.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug596607.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug616841.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug616841.js
index d0c973960..d0c973960 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug616841.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug616841.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug619730.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug619730.js
index 1c21385e0..1c21385e0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug619730.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug619730.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug620837.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug620837.js
index 6bfbfcaf2..6bfbfcaf2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug620837.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug620837.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug655254.js
index 449c59065..449c59065 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug655254.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug659772.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug659772.js
index 6e98a69a4..6e98a69a4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug659772.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug659772.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug675371.js
index 6f2a5e7cd..6f2a5e7cd 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug675371.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug740612.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug740612.js
index d17e7acde..d17e7acde 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug740612.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug740612.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug753900.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug753900.js
index 206862339..206862339 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug753900.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug753900.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug757663.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug757663.js
index 54cee0839..54cee0839 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug757663.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug757663.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug953156.js b/toolkit/mozapps/webextensions/test/xpcshell/test_bug953156.js
index a7acb9ad2..a7acb9ad2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug953156.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_bug953156.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js b/toolkit/mozapps/webextensions/test/xpcshell/test_cache_certdb.js
index edb442aad..edb442aad 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_cache_certdb.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_cacheflush.js b/toolkit/mozapps/webextensions/test/xpcshell/test_cacheflush.js
index f3448abd2..f3448abd2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_cacheflush.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_cacheflush.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.js b/toolkit/mozapps/webextensions/test/xpcshell/test_checkCompatibility_themeOverride.js
index b6cb13e08..b6cb13e08 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_checkCompatibility_themeOverride.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js b/toolkit/mozapps/webextensions/test/xpcshell/test_checkcompatibility.js
index b9fc0b3ab..b9fc0b3ab 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_checkcompatibility.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_childprocess.js b/toolkit/mozapps/webextensions/test/xpcshell/test_childprocess.js
index a6c635eac..a6c635eac 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_childprocess.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_childprocess.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js b/toolkit/mozapps/webextensions/test/xpcshell/test_compatoverrides.js
index c079534c3..c079534c3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_compatoverrides.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js b/toolkit/mozapps/webextensions/test/xpcshell/test_corrupt.js
index 210c6a936..210c6a936 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_corrupt.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js b/toolkit/mozapps/webextensions/test/xpcshell/test_corrupt_strictcompat.js
index 622973472..622973472 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_corrupt_strictcompat.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corruptfile.js b/toolkit/mozapps/webextensions/test/xpcshell/test_corruptfile.js
index 92b375850..92b375850 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_corruptfile.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_corruptfile.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dataDirectory.js b/toolkit/mozapps/webextensions/test/xpcshell/test_dataDirectory.js
index bf75818e9..bf75818e9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dataDirectory.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_dataDirectory.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_default_providers_pref.js b/toolkit/mozapps/webextensions/test/xpcshell/test_default_providers_pref.js
index 1b61e033a..1b61e033a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_default_providers_pref.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_default_providers_pref.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js b/toolkit/mozapps/webextensions/test/xpcshell/test_delay_update.js
index 3d7eef051..3d7eef051 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_delay_update.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js b/toolkit/mozapps/webextensions/test/xpcshell/test_delay_update_webextension.js
index cdfac8f8c..cdfac8f8c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_delay_update_webextension.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dependencies.js b/toolkit/mozapps/webextensions/test/xpcshell/test_dependencies.js
index 3afc03f84..3afc03f84 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dependencies.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_dependencies.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js b/toolkit/mozapps/webextensions/test/xpcshell/test_dictionary.js
index f4b6a0535..f4b6a0535 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_dictionary.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_disable.js b/toolkit/mozapps/webextensions/test/xpcshell/test_disable.js
index 867715863..867715863 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_disable.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_disable.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_distribution.js b/toolkit/mozapps/webextensions/test/xpcshell/test_distribution.js
index 720b454cc..720b454cc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_distribution.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_distribution.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dss.js b/toolkit/mozapps/webextensions/test/xpcshell/test_dss.js
index b408cc9c7..b408cc9c7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dss.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_dss.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js b/toolkit/mozapps/webextensions/test/xpcshell/test_duplicateplugins.js
index 4d1848ea4..4d1848ea4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_duplicateplugins.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_e10s_restartless.js b/toolkit/mozapps/webextensions/test/xpcshell/test_e10s_restartless.js
index 1a3a0e747..1a3a0e747 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_e10s_restartless.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_e10s_restartless.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_error.js b/toolkit/mozapps/webextensions/test/xpcshell/test_error.js
index 11a465b55..11a465b55 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_error.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_error.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js b/toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js
index 3dcd83da8..3dcd83da8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js b/toolkit/mozapps/webextensions/test/xpcshell/test_ext_management.js
index a3b3f477c..a3b3f477c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_ext_management.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js b/toolkit/mozapps/webextensions/test/xpcshell/test_filepointer.js
index 406489e40..406489e40 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_filepointer.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_fuel.js b/toolkit/mozapps/webextensions/test/xpcshell/test_fuel.js
index 0c3035f76..0c3035f76 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_fuel.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_fuel.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_general.js b/toolkit/mozapps/webextensions/test/xpcshell/test_general.js
index e69b13314..e69b13314 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_general.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_general.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_getresource.js b/toolkit/mozapps/webextensions/test/xpcshell/test_getresource.js
index c83638d54..c83638d54 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_getresource.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_getresource.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Device.js
index 9b0eb54a7..9b0eb54a7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Device.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
index f8b783ff2..f8b783ff2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
index 1b3410e87..1b3410e87 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
index 248c9e7f6..248c9e7f6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
index 8b8928bb8..8b8928bb8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
index bd5858023..bd5858023 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
index b5c5ed2a6..b5c5ed2a6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
index ff37e6676..ff37e6676 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OK.js
index 72b2a2bdc..72b2a2bdc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OK.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OS.js
index fa0deb19a..fa0deb19a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OS.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
index f01329b45..f01329b45 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
index 4b1069dc6..4b1069dc6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
index 0c5a0dcb7..0c5a0dcb7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Vendor.js
index 868c48149..868c48149 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Vendor.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Version.js
index 48174b772..48174b772 100755..100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_Version.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_prefs.js
index fbb992879..fbb992879 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gfxBlacklist_prefs.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js b/toolkit/mozapps/webextensions/test/xpcshell/test_gmpProvider.js
index 545d7d666..545d7d666 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_gmpProvider.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.js b/toolkit/mozapps/webextensions/test/xpcshell/test_hasbinarycomponents.js
index 925e63626..925e63626 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_hasbinarycomponents.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_hotfix.js b/toolkit/mozapps/webextensions/test/xpcshell/test_hotfix.js
index c9303897f..c9303897f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_hotfix.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_hotfix.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_hotfix_cert.js b/toolkit/mozapps/webextensions/test/xpcshell/test_hotfix_cert.js
index 42ee59740..42ee59740 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_hotfix_cert.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_hotfix_cert.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install.js b/toolkit/mozapps/webextensions/test/xpcshell/test_install.js
index 60af3a9fd..60af3a9fd 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_install.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install_from_sources.js b/toolkit/mozapps/webextensions/test/xpcshell/test_install_from_sources.js
index 18bb7d74e..18bb7d74e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install_from_sources.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_install_from_sources.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js b/toolkit/mozapps/webextensions/test/xpcshell/test_install_icons.js
index 70f91c560..70f91c560 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_install_icons.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install_strictcompat.js b/toolkit/mozapps/webextensions/test/xpcshell/test_install_strictcompat.js
index 77f806ba2..77f806ba2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install_strictcompat.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_install_strictcompat.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js b/toolkit/mozapps/webextensions/test/xpcshell/test_isDebuggable.js
index 87f2856b0..87f2856b0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_isDebuggable.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_isReady.js b/toolkit/mozapps/webextensions/test/xpcshell/test_isReady.js
index 6222398a7..6222398a7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_isReady.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_isReady.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js b/toolkit/mozapps/webextensions/test/xpcshell/test_json_updatecheck.js
index adf789afb..adf789afb 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_json_updatecheck.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_langpack.js b/toolkit/mozapps/webextensions/test/xpcshell/test_langpack.js
index a97a14d4d..a97a14d4d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_langpack.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_langpack.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locale.js b/toolkit/mozapps/webextensions/test/xpcshell/test_locale.js
index b4c7311e5..b4c7311e5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_locale.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_locale.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locked.js b/toolkit/mozapps/webextensions/test/xpcshell/test_locked.js
index 86457eab1..86457eab1 100755..100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_locked.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_locked.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locked2.js b/toolkit/mozapps/webextensions/test/xpcshell/test_locked2.js
index 4a62c585f..4a62c585f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_locked2.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_locked2.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js b/toolkit/mozapps/webextensions/test/xpcshell/test_locked_strictcompat.js
index 9e17b4c8b..9e17b4c8b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_locked_strictcompat.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_manifest.js b/toolkit/mozapps/webextensions/test/xpcshell/test_manifest.js
index 85279ba5d..85279ba5d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_manifest.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_manifest.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js b/toolkit/mozapps/webextensions/test/xpcshell/test_mapURIToAddonID.js
index 1dd05064e..1dd05064e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_mapURIToAddonID.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_metadata_update.js b/toolkit/mozapps/webextensions/test/xpcshell/test_metadata_update.js
index dbf5db485..dbf5db485 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_metadata_update.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_metadata_update.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate1.js
index 8c13593b9..8c13593b9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate1.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate2.js b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate2.js
index cc7336713..cc7336713 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate2.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate2.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate3.js b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate3.js
index 71bd66603..71bd66603 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate3.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate3.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate4.js b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate4.js
index fad015886..fad015886 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate4.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate4.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate5.js b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate5.js
index 885cd5a7c..885cd5a7c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate5.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate5.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js b/toolkit/mozapps/webextensions/test/xpcshell/test_migrateAddonRepository.js
index d9cfc8790..d9cfc8790 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_migrateAddonRepository.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate_max_version.js b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate_max_version.js
index 171ac411e..171ac411e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate_max_version.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_migrate_max_version.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js b/toolkit/mozapps/webextensions/test/xpcshell/test_multiprocessCompatible.js
index 4cd103fa6..4cd103fa6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_multiprocessCompatible.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js b/toolkit/mozapps/webextensions/test/xpcshell/test_no_addons.js
index a2ea5301e..a2ea5301e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_no_addons.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js b/toolkit/mozapps/webextensions/test/xpcshell/test_nodisable_hidden.js
index 2d11e9c5b..2d11e9c5b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_nodisable_hidden.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_onPropertyChanged_appDisabled.js b/toolkit/mozapps/webextensions/test/xpcshell/test_onPropertyChanged_appDisabled.js
index f9b7da073..f9b7da073 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_onPropertyChanged_appDisabled.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_onPropertyChanged_appDisabled.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js b/toolkit/mozapps/webextensions/test/xpcshell/test_overrideblocklist.js
index c39e432bd..c39e432bd 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_overrideblocklist.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pass_symbol.js b/toolkit/mozapps/webextensions/test/xpcshell/test_pass_symbol.js
index 657601e45..657601e45 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pass_symbol.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_pass_symbol.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js b/toolkit/mozapps/webextensions/test/xpcshell/test_permissions.js
index 48fef406f..48fef406f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_permissions.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js b/toolkit/mozapps/webextensions/test/xpcshell/test_permissions_prefs.js
index 576f04a65..576f04a65 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_permissions_prefs.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js b/toolkit/mozapps/webextensions/test/xpcshell/test_pluginBlocklistCtp.js
index 563b7434c..563b7434c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_pluginBlocklistCtp.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js b/toolkit/mozapps/webextensions/test/xpcshell/test_pluginInfoURL.js
index e5acb28a4..e5acb28a4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_pluginInfoURL.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js b/toolkit/mozapps/webextensions/test/xpcshell/test_pluginchange.js
index 05e17b35e..05e17b35e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_pluginchange.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js b/toolkit/mozapps/webextensions/test/xpcshell/test_plugins.js
index 3f0ac7ebe..3f0ac7ebe 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_plugins.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js b/toolkit/mozapps/webextensions/test/xpcshell/test_pref_properties.js
index c6a10e7c1..c6a10e7c1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_pref_properties.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_markSafe.js
index 228eb7d34..228eb7d34 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_markSafe.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js
index d210eb81d..d210eb81d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
index f90e38292..f90e38292 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_unsafe_access_startup.js
index 1193ddfe4..1193ddfe4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_unsafe_access_startup.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js b/toolkit/mozapps/webextensions/test/xpcshell/test_proxies.js
index 7b28c78f2..7b28c78f2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_proxies.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_proxy.js b/toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js
index c35870c9b..c35870c9b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_proxy.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_registry.js b/toolkit/mozapps/webextensions/test/xpcshell/test_registry.js
index eab7af6b6..eab7af6b6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_registry.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_registry.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_reload.js b/toolkit/mozapps/webextensions/test/xpcshell/test_reload.js
index 5873d1980..5873d1980 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_reload.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_reload.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_safemode.js b/toolkit/mozapps/webextensions/test/xpcshell/test_safemode.js
index 05647f807..05647f807 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_safemode.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_safemode.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js b/toolkit/mozapps/webextensions/test/xpcshell/test_schema_change.js
index 3d386f663..3d386f663 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_schema_change.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_seen.js b/toolkit/mozapps/webextensions/test/xpcshell/test_seen.js
index e499e7339..e499e7339 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_seen.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_seen.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js b/toolkit/mozapps/webextensions/test/xpcshell/test_seen_newprofile.js
index 43ee18594..43ee18594 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_seen_newprofile.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js b/toolkit/mozapps/webextensions/test/xpcshell/test_shutdown.js
index 725887bc1..725887bc1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_shutdown.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_inject.js
index 3b96f40ba..3b96f40ba 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_inject.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_install.js
index 19b07ac16..19b07ac16 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_install.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js
index b74d7804a..b74d7804a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_migrate.js
index 97e2ff79f..97e2ff79f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_migrate.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_multi.js b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_multi.js
index 01de29088..01de29088 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_multi.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_multi.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_updatepref.js
index eb1bb78b3..eb1bb78b3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_updatepref.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_verify.js
index 0b5b30d89..0b5b30d89 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_verify.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js b/toolkit/mozapps/webextensions/test/xpcshell/test_softblocked.js
index 260b536e1..260b536e1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_softblocked.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js b/toolkit/mozapps/webextensions/test/xpcshell/test_sourceURI.js
index db5e4f7cc..db5e4f7cc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_sourceURI.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_startup.js b/toolkit/mozapps/webextensions/test/xpcshell/test_startup.js
index fdd00c1ad..fdd00c1ad 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_startup.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_startup.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js b/toolkit/mozapps/webextensions/test/xpcshell/test_strictcompatibility.js
index cb6704936..cb6704936 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_strictcompatibility.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js b/toolkit/mozapps/webextensions/test/xpcshell/test_switch_os.js
index 552d7cfae..552d7cfae 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_switch_os.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js b/toolkit/mozapps/webextensions/test/xpcshell/test_syncGUID.js
index 385f58405..385f58405 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_syncGUID.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js b/toolkit/mozapps/webextensions/test/xpcshell/test_system_delay_update.js
index 35964c663..35964c663 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_system_delay_update.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js b/toolkit/mozapps/webextensions/test/xpcshell/test_system_reset.js
index 31b7e5783..31b7e5783 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_system_reset.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js b/toolkit/mozapps/webextensions/test/xpcshell/test_system_update.js
index c8e314427..c8e314427 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_system_update.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_targetPlatforms.js b/toolkit/mozapps/webextensions/test/xpcshell/test_targetPlatforms.js
index ef4f2aee5..ef4f2aee5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_targetPlatforms.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_targetPlatforms.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js b/toolkit/mozapps/webextensions/test/xpcshell/test_temporary.js
index ec9e25a0b..ec9e25a0b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_temporary.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_theme.js b/toolkit/mozapps/webextensions/test/xpcshell/test_theme.js
index 84d6f1d0d..84d6f1d0d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_theme.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_theme.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_types.js b/toolkit/mozapps/webextensions/test/xpcshell/test_types.js
index 679f4808c..679f4808c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_types.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_types.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_undothemeuninstall.js b/toolkit/mozapps/webextensions/test/xpcshell/test_undothemeuninstall.js
index 36ca95aec..36ca95aec 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_undothemeuninstall.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_undothemeuninstall.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js b/toolkit/mozapps/webextensions/test/xpcshell/test_undouninstall.js
index 4680a3c4a..4680a3c4a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_undouninstall.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_uninstall.js b/toolkit/mozapps/webextensions/test/xpcshell/test_uninstall.js
index 6b12489f2..6b12489f2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_uninstall.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_uninstall.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update.js b/toolkit/mozapps/webextensions/test/xpcshell/test_update.js
index 4db488ab5..4db488ab5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_update.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js b/toolkit/mozapps/webextensions/test/xpcshell/test_updateCancel.js
index b50fd4a55..b50fd4a55 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_updateCancel.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js b/toolkit/mozapps/webextensions/test/xpcshell/test_update_compatmode.js
index a1d872009..a1d872009 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_update_compatmode.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js b/toolkit/mozapps/webextensions/test/xpcshell/test_update_ignorecompat.js
index e899619d6..e899619d6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_update_ignorecompat.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js b/toolkit/mozapps/webextensions/test/xpcshell/test_update_strictcompat.js
index 2b1f65a9f..2b1f65a9f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_update_strictcompat.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js b/toolkit/mozapps/webextensions/test/xpcshell/test_update_webextensions.js
index ff5d5d321..ff5d5d321 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_update_webextensions.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js b/toolkit/mozapps/webextensions/test/xpcshell/test_updatecheck.js
index e8529bb2c..e8529bb2c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_updatecheck.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js b/toolkit/mozapps/webextensions/test/xpcshell/test_updateid.js
index f7e3e21e5..f7e3e21e5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_updateid.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js b/toolkit/mozapps/webextensions/test/xpcshell/test_upgrade.js
index dc3d9438a..dc3d9438a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_upgrade.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js b/toolkit/mozapps/webextensions/test/xpcshell/test_upgrade_strictcompat.js
index c2203d097..c2203d097 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_upgrade_strictcompat.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension.js
index b51f47977..b51f47977 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_embedded.js b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension_embedded.js
index 3bd8a2bd8..3bd8a2bd8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_embedded.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension_embedded.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension_icons.js
index 25fb4115f..25fb4115f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension_icons.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension_install.js
index 1e7c9d9b7..1e7c9d9b7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension_install.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension_paths.js
index 29a3dacf7..29a3dacf7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_webextension_paths.js
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini b/toolkit/mozapps/webextensions/test/xpcshell/xpcshell-shared.ini
index 1e86e5861..1e86e5861 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
+++ b/toolkit/mozapps/webextensions/test/xpcshell/xpcshell-shared.ini
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini b/toolkit/mozapps/webextensions/test/xpcshell/xpcshell-unpack.ini
index 42a0ca1ca..42a0ca1ca 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini
+++ b/toolkit/mozapps/webextensions/test/xpcshell/xpcshell-unpack.ini
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini b/toolkit/mozapps/webextensions/test/xpcshell/xpcshell.ini
index 2b95eb158..2b95eb158 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/webextensions/test/xpcshell/xpcshell.ini
diff --git a/toolkit/mozapps/extensions/test/xpinstall/.eslintrc.js b/toolkit/mozapps/webextensions/test/xpinstall/.eslintrc.js
index 2852eb81d..2852eb81d 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/.eslintrc.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/.eslintrc.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi b/toolkit/mozapps/webextensions/test/xpinstall/amosigned.xpi
index 4edf91e34..4edf91e34 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/amosigned.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/amosigned2.xpi b/toolkit/mozapps/webextensions/test/xpinstall/amosigned2.xpi
index 74e877f26..74e877f26 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/amosigned2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/amosigned2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/authRedirect.sjs b/toolkit/mozapps/webextensions/test/xpinstall/authRedirect.sjs
index 85d448e2b..85d448e2b 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/authRedirect.sjs
+++ b/toolkit/mozapps/webextensions/test/xpinstall/authRedirect.sjs
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser.ini b/toolkit/mozapps/webextensions/test/xpinstall/browser.ini
index 5627f47a2..5627f47a2 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser.ini
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser.ini
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_trigger.js
index d61ef7362..d61ef7362 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_trigger.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_trigger_iframe.js
index 66564afaa..66564afaa 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_trigger_iframe.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_url.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_url.js
index f6c39b7bb..f6c39b7bb 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_url.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_amosigned_url.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_auth.js
index 1bfa7696f..1bfa7696f 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_auth.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_auth2.js
index 80942a9f4..80942a9f4 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_auth2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_auth3.js
index 4973a1b35..4973a1b35 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_auth3.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_auth4.js
index a3157961d..a3157961d 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_auth4.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_badargs.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_badargs.js
index b4b1110b0..b4b1110b0 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_badargs.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_badargs.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_badargs2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_badargs2.js
index 7137df318..7137df318 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_badargs2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_badargs2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_badhash.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_badhash.js
index 9a26a77e4..9a26a77e4 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_badhash.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_badhash.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_badhashtype.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_badhashtype.js
index a9de9e4f0..a9de9e4f0 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_badhashtype.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_badhashtype.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug540558.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug540558.js
index 4e7e20717..4e7e20717 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug540558.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug540558.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug611242.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug611242.js
index 4f3cd087f..4f3cd087f 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug611242.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug611242.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug638292.js
index 0d96e7cbe..0d96e7cbe 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug638292.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug645699.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug645699.js
index f32d2c9d2..f32d2c9d2 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug645699.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug645699.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug672485.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug672485.js
index 81d89c025..81d89c025 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug672485.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_bug672485.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cancel.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_cancel.js
index e30d7a0e5..e30d7a0e5 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cancel.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_cancel.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_concurrent_installs.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_concurrent_installs.js
index bf919d89c..bf919d89c 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_concurrent_installs.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_concurrent_installs.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_cookies.js
index 541ac8333..541ac8333 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_cookies.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_cookies2.js
index 1ef2b482f..1ef2b482f 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_cookies2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_cookies3.js
index 833562d15..833562d15 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_cookies3.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_cookies4.js
index 792146c64..792146c64 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_cookies4.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_corrupt.js
index bd4d27fb0..bd4d27fb0 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_corrupt.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_datauri.js
index a8bdbde39..a8bdbde39 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_datauri.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_empty.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_empty.js
index 64ca5e6b9..64ca5e6b9 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_empty.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_empty.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_enabled.js
index adbec9499..adbec9499 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_enabled.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_enabled2.js
index cc1b8a8b2..cc1b8a8b2 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_enabled2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled3.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_enabled3.js
index 15bad4ba9..15bad4ba9 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled3.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_enabled3.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_hash.js
index 4c45bd184..4c45bd184 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_hash.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_hash2.js
index 4c8e262c7..4c8e262c7 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_hash2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash.js
index 6a1222797..6a1222797 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash2.js
index 2d930d221..2d930d221 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash3.js
index 5f3ef23ca..5f3ef23ca 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash3.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash4.js
index 3983662af..3983662af 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash4.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash5.js
index 407158e4f..407158e4f 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash5.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash6.js
index 5e1da8175..5e1da8175 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_httphash6.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_installchrome.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_installchrome.js
index 2380a4df2..2380a4df2 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_installchrome.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_installchrome.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_localfile.js
index 997f386a6..997f386a6 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_localfile.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_localfile2.js
index b0e3ffc42..b0e3ffc42 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_localfile2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile3.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_localfile3.js
index 891b85ebc..891b85ebc 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile3.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_localfile3.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile4.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_localfile4.js
index 5203c3153..5203c3153 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile4.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_localfile4.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_multipackage.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_multipackage.js
index d022d713a..d022d713a 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_multipackage.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_multipackage.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway.js
index f092edb8c..f092edb8c 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway2.js
index a41662e1e..a41662e1e 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway3.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway3.js
index 3948d5649..3948d5649 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway3.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway3.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway4.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway4.js
index 61844c5a1..61844c5a1 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_navigateaway4.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_navigateaway4.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_offline.js
index eb4ac391f..eb4ac391f 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_offline.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_relative.js
index 3599f47d1..3599f47d1 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_relative.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_multipackage.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_multipackage.js
index 7341f3082..7341f3082 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_multipackage.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_multipackage.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_multiple.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_multiple.js
index 9dda1aaeb..9dda1aaeb 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_multiple.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_multiple.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_naming.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_naming.js
index 5c3f79045..5c3f79045 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_naming.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_naming.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_tampered.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_tampered.js
index fc798d66a..fc798d66a 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_tampered.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_tampered.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_trigger.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_trigger.js
index 8f1ae2d87..8f1ae2d87 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_trigger.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_trigger.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_untrusted.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_untrusted.js
index d5fa9ae01..d5fa9ae01 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_untrusted.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_untrusted.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_url.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_url.js
index 33cda6e4c..33cda6e4c 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_url.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_signed_url.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_softwareupdate.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_softwareupdate.js
index 16e20f3e9..16e20f3e9 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_softwareupdate.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_softwareupdate.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_switchtab.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_switchtab.js
index 9bbb59400..9bbb59400 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_switchtab.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_switchtab.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_trigger_redirect.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_trigger_redirect.js
index 9c0543602..9c0543602 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_trigger_redirect.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_trigger_redirect.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger.js
index 006879439..006879439 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger_iframe.js
index b9df6615e..b9df6615e 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger_iframe.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_xorigin.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger_xorigin.js
index b0875fc99..b0875fc99 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_xorigin.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_trigger_xorigin.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_url.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_url.js
index e103dffd3..e103dffd3 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_url.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_unsigned_url.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist.js
index ad3d645f5..ad3d645f5 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist2.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist2.js
index fd9e944e8..fd9e944e8 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist2.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist2.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist3.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist3.js
index 6f4306df6..6f4306df6 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist3.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist3.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist4.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist4.js
index e4c47cda5..e4c47cda5 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist4.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist4.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist5.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist5.js
index 0a9333430..0a9333430 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist5.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist5.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist6.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist6.js
index 555f1e2fc..555f1e2fc 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist6.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist6.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist7.js b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist7.js
index 96c60ac9e..96c60ac9e 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist7.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/browser_whitelist7.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/bug540558.html b/toolkit/mozapps/webextensions/test/xpinstall/bug540558.html
index 286046d25..286046d25 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/bug540558.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/bug540558.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/bug638292.html b/toolkit/mozapps/webextensions/test/xpinstall/bug638292.html
index 198207d4b..198207d4b 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/bug638292.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/bug638292.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/bug645699.html b/toolkit/mozapps/webextensions/test/xpinstall/bug645699.html
index 8334c37c2..8334c37c2 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/bug645699.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/bug645699.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/concurrent_installs.html b/toolkit/mozapps/webextensions/test/xpinstall/concurrent_installs.html
index 780409257..780409257 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/concurrent_installs.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/concurrent_installs.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/cookieRedirect.sjs b/toolkit/mozapps/webextensions/test/xpinstall/cookieRedirect.sjs
index 92bccd9ec..92bccd9ec 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/cookieRedirect.sjs
+++ b/toolkit/mozapps/webextensions/test/xpinstall/cookieRedirect.sjs
diff --git a/toolkit/mozapps/extensions/test/xpinstall/corrupt.xpi b/toolkit/mozapps/webextensions/test/xpinstall/corrupt.xpi
index 35d7bd5e5..35d7bd5e5 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/corrupt.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/corrupt.xpi
diff --git a/toolkit/mozapps/extensions/test/xpinstall/empty.xpi b/toolkit/mozapps/webextensions/test/xpinstall/empty.xpi
index 74ed2b817..74ed2b817 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/empty.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/empty.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/enabled.html b/toolkit/mozapps/webextensions/test/xpinstall/enabled.html
index 370cde8fb..370cde8fb 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/enabled.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/enabled.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/hashRedirect.sjs b/toolkit/mozapps/webextensions/test/xpinstall/hashRedirect.sjs
index 324a092a3..324a092a3 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/hashRedirect.sjs
+++ b/toolkit/mozapps/webextensions/test/xpinstall/hashRedirect.sjs
diff --git a/toolkit/mozapps/extensions/test/xpinstall/head.js b/toolkit/mozapps/webextensions/test/xpinstall/head.js
index 197fe3fac..197fe3fac 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/head.js
+++ b/toolkit/mozapps/webextensions/test/xpinstall/head.js
diff --git a/toolkit/mozapps/extensions/test/xpinstall/incompatible.xpi b/toolkit/mozapps/webextensions/test/xpinstall/incompatible.xpi
index 262ed38a7..262ed38a7 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/incompatible.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/incompatible.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/installchrome.html b/toolkit/mozapps/webextensions/test/xpinstall/installchrome.html
index 6abee2ef3..6abee2ef3 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/installchrome.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/installchrome.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/installtrigger.html b/toolkit/mozapps/webextensions/test/xpinstall/installtrigger.html
index 65cab1ef1..65cab1ef1 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/installtrigger.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/installtrigger.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/installtrigger_frame.html b/toolkit/mozapps/webextensions/test/xpinstall/installtrigger_frame.html
index 2b302642e..2b302642e 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/installtrigger_frame.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/installtrigger_frame.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/multipackage.xpi b/toolkit/mozapps/webextensions/test/xpinstall/multipackage.xpi
index d52f28c28..d52f28c28 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/multipackage.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/multipackage.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/navigate.html b/toolkit/mozapps/webextensions/test/xpinstall/navigate.html
index 5a6903eb9..5a6903eb9 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/navigate.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/navigate.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/redirect.sjs b/toolkit/mozapps/webextensions/test/xpinstall/redirect.sjs
index d248bfbc7..d248bfbc7 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/redirect.sjs
+++ b/toolkit/mozapps/webextensions/test/xpinstall/redirect.sjs
diff --git a/toolkit/mozapps/extensions/test/xpinstall/restartless-unsigned.xpi b/toolkit/mozapps/webextensions/test/xpinstall/restartless-unsigned.xpi
index 8e76bd052..8e76bd052 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/restartless-unsigned.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/restartless-unsigned.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/restartless.xpi b/toolkit/mozapps/webextensions/test/xpinstall/restartless.xpi
index 9fee8f60b..9fee8f60b 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/restartless.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/restartless.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/signed-multipackage.xpi b/toolkit/mozapps/webextensions/test/xpinstall/signed-multipackage.xpi
index 11fbe1861..11fbe1861 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/signed-multipackage.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/signed-multipackage.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/signed-no-cn.xpi b/toolkit/mozapps/webextensions/test/xpinstall/signed-no-cn.xpi
index 90d3a3ce6..90d3a3ce6 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/signed-no-cn.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/signed-no-cn.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/signed-no-o.xpi b/toolkit/mozapps/webextensions/test/xpinstall/signed-no-o.xpi
index 19b754038..19b754038 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/signed-no-o.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/signed-no-o.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/signed-tampered.xpi b/toolkit/mozapps/webextensions/test/xpinstall/signed-tampered.xpi
index 8c951881e..8c951881e 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/signed-tampered.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/signed-tampered.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/signed-untrusted.xpi b/toolkit/mozapps/webextensions/test/xpinstall/signed-untrusted.xpi
index 09789d189..09789d189 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/signed-untrusted.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/signed-untrusted.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/signed.xpi b/toolkit/mozapps/webextensions/test/xpinstall/signed.xpi
index bd7f78b7c..bd7f78b7c 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/signed.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/signed.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/signed2.xpi b/toolkit/mozapps/webextensions/test/xpinstall/signed2.xpi
index 085efbbf7..085efbbf7 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/signed2.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/signed2.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/slowinstall.sjs b/toolkit/mozapps/webextensions/test/xpinstall/slowinstall.sjs
index 5f767a8f4..5f767a8f4 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/slowinstall.sjs
+++ b/toolkit/mozapps/webextensions/test/xpinstall/slowinstall.sjs
diff --git a/toolkit/mozapps/extensions/test/xpinstall/startsoftwareupdate.html b/toolkit/mozapps/webextensions/test/xpinstall/startsoftwareupdate.html
index 50083ca90..50083ca90 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/startsoftwareupdate.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/startsoftwareupdate.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/theme.xpi b/toolkit/mozapps/webextensions/test/xpinstall/theme.xpi
index 74e650b4a..74e650b4a 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/theme.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/theme.xpi
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpinstall/triggerredirect.html b/toolkit/mozapps/webextensions/test/xpinstall/triggerredirect.html
index 42e0e1cd0..42e0e1cd0 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/triggerredirect.html
+++ b/toolkit/mozapps/webextensions/test/xpinstall/triggerredirect.html
diff --git a/toolkit/mozapps/extensions/test/xpinstall/unsigned.xpi b/toolkit/mozapps/webextensions/test/xpinstall/unsigned.xpi
index 51b00475a..51b00475a 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/unsigned.xpi
+++ b/toolkit/mozapps/webextensions/test/xpinstall/unsigned.xpi
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/extensions.css b/toolkit/themes/linux/mozapps/extensions/extensions.css
deleted file mode 100644
index a75669937..000000000
--- a/toolkit/themes/linux/mozapps/extensions/extensions.css
+++ /dev/null
@@ -1,42 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-%include ../../../shared/extensions/extensions.inc.css
-
-#header-utils-btn .toolbarbutton-icon {
- list-style-image: url("chrome://mozapps/skin/extensions/utilities.svg#utilities-native");
-}
-
-.sorter[checkState="1"] .button-icon {
- display: -moz-box;
- list-style-image: url("moz-icon://stock/gtk-sort-descending?size=16");
-}
-
-.sorter[checkState="2"] .button-icon {
- display: -moz-box;
- list-style-image: url("moz-icon://stock/gtk-sort-ascending?size=16");
-}
-
-.addon .relnotes-toggle {
- list-style-image: url("moz-icon://stock/gtk-go-down?size=16");
-}
-
-.addon .relnotes-toggle > .button-box > .button-icon {
- display: -moz-box;
-}
-
-.addon[show-relnotes] .relnotes-toggle {
- list-style-image: url("moz-icon://stock/gtk-go-up?size=16");
-}
-
-.meta-rating[showrating="average"] > .star {
- list-style-image: url("chrome://mozapps/skin/extensions/rating-not-won.png");
- padding: 0 1px;
-}
-
-.meta-rating > .star[on="true"],
-.meta-rating[showrating="user"] > .star[hover] {
- list-style-image: url("chrome://mozapps/skin/extensions/rating-won.png");
- padding: 0 1px;
-}
diff --git a/toolkit/themes/linux/mozapps/extensions/newaddon.css b/toolkit/themes/linux/mozapps/extensions/newaddon.css
deleted file mode 100644
index edfba0ef5..000000000
--- a/toolkit/themes/linux/mozapps/extensions/newaddon.css
+++ /dev/null
@@ -1,5 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-%include ../../../shared/extensions/newaddon.inc.css
diff --git a/toolkit/themes/linux/mozapps/jar.mn b/toolkit/themes/linux/mozapps/jar.mn
index 8d1c12305..0965662bd 100644
--- a/toolkit/themes/linux/mozapps/jar.mn
+++ b/toolkit/themes/linux/mozapps/jar.mn
@@ -6,21 +6,23 @@ toolkit.jar:
#include ../../shared/mozapps.inc.mn
skin/classic/mozapps/downloads/downloadIcon.png (downloads/downloadIcon.png)
skin/classic/mozapps/downloads/downloads.css (downloads/downloads.css)
-* skin/classic/mozapps/extensions/extensions.css (extensions/extensions.css)
- skin/classic/mozapps/extensions/category-search.png (extensions/category-search.png)
- skin/classic/mozapps/extensions/category-discover.png (extensions/category-discover.png)
- skin/classic/mozapps/extensions/category-plugins.png (extensions/category-plugins.png)
- skin/classic/mozapps/extensions/category-service.png (extensions/category-service.png)
- skin/classic/mozapps/extensions/category-recent.png (extensions/category-recent.png)
- skin/classic/mozapps/extensions/category-available.png (extensions/category-available.png)
- skin/classic/mozapps/extensions/extensionGeneric-16.png (extensions/extensionGeneric-16.png)
- skin/classic/mozapps/extensions/dictionaryGeneric.png (extensions/dictionaryGeneric.png)
- skin/classic/mozapps/extensions/dictionaryGeneric-16.png (extensions/dictionaryGeneric-16.png)
- skin/classic/mozapps/extensions/themeGeneric.png (extensions/themeGeneric.png)
- skin/classic/mozapps/extensions/themeGeneric-16.png (extensions/themeGeneric-16.png)
- skin/classic/mozapps/extensions/localeGeneric.png (extensions/localeGeneric.png)
-* skin/classic/mozapps/extensions/newaddon.css (extensions/newaddon.css)
- skin/classic/mozapps/extensions/heart.png (extensions/heart.png)
+#ifdef MOZ_WEBEXTENSIONS
+* skin/classic/mozapps/extensions/extensions.css (webextensions/extensions.css)
+ skin/classic/mozapps/extensions/category-search.png (webextensions/category-search.png)
+ skin/classic/mozapps/extensions/category-discover.png (webextensions/category-discover.png)
+ skin/classic/mozapps/extensions/category-plugins.png (webextensions/category-plugins.png)
+ skin/classic/mozapps/extensions/category-service.png (webextensions/category-service.png)
+ skin/classic/mozapps/extensions/category-recent.png (webextensions/category-recent.png)
+ skin/classic/mozapps/extensions/category-available.png (webextensions/category-available.png)
+ skin/classic/mozapps/extensions/extensionGeneric-16.png (webextensions/extensionGeneric-16.png)
+ skin/classic/mozapps/extensions/dictionaryGeneric.png (webextensions/dictionaryGeneric.png)
+ skin/classic/mozapps/extensions/dictionaryGeneric-16.png (webextensions/dictionaryGeneric-16.png)
+ skin/classic/mozapps/extensions/themeGeneric.png (webextensions/themeGeneric.png)
+ skin/classic/mozapps/extensions/themeGeneric-16.png (webextensions/themeGeneric-16.png)
+ skin/classic/mozapps/extensions/localeGeneric.png (webextensions/localeGeneric.png)
+* skin/classic/mozapps/extensions/newaddon.css (webextensions/newaddon.css)
+ skin/classic/mozapps/extensions/heart.png (webextensions/heart.png)
+#endif
skin/classic/mozapps/plugins/pluginGeneric.png (plugins/pluginGeneric.png)
skin/classic/mozapps/plugins/pluginBlocked.png (plugins/pluginBlocked.png)
skin/classic/mozapps/plugins/pluginGeneric-16.png (plugins/pluginGeneric-16.png)
diff --git a/toolkit/themes/linux/mozapps/extensions/category-available.png b/toolkit/themes/linux/mozapps/webextensions/category-available.png
index 689d526c9..689d526c9 100644
--- a/toolkit/themes/linux/mozapps/extensions/category-available.png
+++ b/toolkit/themes/linux/mozapps/webextensions/category-available.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/category-discover.png b/toolkit/themes/linux/mozapps/webextensions/category-discover.png
index ccea27524..ccea27524 100644
--- a/toolkit/themes/linux/mozapps/extensions/category-discover.png
+++ b/toolkit/themes/linux/mozapps/webextensions/category-discover.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/category-plugins.png b/toolkit/themes/linux/mozapps/webextensions/category-plugins.png
index b253dd08f..b253dd08f 100644
--- a/toolkit/themes/linux/mozapps/extensions/category-plugins.png
+++ b/toolkit/themes/linux/mozapps/webextensions/category-plugins.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/category-recent.png b/toolkit/themes/linux/mozapps/webextensions/category-recent.png
index 9039b27aa..9039b27aa 100644
--- a/toolkit/themes/linux/mozapps/extensions/category-recent.png
+++ b/toolkit/themes/linux/mozapps/webextensions/category-recent.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/category-search.png b/toolkit/themes/linux/mozapps/webextensions/category-search.png
index 52e91a7ce..52e91a7ce 100644
--- a/toolkit/themes/linux/mozapps/extensions/category-search.png
+++ b/toolkit/themes/linux/mozapps/webextensions/category-search.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/category-service.png b/toolkit/themes/linux/mozapps/webextensions/category-service.png
index 997c8541c..997c8541c 100644
--- a/toolkit/themes/linux/mozapps/extensions/category-service.png
+++ b/toolkit/themes/linux/mozapps/webextensions/category-service.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/dictionaryGeneric-16.png b/toolkit/themes/linux/mozapps/webextensions/dictionaryGeneric-16.png
index 08a0447a4..08a0447a4 100644
--- a/toolkit/themes/linux/mozapps/extensions/dictionaryGeneric-16.png
+++ b/toolkit/themes/linux/mozapps/webextensions/dictionaryGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/dictionaryGeneric.png b/toolkit/themes/linux/mozapps/webextensions/dictionaryGeneric.png
index a1e0d5359..a1e0d5359 100644
--- a/toolkit/themes/linux/mozapps/extensions/dictionaryGeneric.png
+++ b/toolkit/themes/linux/mozapps/webextensions/dictionaryGeneric.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/extensionGeneric-16.png b/toolkit/themes/linux/mozapps/webextensions/extensionGeneric-16.png
index b1a2f3652..b1a2f3652 100644
--- a/toolkit/themes/linux/mozapps/extensions/extensionGeneric-16.png
+++ b/toolkit/themes/linux/mozapps/webextensions/extensionGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/webextensions/extensions.css b/toolkit/themes/linux/mozapps/webextensions/extensions.css
new file mode 100644
index 000000000..5a11df119
--- /dev/null
+++ b/toolkit/themes/linux/mozapps/webextensions/extensions.css
@@ -0,0 +1,42 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+%include ../../../shared/webextensions/extensions.inc.css
+
+#header-utils-btn .toolbarbutton-icon {
+ list-style-image: url("chrome://mozapps/skin/extensions/utilities.svg#utilities-native");
+}
+
+.sorter[checkState="1"] .button-icon {
+ display: -moz-box;
+ list-style-image: url("moz-icon://stock/gtk-sort-descending?size=16");
+}
+
+.sorter[checkState="2"] .button-icon {
+ display: -moz-box;
+ list-style-image: url("moz-icon://stock/gtk-sort-ascending?size=16");
+}
+
+.addon .relnotes-toggle {
+ list-style-image: url("moz-icon://stock/gtk-go-down?size=16");
+}
+
+.addon .relnotes-toggle > .button-box > .button-icon {
+ display: -moz-box;
+}
+
+.addon[show-relnotes] .relnotes-toggle {
+ list-style-image: url("moz-icon://stock/gtk-go-up?size=16");
+}
+
+.meta-rating[showrating="average"] > .star {
+ list-style-image: url("chrome://mozapps/skin/extensions/rating-not-won.png");
+ padding: 0 1px;
+}
+
+.meta-rating > .star[on="true"],
+.meta-rating[showrating="user"] > .star[hover] {
+ list-style-image: url("chrome://mozapps/skin/extensions/rating-won.png");
+ padding: 0 1px;
+}
diff --git a/toolkit/themes/linux/mozapps/extensions/heart.png b/toolkit/themes/linux/mozapps/webextensions/heart.png
index 655f4c4be..655f4c4be 100644
--- a/toolkit/themes/linux/mozapps/extensions/heart.png
+++ b/toolkit/themes/linux/mozapps/webextensions/heart.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/localeGeneric.png b/toolkit/themes/linux/mozapps/webextensions/localeGeneric.png
index c72115906..c72115906 100644
--- a/toolkit/themes/linux/mozapps/extensions/localeGeneric.png
+++ b/toolkit/themes/linux/mozapps/webextensions/localeGeneric.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/webextensions/newaddon.css b/toolkit/themes/linux/mozapps/webextensions/newaddon.css
new file mode 100644
index 000000000..5856c08b5
--- /dev/null
+++ b/toolkit/themes/linux/mozapps/webextensions/newaddon.css
@@ -0,0 +1,5 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+%include ../../../shared/webextensions/newaddon.inc.css
diff --git a/toolkit/themes/linux/mozapps/extensions/themeGeneric-16.png b/toolkit/themes/linux/mozapps/webextensions/themeGeneric-16.png
index 019886fea..019886fea 100644
--- a/toolkit/themes/linux/mozapps/extensions/themeGeneric-16.png
+++ b/toolkit/themes/linux/mozapps/webextensions/themeGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/linux/mozapps/extensions/themeGeneric.png b/toolkit/themes/linux/mozapps/webextensions/themeGeneric.png
index cde1c7834..cde1c7834 100644
--- a/toolkit/themes/linux/mozapps/extensions/themeGeneric.png
+++ b/toolkit/themes/linux/mozapps/webextensions/themeGeneric.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/extensions.css b/toolkit/themes/osx/mozapps/extensions/extensions.css
deleted file mode 100644
index d4dac2f01..000000000
--- a/toolkit/themes/osx/mozapps/extensions/extensions.css
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-%include ../../../shared/extensions/extensions.inc.css
-
-.no-auto-hide > .menulist-dropmarker {
- padding-inline-start: 0px !important;
-}
-
-#header-utils-btn {
- list-style-image: url("chrome://mozapps/skin/extensions/utilities.svg#utilities");
- margin-inline-end: 18px;
-}
-
-#header-utils-btn > .toolbarbutton-menu-dropmarker {
- list-style-image: url("chrome://mozapps/skin/extensions/toolbarbutton-dropmarker.png");
- padding: 0;
- margin-inline-start: 2px;
-}
-
-.sorter[checkState="1"] {
- list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
-}
-
-.sorter[checkState="2"] {
- list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
-}
-
-.addon .relnotes-toggle {
- -moz-box-direction: reverse;
- list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
-}
-
-.addon[show-relnotes] .relnotes-toggle {
- list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
-}
-
-.download-progress {
- margin-top: 3px;
- margin-bottom: 3px;
-}
-
-.meta-rating > .star {
- list-style-image: url("chrome://mozapps/skin/extensions/rating-not-won.png");
- padding: 0 1px;
-}
-
-.meta-rating > .star[on="true"] {
- list-style-image: url("chrome://mozapps/skin/extensions/rating-won.png");
-}
diff --git a/toolkit/themes/osx/mozapps/extensions/newaddon.css b/toolkit/themes/osx/mozapps/extensions/newaddon.css
deleted file mode 100644
index edfba0ef5..000000000
--- a/toolkit/themes/osx/mozapps/extensions/newaddon.css
+++ /dev/null
@@ -1,5 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-%include ../../../shared/extensions/newaddon.inc.css
diff --git a/toolkit/themes/osx/mozapps/jar.mn b/toolkit/themes/osx/mozapps/jar.mn
index 3f5717073..8da83da16 100644
--- a/toolkit/themes/osx/mozapps/jar.mn
+++ b/toolkit/themes/osx/mozapps/jar.mn
@@ -8,34 +8,36 @@ toolkit.jar:
skin/classic/mozapps/downloads/downloadIcon.png (downloads/downloadIcon.png)
* skin/classic/mozapps/downloads/downloads.css (downloads/downloads.css)
skin/classic/mozapps/downloads/unknownContentType.css (downloads/unknownContentType.css)
- skin/classic/mozapps/extensions/category-search.png (extensions/category-search.png)
- skin/classic/mozapps/extensions/category-discover.png (extensions/category-discover.png)
- skin/classic/mozapps/extensions/category-plugins.png (extensions/category-plugins.png)
- skin/classic/mozapps/extensions/category-service.png (extensions/category-service.png)
- skin/classic/mozapps/extensions/category-dictionaries.png (extensions/category-dictionaries.png)
- skin/classic/mozapps/extensions/category-experiments.png (extensions/category-experiments.png)
- skin/classic/mozapps/extensions/category-recent.png (extensions/category-recent.png)
- skin/classic/mozapps/extensions/category-available.png (extensions/category-available.png)
- skin/classic/mozapps/extensions/discover-logo.png (extensions/discover-logo.png)
- skin/classic/mozapps/extensions/extensionGeneric-16.png (extensions/extensionGeneric-16.png)
- skin/classic/mozapps/extensions/themeGeneric.png (extensions/themeGeneric.png)
- skin/classic/mozapps/extensions/themeGeneric-16.png (extensions/themeGeneric-16.png)
- skin/classic/mozapps/extensions/dictionaryGeneric.png (extensions/dictionaryGeneric.png)
- skin/classic/mozapps/extensions/dictionaryGeneric-16.png (extensions/dictionaryGeneric-16.png)
- skin/classic/mozapps/extensions/experimentGeneric.png (extensions/experimentGeneric.png)
- skin/classic/mozapps/extensions/localeGeneric.png (extensions/localeGeneric.png)
- skin/classic/mozapps/extensions/rating-won.png (extensions/rating-won.png)
- skin/classic/mozapps/extensions/rating-not-won.png (extensions/rating-not-won.png)
- skin/classic/mozapps/extensions/cancel.png (extensions/cancel.png)
- skin/classic/mozapps/extensions/toolbarbutton-dropmarker.png (extensions/toolbarbutton-dropmarker.png)
- skin/classic/mozapps/extensions/heart.png (extensions/heart.png)
- skin/classic/mozapps/extensions/search.png (extensions/search.png)
- skin/classic/mozapps/extensions/about.css (extensions/about.css)
-* skin/classic/mozapps/extensions/extensions.css (extensions/extensions.css)
- skin/classic/mozapps/extensions/update.css (extensions/update.css)
- skin/classic/mozapps/extensions/eula.css (extensions/eula.css)
- skin/classic/mozapps/extensions/blocklist.css (extensions/blocklist.css)
-* skin/classic/mozapps/extensions/newaddon.css (extensions/newaddon.css)
+#ifdef MOZ_WEBEXTENSIONS
+ skin/classic/mozapps/extensions/category-search.png (webextensions/category-search.png)
+ skin/classic/mozapps/extensions/category-discover.png (webextensions/category-discover.png)
+ skin/classic/mozapps/extensions/category-plugins.png (webextensions/category-plugins.png)
+ skin/classic/mozapps/extensions/category-service.png (webextensions/category-service.png)
+ skin/classic/mozapps/extensions/category-dictionaries.png (webextensions/category-dictionaries.png)
+ skin/classic/mozapps/extensions/category-experiments.png (webextensions/category-experiments.png)
+ skin/classic/mozapps/extensions/category-recent.png (webextensions/category-recent.png)
+ skin/classic/mozapps/extensions/category-available.png (webextensions/category-available.png)
+ skin/classic/mozapps/extensions/discover-logo.png (webextensions/discover-logo.png)
+ skin/classic/mozapps/extensions/extensionGeneric-16.png (webextensions/extensionGeneric-16.png)
+ skin/classic/mozapps/extensions/themeGeneric.png (webextensions/themeGeneric.png)
+ skin/classic/mozapps/extensions/themeGeneric-16.png (webextensions/themeGeneric-16.png)
+ skin/classic/mozapps/extensions/dictionaryGeneric.png (webextensions/dictionaryGeneric.png)
+ skin/classic/mozapps/extensions/dictionaryGeneric-16.png (webextensions/dictionaryGeneric-16.png)
+ skin/classic/mozapps/extensions/experimentGeneric.png (webextensions/experimentGeneric.png)
+ skin/classic/mozapps/extensions/localeGeneric.png (webextensions/localeGeneric.png)
+ skin/classic/mozapps/extensions/rating-won.png (webextensions/rating-won.png)
+ skin/classic/mozapps/extensions/rating-not-won.png (webextensions/rating-not-won.png)
+ skin/classic/mozapps/extensions/cancel.png (webextensions/cancel.png)
+ skin/classic/mozapps/extensions/toolbarbutton-dropmarker.png (webextensions/toolbarbutton-dropmarker.png)
+ skin/classic/mozapps/extensions/heart.png (webextensions/heart.png)
+ skin/classic/mozapps/extensions/search.png (webextensions/search.png)
+ skin/classic/mozapps/extensions/about.css (webextensions/about.css)
+* skin/classic/mozapps/extensions/extensions.css (webextensions/extensions.css)
+ skin/classic/mozapps/extensions/update.css (webextensions/update.css)
+ skin/classic/mozapps/extensions/eula.css (webextensions/eula.css)
+ skin/classic/mozapps/extensions/blocklist.css (webextensions/blocklist.css)
+* skin/classic/mozapps/extensions/newaddon.css (webextensions/newaddon.css)
+#endif
skin/classic/mozapps/plugins/notifyPluginGeneric.png (plugins/notifyPluginGeneric.png)
skin/classic/mozapps/plugins/pluginGeneric.png (plugins/pluginGeneric.png)
skin/classic/mozapps/plugins/pluginBlocked.png (plugins/pluginBlocked.png)
@@ -48,7 +50,9 @@ toolkit.jar:
skin/classic/mozapps/update/buttons.png (update/buttons.png)
* skin/classic/mozapps/update/updates.css (update/updates.css)
skin/classic/mozapps/viewsource/viewsource.css (viewsource/viewsource.css)
- skin/classic/mozapps/xpinstall/xpinstallConfirm.css (extensions/xpinstallConfirm.css)
+#ifdef MOZ_WEBEXTENSIONS
+ skin/classic/mozapps/xpinstall/xpinstallConfirm.css (webextensions/xpinstallConfirm.css)
+#endif
skin/classic/mozapps/handling/handling.css (handling/handling.css)
#ifdef MOZ_PHOENIX
@@ -56,7 +60,9 @@ toolkit.jar:
#elif MOZ_SEPARATE_MANIFEST_FOR_THEME_OVERRIDES
[extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
#endif
+#ifdef MOZ_WEBEXTENSIONS
% override chrome://mozapps/skin/extensions/category-extensions.svg chrome://mozapps/skin/extensions/extensionGeneric.svg
% override chrome://mozapps/skin/extensions/category-languages.png chrome://mozapps/skin/extensions/localeGeneric.png
% override chrome://mozapps/skin/extensions/category-themes.png chrome://mozapps/skin/extensions/themeGeneric.png
+#endif
% override chrome://mozapps/skin/plugins/notifyPluginCrashed.png chrome://mozapps/skin/plugins/notifyPluginGeneric.png
diff --git a/toolkit/themes/osx/mozapps/extensions/about.css b/toolkit/themes/osx/mozapps/webextensions/about.css
index c13ce5f59..c13ce5f59 100644
--- a/toolkit/themes/osx/mozapps/extensions/about.css
+++ b/toolkit/themes/osx/mozapps/webextensions/about.css
diff --git a/toolkit/themes/osx/mozapps/extensions/blocklist.css b/toolkit/themes/osx/mozapps/webextensions/blocklist.css
index 02f6e1d49..02f6e1d49 100644
--- a/toolkit/themes/osx/mozapps/extensions/blocklist.css
+++ b/toolkit/themes/osx/mozapps/webextensions/blocklist.css
diff --git a/toolkit/themes/osx/mozapps/extensions/cancel.png b/toolkit/themes/osx/mozapps/webextensions/cancel.png
index 0d98ab235..0d98ab235 100644
--- a/toolkit/themes/osx/mozapps/extensions/cancel.png
+++ b/toolkit/themes/osx/mozapps/webextensions/cancel.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/category-available.png b/toolkit/themes/osx/mozapps/webextensions/category-available.png
index d1b737ab0..d1b737ab0 100644
--- a/toolkit/themes/osx/mozapps/extensions/category-available.png
+++ b/toolkit/themes/osx/mozapps/webextensions/category-available.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/category-dictionaries.png b/toolkit/themes/osx/mozapps/webextensions/category-dictionaries.png
index 54ae4f93f..54ae4f93f 100644
--- a/toolkit/themes/osx/mozapps/extensions/category-dictionaries.png
+++ b/toolkit/themes/osx/mozapps/webextensions/category-dictionaries.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/category-discover.png b/toolkit/themes/osx/mozapps/webextensions/category-discover.png
index a6f5b49b3..a6f5b49b3 100644
--- a/toolkit/themes/osx/mozapps/extensions/category-discover.png
+++ b/toolkit/themes/osx/mozapps/webextensions/category-discover.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/category-experiments.png b/toolkit/themes/osx/mozapps/webextensions/category-experiments.png
index a9d00545e..a9d00545e 100644
--- a/toolkit/themes/osx/mozapps/extensions/category-experiments.png
+++ b/toolkit/themes/osx/mozapps/webextensions/category-experiments.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/category-plugins.png b/toolkit/themes/osx/mozapps/webextensions/category-plugins.png
index 5c4d8bf47..5c4d8bf47 100644
--- a/toolkit/themes/osx/mozapps/extensions/category-plugins.png
+++ b/toolkit/themes/osx/mozapps/webextensions/category-plugins.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/category-recent.png b/toolkit/themes/osx/mozapps/webextensions/category-recent.png
index 7ecfc7d4c..7ecfc7d4c 100644
--- a/toolkit/themes/osx/mozapps/extensions/category-recent.png
+++ b/toolkit/themes/osx/mozapps/webextensions/category-recent.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/category-search.png b/toolkit/themes/osx/mozapps/webextensions/category-search.png
index 52e91a7ce..52e91a7ce 100644
--- a/toolkit/themes/osx/mozapps/extensions/category-search.png
+++ b/toolkit/themes/osx/mozapps/webextensions/category-search.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/category-service.png b/toolkit/themes/osx/mozapps/webextensions/category-service.png
index 997c8541c..997c8541c 100644
--- a/toolkit/themes/osx/mozapps/extensions/category-service.png
+++ b/toolkit/themes/osx/mozapps/webextensions/category-service.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/dictionaryGeneric-16.png b/toolkit/themes/osx/mozapps/webextensions/dictionaryGeneric-16.png
index 4ad1a1a82..4ad1a1a82 100644
--- a/toolkit/themes/osx/mozapps/extensions/dictionaryGeneric-16.png
+++ b/toolkit/themes/osx/mozapps/webextensions/dictionaryGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/dictionaryGeneric.png b/toolkit/themes/osx/mozapps/webextensions/dictionaryGeneric.png
index 54ae4f93f..54ae4f93f 100644
--- a/toolkit/themes/osx/mozapps/extensions/dictionaryGeneric.png
+++ b/toolkit/themes/osx/mozapps/webextensions/dictionaryGeneric.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/discover-logo.png b/toolkit/themes/osx/mozapps/webextensions/discover-logo.png
index cd50735a8..cd50735a8 100644
--- a/toolkit/themes/osx/mozapps/extensions/discover-logo.png
+++ b/toolkit/themes/osx/mozapps/webextensions/discover-logo.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/eula.css b/toolkit/themes/osx/mozapps/webextensions/eula.css
index 05aeb3c1c..05aeb3c1c 100644
--- a/toolkit/themes/osx/mozapps/extensions/eula.css
+++ b/toolkit/themes/osx/mozapps/webextensions/eula.css
diff --git a/toolkit/themes/osx/mozapps/extensions/experimentGeneric.png b/toolkit/themes/osx/mozapps/webextensions/experimentGeneric.png
index a9d00545e..a9d00545e 100644
--- a/toolkit/themes/osx/mozapps/extensions/experimentGeneric.png
+++ b/toolkit/themes/osx/mozapps/webextensions/experimentGeneric.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/extensionGeneric-16.png b/toolkit/themes/osx/mozapps/webextensions/extensionGeneric-16.png
index fc6c8a258..fc6c8a258 100644
--- a/toolkit/themes/osx/mozapps/extensions/extensionGeneric-16.png
+++ b/toolkit/themes/osx/mozapps/webextensions/extensionGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/webextensions/extensions.css b/toolkit/themes/osx/mozapps/webextensions/extensions.css
new file mode 100644
index 000000000..cbdd9a5b0
--- /dev/null
+++ b/toolkit/themes/osx/mozapps/webextensions/extensions.css
@@ -0,0 +1,51 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+%include ../../../shared/webextensions/extensions.inc.css
+
+.no-auto-hide > .menulist-dropmarker {
+ padding-inline-start: 0px !important;
+}
+
+#header-utils-btn {
+ list-style-image: url("chrome://mozapps/skin/extensions/utilities.svg#utilities");
+ margin-inline-end: 18px;
+}
+
+#header-utils-btn > .toolbarbutton-menu-dropmarker {
+ list-style-image: url("chrome://mozapps/skin/extensions/toolbarbutton-dropmarker.png");
+ padding: 0;
+ margin-inline-start: 2px;
+}
+
+.sorter[checkState="1"] {
+ list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
+}
+
+.sorter[checkState="2"] {
+ list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
+}
+
+.addon .relnotes-toggle {
+ -moz-box-direction: reverse;
+ list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
+}
+
+.addon[show-relnotes] .relnotes-toggle {
+ list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
+}
+
+.download-progress {
+ margin-top: 3px;
+ margin-bottom: 3px;
+}
+
+.meta-rating > .star {
+ list-style-image: url("chrome://mozapps/skin/extensions/rating-not-won.png");
+ padding: 0 1px;
+}
+
+.meta-rating > .star[on="true"] {
+ list-style-image: url("chrome://mozapps/skin/extensions/rating-won.png");
+}
diff --git a/toolkit/themes/osx/mozapps/extensions/heart.png b/toolkit/themes/osx/mozapps/webextensions/heart.png
index 655f4c4be..655f4c4be 100644
--- a/toolkit/themes/osx/mozapps/extensions/heart.png
+++ b/toolkit/themes/osx/mozapps/webextensions/heart.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/localeGeneric.png b/toolkit/themes/osx/mozapps/webextensions/localeGeneric.png
index 4d9ac5ad8..4d9ac5ad8 100644
--- a/toolkit/themes/osx/mozapps/extensions/localeGeneric.png
+++ b/toolkit/themes/osx/mozapps/webextensions/localeGeneric.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/webextensions/newaddon.css b/toolkit/themes/osx/mozapps/webextensions/newaddon.css
new file mode 100644
index 000000000..5856c08b5
--- /dev/null
+++ b/toolkit/themes/osx/mozapps/webextensions/newaddon.css
@@ -0,0 +1,5 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+%include ../../../shared/webextensions/newaddon.inc.css
diff --git a/toolkit/themes/osx/mozapps/extensions/rating-not-won.png b/toolkit/themes/osx/mozapps/webextensions/rating-not-won.png
index 2761f1925..2761f1925 100644
--- a/toolkit/themes/osx/mozapps/extensions/rating-not-won.png
+++ b/toolkit/themes/osx/mozapps/webextensions/rating-not-won.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/rating-won.png b/toolkit/themes/osx/mozapps/webextensions/rating-won.png
index 336dd8f6e..336dd8f6e 100644
--- a/toolkit/themes/osx/mozapps/extensions/rating-won.png
+++ b/toolkit/themes/osx/mozapps/webextensions/rating-won.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/search.png b/toolkit/themes/osx/mozapps/webextensions/search.png
index 93196dbbf..93196dbbf 100644
--- a/toolkit/themes/osx/mozapps/extensions/search.png
+++ b/toolkit/themes/osx/mozapps/webextensions/search.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/themeGeneric-16.png b/toolkit/themes/osx/mozapps/webextensions/themeGeneric-16.png
index 190bb30d7..190bb30d7 100644
--- a/toolkit/themes/osx/mozapps/extensions/themeGeneric-16.png
+++ b/toolkit/themes/osx/mozapps/webextensions/themeGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/themeGeneric.png b/toolkit/themes/osx/mozapps/webextensions/themeGeneric.png
index be645f76d..be645f76d 100644
--- a/toolkit/themes/osx/mozapps/extensions/themeGeneric.png
+++ b/toolkit/themes/osx/mozapps/webextensions/themeGeneric.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/toolbarbutton-dropmarker.png b/toolkit/themes/osx/mozapps/webextensions/toolbarbutton-dropmarker.png
index e7674c62a..e7674c62a 100644
--- a/toolkit/themes/osx/mozapps/extensions/toolbarbutton-dropmarker.png
+++ b/toolkit/themes/osx/mozapps/webextensions/toolbarbutton-dropmarker.png
Binary files differ
diff --git a/toolkit/themes/osx/mozapps/extensions/update.css b/toolkit/themes/osx/mozapps/webextensions/update.css
index a0a016868..a0a016868 100644
--- a/toolkit/themes/osx/mozapps/extensions/update.css
+++ b/toolkit/themes/osx/mozapps/webextensions/update.css
diff --git a/toolkit/themes/osx/mozapps/extensions/xpinstallConfirm.css b/toolkit/themes/osx/mozapps/webextensions/xpinstallConfirm.css
index 48af7c1a9..48af7c1a9 100644
--- a/toolkit/themes/osx/mozapps/extensions/xpinstallConfirm.css
+++ b/toolkit/themes/osx/mozapps/webextensions/xpinstallConfirm.css
diff --git a/toolkit/themes/shared/mozapps.inc.mn b/toolkit/themes/shared/mozapps.inc.mn
index bb43fd4d2..fadd203b0 100644
--- a/toolkit/themes/shared/mozapps.inc.mn
+++ b/toolkit/themes/shared/mozapps.inc.mn
@@ -7,13 +7,15 @@
# be specified once. As a result, the source file paths are relative
# to the location of the actual manifest.
- skin/classic/mozapps/extensions/extensionGeneric.svg (../../shared/extensions/extensionGeneric.svg)
- skin/classic/mozapps/extensions/utilities.svg (../../shared/extensions/utilities.svg)
- skin/classic/mozapps/extensions/navigation.png (../../shared/extensions/navigation.png)
- skin/classic/mozapps/extensions/alerticon-warning.svg (../../shared/extensions/alerticon-warning.svg)
- skin/classic/mozapps/extensions/alerticon-error.svg (../../shared/extensions/alerticon-error.svg)
- skin/classic/mozapps/extensions/alerticon-info-positive.svg (../../shared/extensions/alerticon-info-positive.svg)
- skin/classic/mozapps/extensions/alerticon-info-negative.svg (../../shared/extensions/alerticon-info-negative.svg)
+#ifdef MOZ_WEBEXTENSIONS
+ skin/classic/mozapps/extensions/extensionGeneric.svg (../../shared/webextensions/extensionGeneric.svg)
+ skin/classic/mozapps/extensions/utilities.svg (../../shared/webextensions/utilities.svg)
+ skin/classic/mozapps/extensions/navigation.png (../../shared/webextensions/navigation.png)
+ skin/classic/mozapps/extensions/alerticon-warning.svg (../../shared/webextensions/alerticon-warning.svg)
+ skin/classic/mozapps/extensions/alerticon-error.svg (../../shared/webextensions/alerticon-error.svg)
+ skin/classic/mozapps/extensions/alerticon-info-positive.svg (../../shared/webextensions/alerticon-info-positive.svg)
+ skin/classic/mozapps/extensions/alerticon-info-negative.svg (../../shared/webextensions/alerticon-info-negative.svg)
+#endif
skin/classic/mozapps/formautofill/requestAutocomplete.css (../../shared/formautofill/requestAutocomplete.css)
skin/classic/mozapps/plugins/pluginProblem.css (../../shared/plugins/pluginProblem.css)
skin/classic/mozapps/aboutNetworking.css (../../shared/aboutNetworking.css)
diff --git a/toolkit/themes/shared/non-mac.jar.inc.mn b/toolkit/themes/shared/non-mac.jar.inc.mn
index 859f1ba4a..a783bbb3c 100644
--- a/toolkit/themes/shared/non-mac.jar.inc.mn
+++ b/toolkit/themes/shared/non-mac.jar.inc.mn
@@ -107,27 +107,32 @@
skin/classic/mozapps/downloads/downloadButtons.png (../../windows/mozapps/downloads/downloadButtons.png)
skin/classic/mozapps/downloads/unknownContentType.css (../../windows/mozapps/downloads/unknownContentType.css)
- skin/classic/mozapps/extensions/about.css (../../windows/mozapps/extensions/about.css)
- skin/classic/mozapps/extensions/blocklist.css (../../windows/mozapps/extensions/blocklist.css)
- skin/classic/mozapps/extensions/update.css (../../windows/mozapps/extensions/update.css)
- skin/classic/mozapps/extensions/discover-logo.png (../../windows/mozapps/extensions/discover-logo.png)
- skin/classic/mozapps/extensions/experimentGeneric.png (../../windows/mozapps/extensions/experimentGeneric.png)
- skin/classic/mozapps/extensions/rating-won.png (../../windows/mozapps/extensions/rating-won.png)
- skin/classic/mozapps/extensions/rating-not-won.png (../../windows/mozapps/extensions/rating-not-won.png)
- skin/classic/mozapps/extensions/cancel.png (../../windows/mozapps/extensions/cancel.png)
- skin/classic/mozapps/extensions/eula.css (../../windows/mozapps/extensions/eula.css)
+#ifdef MOZ_WEBEXTENSIONS
+ skin/classic/mozapps/extensions/about.css (../../windows/mozapps/webextensions/about.css)
+ skin/classic/mozapps/extensions/blocklist.css (../../windows/mozapps/webextensions/blocklist.css)
+ skin/classic/mozapps/extensions/update.css (../../windows/mozapps/webextensions/update.css)
+ skin/classic/mozapps/extensions/discover-logo.png (../../windows/mozapps/webextensions/discover-logo.png)
+ skin/classic/mozapps/extensions/experimentGeneric.png (../../windows/mozapps/webextensions/experimentGeneric.png)
+ skin/classic/mozapps/extensions/rating-won.png (../../windows/mozapps/webextensions/rating-won.png)
+ skin/classic/mozapps/extensions/rating-not-won.png (../../windows/mozapps/webextensions/rating-not-won.png)
+ skin/classic/mozapps/extensions/cancel.png (../../windows/mozapps/webextensions/cancel.png)
+ skin/classic/mozapps/extensions/eula.css (../../windows/mozapps/webextensions/eula.css)
+#endif
skin/classic/mozapps/handling/handling.css (../../windows/mozapps/handling/handling.css)
skin/classic/mozapps/plugins/pluginBlocked-64.png (../../windows/mozapps/plugins/pluginBlocked-64.png)
skin/classic/mozapps/plugins/pluginHelp-16.png (../../windows/mozapps/plugins/pluginHelp-16.png)
skin/classic/mozapps/profile/profileSelection.css (../../windows/mozapps/profile/profileSelection.css)
skin/classic/mozapps/update/downloadButtons.png (../../windows/mozapps/update/downloadButtons.png)
-* skin/classic/mozapps/xpinstall/xpinstallConfirm.css (../../windows/mozapps/extensions/xpinstallConfirm.css)
+#ifdef MOZ_WEBEXTENSIONS
+* skin/classic/mozapps/xpinstall/xpinstallConfirm.css (../../windows/mozapps/webextensions/xpinstallConfirm.css)
+#endif
#ifdef MOZ_PHOENIX
[browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
#elif MOZ_SEPARATE_MANIFEST_FOR_THEME_OVERRIDES
[extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
#endif
+#ifdef MOZ_WEBEXTENSIONS
% override chrome://global/skin/arrow/arrow-lft-hov.gif chrome://global/skin/arrow/arrow-lft.gif
% override chrome://global/skin/arrow/arrow-rit-hov.gif chrome://global/skin/arrow/arrow-rit.gif
% override chrome://mozapps/skin/extensions/category-dictionaries.png chrome://mozapps/skin/extensions/dictionaryGeneric.png
@@ -138,4 +143,4 @@
% override chrome://mozapps/skin/plugins/notifyPluginCrashed.png chrome://mozapps/skin/plugins/pluginGeneric-16.png
% override chrome://mozapps/skin/plugins/notifyPluginGeneric.png chrome://mozapps/skin/plugins/pluginGeneric-16.png
% override chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png chrome://mozapps/skin/extensions/extensionGeneric.png
-
+#endif
diff --git a/toolkit/themes/shared/extensions/alerticon-error.svg b/toolkit/themes/shared/webextensions/alerticon-error.svg
index cb883e16e..cb883e16e 100644
--- a/toolkit/themes/shared/extensions/alerticon-error.svg
+++ b/toolkit/themes/shared/webextensions/alerticon-error.svg
diff --git a/toolkit/themes/shared/extensions/alerticon-info-negative.svg b/toolkit/themes/shared/webextensions/alerticon-info-negative.svg
index 733f8571a..733f8571a 100644
--- a/toolkit/themes/shared/extensions/alerticon-info-negative.svg
+++ b/toolkit/themes/shared/webextensions/alerticon-info-negative.svg
diff --git a/toolkit/themes/shared/extensions/alerticon-info-positive.svg b/toolkit/themes/shared/webextensions/alerticon-info-positive.svg
index 031190bce..031190bce 100644
--- a/toolkit/themes/shared/extensions/alerticon-info-positive.svg
+++ b/toolkit/themes/shared/webextensions/alerticon-info-positive.svg
diff --git a/toolkit/themes/shared/extensions/alerticon-warning.svg b/toolkit/themes/shared/webextensions/alerticon-warning.svg
index 2b403220e..2b403220e 100644
--- a/toolkit/themes/shared/extensions/alerticon-warning.svg
+++ b/toolkit/themes/shared/webextensions/alerticon-warning.svg
diff --git a/toolkit/themes/shared/extensions/extensionGeneric.svg b/toolkit/themes/shared/webextensions/extensionGeneric.svg
index 28c2f7ba3..28c2f7ba3 100644
--- a/toolkit/themes/shared/extensions/extensionGeneric.svg
+++ b/toolkit/themes/shared/webextensions/extensionGeneric.svg
diff --git a/toolkit/themes/shared/extensions/extensions.inc.css b/toolkit/themes/shared/webextensions/extensions.inc.css
index c4523bbe6..c4523bbe6 100644
--- a/toolkit/themes/shared/extensions/extensions.inc.css
+++ b/toolkit/themes/shared/webextensions/extensions.inc.css
diff --git a/toolkit/themes/shared/extensions/navigation.png b/toolkit/themes/shared/webextensions/navigation.png
index 67ff3d9a7..67ff3d9a7 100644
--- a/toolkit/themes/shared/extensions/navigation.png
+++ b/toolkit/themes/shared/webextensions/navigation.png
Binary files differ
diff --git a/toolkit/themes/shared/extensions/newaddon.inc.css b/toolkit/themes/shared/webextensions/newaddon.inc.css
index 52352ccd2..52352ccd2 100644
--- a/toolkit/themes/shared/extensions/newaddon.inc.css
+++ b/toolkit/themes/shared/webextensions/newaddon.inc.css
diff --git a/toolkit/themes/shared/extensions/utilities.svg b/toolkit/themes/shared/webextensions/utilities.svg
index 8bf24458c..8bf24458c 100644
--- a/toolkit/themes/shared/extensions/utilities.svg
+++ b/toolkit/themes/shared/webextensions/utilities.svg
diff --git a/toolkit/themes/windows/mozapps/extensions/extensions.css b/toolkit/themes/windows/mozapps/extensions/extensions.css
deleted file mode 100644
index 335a31bde..000000000
--- a/toolkit/themes/windows/mozapps/extensions/extensions.css
+++ /dev/null
@@ -1,42 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-%include ../../../shared/extensions/extensions.inc.css
-
-#header-utils-btn {
- list-style-image: url("chrome://mozapps/skin/extensions/utilities.svg#utilities");
- margin-inline-end: 16px;
-}
-
-@media not all and (-moz-windows-default-theme) {
- #header-utils-btn {
- list-style-image: url("chrome://mozapps/skin/extensions/utilities.svg#utilities-native");
- }
-}
-
-.sorter[checkState="1"] {
- list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
-}
-
-.sorter[checkState="2"] {
- list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
-}
-
-.addon .relnotes-toggle {
- -moz-box-direction: reverse;
- list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
-}
-
-.addon[show-relnotes] .relnotes-toggle {
- list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
-}
-
-.meta-rating > .star {
- list-style-image: url("chrome://mozapps/skin/extensions/rating-not-won.png");
- padding: 0 1px;
-}
-
-.meta-rating > .star[on="true"] {
- list-style-image: url("chrome://mozapps/skin/extensions/rating-won.png");
-}
diff --git a/toolkit/themes/windows/mozapps/extensions/newaddon.css b/toolkit/themes/windows/mozapps/extensions/newaddon.css
deleted file mode 100644
index edfba0ef5..000000000
--- a/toolkit/themes/windows/mozapps/extensions/newaddon.css
+++ /dev/null
@@ -1,5 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-%include ../../../shared/extensions/newaddon.inc.css
diff --git a/toolkit/themes/windows/mozapps/jar.mn b/toolkit/themes/windows/mozapps/jar.mn
index 901e93e4e..b5907d016 100644
--- a/toolkit/themes/windows/mozapps/jar.mn
+++ b/toolkit/themes/windows/mozapps/jar.mn
@@ -6,21 +6,23 @@ toolkit.jar:
#include ../../shared/mozapps.inc.mn
skin/classic/mozapps/downloads/downloadIcon.png (downloads/downloadIcon.png)
skin/classic/mozapps/downloads/downloads.css (downloads/downloads.css)
-* skin/classic/mozapps/extensions/extensions.css (extensions/extensions.css)
- skin/classic/mozapps/extensions/category-search.png (extensions/category-search.png)
- skin/classic/mozapps/extensions/category-discover.png (extensions/category-discover.png)
- skin/classic/mozapps/extensions/category-plugins.png (extensions/category-plugins.png)
- skin/classic/mozapps/extensions/category-service.png (extensions/category-service.png)
- skin/classic/mozapps/extensions/category-recent.png (extensions/category-recent.png)
- skin/classic/mozapps/extensions/category-available.png (extensions/category-available.png)
- skin/classic/mozapps/extensions/extensionGeneric-16.png (extensions/extensionGeneric-16.png)
- skin/classic/mozapps/extensions/themeGeneric.png (extensions/themeGeneric.png)
- skin/classic/mozapps/extensions/themeGeneric-16.png (extensions/themeGeneric-16.png)
- skin/classic/mozapps/extensions/dictionaryGeneric.png (extensions/dictionaryGeneric.png)
- skin/classic/mozapps/extensions/dictionaryGeneric-16.png (extensions/dictionaryGeneric-16.png)
- skin/classic/mozapps/extensions/localeGeneric.png (extensions/localeGeneric.png)
- skin/classic/mozapps/extensions/heart.png (extensions/heart.png)
-* skin/classic/mozapps/extensions/newaddon.css (extensions/newaddon.css)
+#ifdef MOZ_WEBEXTENSIONS
+* skin/classic/mozapps/extensions/extensions.css (webextensions/extensions.css)
+ skin/classic/mozapps/extensions/category-search.png (webextensions/category-search.png)
+ skin/classic/mozapps/extensions/category-discover.png (webextensions/category-discover.png)
+ skin/classic/mozapps/extensions/category-plugins.png (webextensions/category-plugins.png)
+ skin/classic/mozapps/extensions/category-service.png (webextensions/category-service.png)
+ skin/classic/mozapps/extensions/category-recent.png (webextensions/category-recent.png)
+ skin/classic/mozapps/extensions/category-available.png (webextensions/category-available.png)
+ skin/classic/mozapps/extensions/extensionGeneric-16.png (webextensions/extensionGeneric-16.png)
+ skin/classic/mozapps/extensions/themeGeneric.png (webextensions/themeGeneric.png)
+ skin/classic/mozapps/extensions/themeGeneric-16.png (webextensions/themeGeneric-16.png)
+ skin/classic/mozapps/extensions/dictionaryGeneric.png (webextensions/dictionaryGeneric.png)
+ skin/classic/mozapps/extensions/dictionaryGeneric-16.png (webextensions/dictionaryGeneric-16.png)
+ skin/classic/mozapps/extensions/localeGeneric.png (webextensions/localeGeneric.png)
+ skin/classic/mozapps/extensions/heart.png (webextensions/heart.png)
+* skin/classic/mozapps/extensions/newaddon.css (webextensions/newaddon.css)
+#endif
skin/classic/mozapps/plugins/pluginGeneric.png (plugins/pluginGeneric.png)
skin/classic/mozapps/plugins/pluginBlocked.png (plugins/pluginBlocked.png)
skin/classic/mozapps/plugins/pluginGeneric-16.png (plugins/pluginGeneric-16.png)
@@ -29,14 +31,16 @@ toolkit.jar:
skin/classic/mozapps/viewsource/viewsource.css (viewsource/viewsource.css)
skin/classic/mozapps/downloads/downloadButtons-XP.png (downloads/downloadButtons-XP.png)
skin/classic/mozapps/downloads/downloadIcon-XP.png (downloads/downloadIcon-XP.png)
- skin/classic/mozapps/extensions/category-discover-XP.png (extensions/category-discover-XP.png)
- skin/classic/mozapps/extensions/category-plugins-XP.png (extensions/category-plugins-XP.png)
- skin/classic/mozapps/extensions/category-recent-XP.png (extensions/category-recent-XP.png)
- skin/classic/mozapps/extensions/category-available-XP.png (extensions/category-available-XP.png)
- skin/classic/mozapps/extensions/extensionGeneric-16-XP.png (extensions/extensionGeneric-16-XP.png)
- skin/classic/mozapps/extensions/themeGeneric-XP.png (extensions/themeGeneric-XP.png)
- skin/classic/mozapps/extensions/themeGeneric-16-XP.png (extensions/themeGeneric-16-XP.png)
- skin/classic/mozapps/extensions/localeGeneric-XP.png (extensions/localeGeneric-XP.png)
+#ifdef MOZ_WEBEXTENSIONS
+ skin/classic/mozapps/extensions/category-discover-XP.png (webextensions/category-discover-XP.png)
+ skin/classic/mozapps/extensions/category-plugins-XP.png (webextensions/category-plugins-XP.png)
+ skin/classic/mozapps/extensions/category-recent-XP.png (webextensions/category-recent-XP.png)
+ skin/classic/mozapps/extensions/category-available-XP.png (webextensions/category-available-XP.png)
+ skin/classic/mozapps/extensions/extensionGeneric-16-XP.png (webextensions/extensionGeneric-16-XP.png)
+ skin/classic/mozapps/extensions/themeGeneric-XP.png (webextensions/themeGeneric-XP.png)
+ skin/classic/mozapps/extensions/themeGeneric-16-XP.png (webextensions/themeGeneric-16-XP.png)
+ skin/classic/mozapps/extensions/localeGeneric-XP.png (webextensions/localeGeneric-XP.png)
+#endif
skin/classic/mozapps/plugins/pluginGeneric-XP.png (plugins/pluginGeneric-XP.png)
skin/classic/mozapps/plugins/pluginBlocked-XP.png (plugins/pluginBlocked-XP.png)
skin/classic/mozapps/plugins/pluginGeneric-16-XP.png (plugins/pluginGeneric-16-XP.png)
@@ -50,6 +54,7 @@ toolkit.jar:
#endif
% override chrome://mozapps/skin/downloads/downloadButtons.png chrome://mozapps/skin/downloads/downloadButtons-XP.png osversion<6
% override chrome://mozapps/skin/downloads/downloadIcon.png chrome://mozapps/skin/downloads/downloadIcon-XP.png osversion<6
+#ifdef MOZ_WEBEXTENSIONS
% override chrome://mozapps/skin/extensions/category-discover.png chrome://mozapps/skin/extensions/category-discover-XP.png osversion<6
% override chrome://mozapps/skin/extensions/category-plugins.png chrome://mozapps/skin/extensions/category-plugins-XP.png osversion<6
% override chrome://mozapps/skin/extensions/category-recent.png chrome://mozapps/skin/extensions/category-recent-XP.png osversion<6
@@ -58,6 +63,7 @@ toolkit.jar:
% override chrome://mozapps/skin/extensions/themeGeneric.png chrome://mozapps/skin/extensions/themeGeneric-XP.png osversion<6
% override chrome://mozapps/skin/extensions/themeGeneric-16.png chrome://mozapps/skin/extensions/themeGeneric-16-XP.png osversion<6
% override chrome://mozapps/skin/extensions/localeGeneric.png chrome://mozapps/skin/extensions/localeGeneric-XP.png osversion<6
+#endif
% override chrome://mozapps/skin/plugins/pluginGeneric.png chrome://mozapps/skin/plugins/pluginGeneric-XP.png osversion<6
% override chrome://mozapps/skin/plugins/pluginBlocked.png chrome://mozapps/skin/plugins/pluginBlocked-XP.png osversion<6
% override chrome://mozapps/skin/plugins/pluginGeneric-16.png chrome://mozapps/skin/plugins/pluginGeneric-16-XP.png osversion<6
diff --git a/toolkit/themes/windows/mozapps/extensions/about.css b/toolkit/themes/windows/mozapps/webextensions/about.css
index 19eaddca8..19eaddca8 100644
--- a/toolkit/themes/windows/mozapps/extensions/about.css
+++ b/toolkit/themes/windows/mozapps/webextensions/about.css
diff --git a/toolkit/themes/windows/mozapps/extensions/blocklist.css b/toolkit/themes/windows/mozapps/webextensions/blocklist.css
index 1cdbb35ac..1cdbb35ac 100644
--- a/toolkit/themes/windows/mozapps/extensions/blocklist.css
+++ b/toolkit/themes/windows/mozapps/webextensions/blocklist.css
diff --git a/toolkit/themes/windows/mozapps/extensions/cancel.png b/toolkit/themes/windows/mozapps/webextensions/cancel.png
index 0d98ab235..0d98ab235 100644
--- a/toolkit/themes/windows/mozapps/extensions/cancel.png
+++ b/toolkit/themes/windows/mozapps/webextensions/cancel.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-available-XP.png b/toolkit/themes/windows/mozapps/webextensions/category-available-XP.png
index d1b737ab0..d1b737ab0 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-available-XP.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-available-XP.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-available.png b/toolkit/themes/windows/mozapps/webextensions/category-available.png
index 9341f2aa7..9341f2aa7 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-available.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-available.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-discover-XP.png b/toolkit/themes/windows/mozapps/webextensions/category-discover-XP.png
index a6f5b49b3..a6f5b49b3 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-discover-XP.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-discover-XP.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-discover.png b/toolkit/themes/windows/mozapps/webextensions/category-discover.png
index af954a613..af954a613 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-discover.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-discover.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-plugins-XP.png b/toolkit/themes/windows/mozapps/webextensions/category-plugins-XP.png
index 5c4d8bf47..5c4d8bf47 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-plugins-XP.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-plugins-XP.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-plugins.png b/toolkit/themes/windows/mozapps/webextensions/category-plugins.png
index 100a90307..100a90307 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-plugins.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-plugins.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-recent-XP.png b/toolkit/themes/windows/mozapps/webextensions/category-recent-XP.png
index 7ecfc7d4c..7ecfc7d4c 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-recent-XP.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-recent-XP.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-recent.png b/toolkit/themes/windows/mozapps/webextensions/category-recent.png
index d65158646..d65158646 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-recent.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-recent.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-search.png b/toolkit/themes/windows/mozapps/webextensions/category-search.png
index 52e91a7ce..52e91a7ce 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-search.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-search.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/category-service.png b/toolkit/themes/windows/mozapps/webextensions/category-service.png
index 997c8541c..997c8541c 100644
--- a/toolkit/themes/windows/mozapps/extensions/category-service.png
+++ b/toolkit/themes/windows/mozapps/webextensions/category-service.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/dictionaryGeneric-16.png b/toolkit/themes/windows/mozapps/webextensions/dictionaryGeneric-16.png
index 37e2a5e4c..37e2a5e4c 100644
--- a/toolkit/themes/windows/mozapps/extensions/dictionaryGeneric-16.png
+++ b/toolkit/themes/windows/mozapps/webextensions/dictionaryGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/dictionaryGeneric.png b/toolkit/themes/windows/mozapps/webextensions/dictionaryGeneric.png
index b26bb7100..b26bb7100 100644
--- a/toolkit/themes/windows/mozapps/extensions/dictionaryGeneric.png
+++ b/toolkit/themes/windows/mozapps/webextensions/dictionaryGeneric.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/discover-logo.png b/toolkit/themes/windows/mozapps/webextensions/discover-logo.png
index cd50735a8..cd50735a8 100644
--- a/toolkit/themes/windows/mozapps/extensions/discover-logo.png
+++ b/toolkit/themes/windows/mozapps/webextensions/discover-logo.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/eula.css b/toolkit/themes/windows/mozapps/webextensions/eula.css
index 05aeb3c1c..05aeb3c1c 100644
--- a/toolkit/themes/windows/mozapps/extensions/eula.css
+++ b/toolkit/themes/windows/mozapps/webextensions/eula.css
diff --git a/toolkit/themes/windows/mozapps/extensions/experimentGeneric.png b/toolkit/themes/windows/mozapps/webextensions/experimentGeneric.png
index a9d00545e..a9d00545e 100644
--- a/toolkit/themes/windows/mozapps/extensions/experimentGeneric.png
+++ b/toolkit/themes/windows/mozapps/webextensions/experimentGeneric.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/extensionGeneric-16-XP.png b/toolkit/themes/windows/mozapps/webextensions/extensionGeneric-16-XP.png
index 36e7689a3..36e7689a3 100644
--- a/toolkit/themes/windows/mozapps/extensions/extensionGeneric-16-XP.png
+++ b/toolkit/themes/windows/mozapps/webextensions/extensionGeneric-16-XP.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/extensionGeneric-16.png b/toolkit/themes/windows/mozapps/webextensions/extensionGeneric-16.png
index 2724b9e7c..2724b9e7c 100644
--- a/toolkit/themes/windows/mozapps/extensions/extensionGeneric-16.png
+++ b/toolkit/themes/windows/mozapps/webextensions/extensionGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/webextensions/extensions.css b/toolkit/themes/windows/mozapps/webextensions/extensions.css
new file mode 100644
index 000000000..7c4aed05e
--- /dev/null
+++ b/toolkit/themes/windows/mozapps/webextensions/extensions.css
@@ -0,0 +1,42 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+%include ../../../shared/webextensions/extensions.inc.css
+
+#header-utils-btn {
+ list-style-image: url("chrome://mozapps/skin/extensions/utilities.svg#utilities");
+ margin-inline-end: 16px;
+}
+
+@media not all and (-moz-windows-default-theme) {
+ #header-utils-btn {
+ list-style-image: url("chrome://mozapps/skin/extensions/utilities.svg#utilities-native");
+ }
+}
+
+.sorter[checkState="1"] {
+ list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
+}
+
+.sorter[checkState="2"] {
+ list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
+}
+
+.addon .relnotes-toggle {
+ -moz-box-direction: reverse;
+ list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
+}
+
+.addon[show-relnotes] .relnotes-toggle {
+ list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
+}
+
+.meta-rating > .star {
+ list-style-image: url("chrome://mozapps/skin/extensions/rating-not-won.png");
+ padding: 0 1px;
+}
+
+.meta-rating > .star[on="true"] {
+ list-style-image: url("chrome://mozapps/skin/extensions/rating-won.png");
+}
diff --git a/toolkit/themes/windows/mozapps/extensions/heart.png b/toolkit/themes/windows/mozapps/webextensions/heart.png
index 655f4c4be..655f4c4be 100644
--- a/toolkit/themes/windows/mozapps/extensions/heart.png
+++ b/toolkit/themes/windows/mozapps/webextensions/heart.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/localeGeneric-XP.png b/toolkit/themes/windows/mozapps/webextensions/localeGeneric-XP.png
index 4d9ac5ad8..4d9ac5ad8 100644
--- a/toolkit/themes/windows/mozapps/extensions/localeGeneric-XP.png
+++ b/toolkit/themes/windows/mozapps/webextensions/localeGeneric-XP.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/localeGeneric.png b/toolkit/themes/windows/mozapps/webextensions/localeGeneric.png
index 623ba3a6a..623ba3a6a 100644
--- a/toolkit/themes/windows/mozapps/extensions/localeGeneric.png
+++ b/toolkit/themes/windows/mozapps/webextensions/localeGeneric.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/webextensions/newaddon.css b/toolkit/themes/windows/mozapps/webextensions/newaddon.css
new file mode 100644
index 000000000..5856c08b5
--- /dev/null
+++ b/toolkit/themes/windows/mozapps/webextensions/newaddon.css
@@ -0,0 +1,5 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+%include ../../../shared/webextensions/newaddon.inc.css
diff --git a/toolkit/themes/windows/mozapps/extensions/rating-not-won.png b/toolkit/themes/windows/mozapps/webextensions/rating-not-won.png
index 2761f1925..2761f1925 100644
--- a/toolkit/themes/windows/mozapps/extensions/rating-not-won.png
+++ b/toolkit/themes/windows/mozapps/webextensions/rating-not-won.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/rating-won.png b/toolkit/themes/windows/mozapps/webextensions/rating-won.png
index 336dd8f6e..336dd8f6e 100644
--- a/toolkit/themes/windows/mozapps/extensions/rating-won.png
+++ b/toolkit/themes/windows/mozapps/webextensions/rating-won.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/themeGeneric-16-XP.png b/toolkit/themes/windows/mozapps/webextensions/themeGeneric-16-XP.png
index 16d77a4a2..16d77a4a2 100644
--- a/toolkit/themes/windows/mozapps/extensions/themeGeneric-16-XP.png
+++ b/toolkit/themes/windows/mozapps/webextensions/themeGeneric-16-XP.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/themeGeneric-16.png b/toolkit/themes/windows/mozapps/webextensions/themeGeneric-16.png
index ff13ce37f..ff13ce37f 100644
--- a/toolkit/themes/windows/mozapps/extensions/themeGeneric-16.png
+++ b/toolkit/themes/windows/mozapps/webextensions/themeGeneric-16.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/themeGeneric-XP.png b/toolkit/themes/windows/mozapps/webextensions/themeGeneric-XP.png
index be645f76d..be645f76d 100644
--- a/toolkit/themes/windows/mozapps/extensions/themeGeneric-XP.png
+++ b/toolkit/themes/windows/mozapps/webextensions/themeGeneric-XP.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/themeGeneric.png b/toolkit/themes/windows/mozapps/webextensions/themeGeneric.png
index 9cea549dd..9cea549dd 100644
--- a/toolkit/themes/windows/mozapps/extensions/themeGeneric.png
+++ b/toolkit/themes/windows/mozapps/webextensions/themeGeneric.png
Binary files differ
diff --git a/toolkit/themes/windows/mozapps/extensions/update.css b/toolkit/themes/windows/mozapps/webextensions/update.css
index 0db179330..0db179330 100644
--- a/toolkit/themes/windows/mozapps/extensions/update.css
+++ b/toolkit/themes/windows/mozapps/webextensions/update.css
diff --git a/toolkit/themes/windows/mozapps/extensions/xpinstallConfirm.css b/toolkit/themes/windows/mozapps/webextensions/xpinstallConfirm.css
index 42db4cd4d..42db4cd4d 100644
--- a/toolkit/themes/windows/mozapps/extensions/xpinstallConfirm.css
+++ b/toolkit/themes/windows/mozapps/webextensions/xpinstallConfirm.css
diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild
index 0f5b6e997..439282525 100644
--- a/toolkit/toolkit.mozbuild
+++ b/toolkit/toolkit.mozbuild
@@ -157,8 +157,6 @@ DIRS += [
if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
DIRS += ['/toolkit/system/gnome']
-DIRS += ['/addon-sdk']
-
if CONFIG['ENABLE_MARIONETTE'] or CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('gonk', 'android'):
DIRS += [
'/testing/firefox-ui',